This tutorial will teach Inventory Management Sales Part step by step.i already complete the part of category and brand and product and user login. this will cover about the sales part of Inventory Management
Sales
The app shall be able search the product name,price by the relavent barcode id.after got the product name,price where the user has the option to add the qty by click the add button to see all Products details which will be shown in the below table.after calculating the total on total textbox.
UI Design Of the App
activity_main.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 | <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:gravity="center" tools:context=".MainActivity"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Simple Sales Inventory Using Android" android:textColor="@color/colorAccent" android:gravity="center" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Product Name" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ed1" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Price" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ed2" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Qty" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/ed3" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Subtotal" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10sp" android:background="@color/colorPrimaryDark" android:id="@+id/txtsub" android:textColor="#fff" android:enabled="false" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Payment" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10sp" android:background="@color/colorPrimaryDark" android:id="@+id/txtpay" android:textColor="#fff" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Balance" /> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="10sp" android:background="@color/colorPrimaryDark" android:id="@+id/txtbal" android:textColor="#fff" android:enabled="false" android:ems="10" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btn1" android:text="Add" android:background="@color/colorAccent" /> </LinearLayout> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical"> <TableLayout android:layout_width="match_parent" android:layout_height="360dp" android:id="@+id/tb1" android:stretchColumns="*"> <TableRow android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/tbrow1"> <TextView android:id="@+id/t1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Product Name" /> <TextView android:id="@+id/t2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Price" /> <TextView android:id="@+id/t3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Qty" /> <TextView android:id="@+id/t4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Total" /> </TableRow> </TableLayout> </LinearLayout> </LinearLayout> |
MainActivity.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | package com.example.kobinath.simpleinventroy; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.Editable; import android.text.TextWatcher; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.TableLayout; import android.widget.TableRow; import android.widget.TextView; import java.util.ArrayList; public class MainActivity extends AppCompatActivity { private ArrayList<String> data = new ArrayList<String>(); private ArrayList<String> data1 = new ArrayList<String>(); private ArrayList<String> data2 = new ArrayList<String>(); private ArrayList<String> data3 = new ArrayList<String>(); private TableLayout table; EditText ed1,ed2,ed3,ed4,ed5,ed6; Button b1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ed1 = findViewById(R.id.ed1); ed2 = findViewById(R.id.ed2); ed3 = findViewById(R.id.ed3); ed4 = findViewById(R.id.txtsub); ed5 = findViewById(R.id.txtpay); ed6= findViewById(R.id.txtbal); b1 = findViewById(R.id.btn1); ed5.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { int subtotal = Integer.parseInt(ed4.getText().toString()); int pay = Integer.parseInt(ed5.getText().toString()); int bal = pay - subtotal; ed6.setText(String.valueOf(bal)); } @Override public void afterTextChanged(Editable s) { } }); b1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { add(); } }); } public void add() { int tot; String prodname = ed1.getText().toString(); int price = Integer.parseInt(ed2.getText().toString()); int qty = Integer.parseInt(ed3.getText().toString()); tot = price * qty; data.add(prodname); data1.add(String.valueOf(price)); data2.add(String.valueOf(qty)); data3.add(String.valueOf(tot)); TableLayout table = (TableLayout) findViewById(R.id.tb1); TableRow row = new TableRow(this); TextView t1 = new TextView(this); TextView t2 = new TextView(this); TextView t3 = new TextView(this); TextView t4 = new TextView(this); String total; int sum = 0; for(int i = 0; i< data.size(); i ++) { String pname = data.get(i); String prc = data1.get(i); String qtyy = data2.get(i); total = data3.get(i); t1.setText(pname); t2.setText(prc); t3.setText(qtyy); t4.setText(total); sum = sum + Integer.parseInt(data3.get(i).toString()); } row.addView(t1); row.addView(t2); row.addView(t3); row.addView(t4); table.addView(row); ed4.setText(String.valueOf(sum)); ed1.setText(""); ed2.setText(""); ed3.setText(""); ed1.requestFocus(); } } |
i have attached the video link below. which will do this tutorials step by step.