private void btnAdd_Click(object sender, EventArgs e) { // dataGridView1.CurrentRow.Cells["itemName"].Value = cmbitemname.SelectedItem.ToString(); // dataGridView1.CurrentRow.Cells["itemQty"].Value = txtqty.Text.ToString(); if (cmbitemname.SelectedIndex != 0 && txtqty.Text.Length != 0) { String name = cmbitemname.SelectedItem.ToString(); int qty = Convert.ToInt32(txtqty.Text.ToString()); DBItem dbi = new DBItem(); int price = dbi.getItemPrice(name); int subtot = price * qty; count_qty = count_qty + qty; count_tot = count_tot + subtot; txttotqty.Text = count_qty.ToString(); txtprice.Text = count_tot.ToString(); txtstatus.Text = "Active"; String[] row = { name, qty.ToString(), subtot.ToString() }; dataGridView1.Rows.Add(row); } else { MessageBox.Show("Please insert data to all fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void metroTile1_Click(object sender, EventArgs e) { int error = 0; if (metroTextBox4.Text.Length == 0 && metroTextBox3.Text.Length == 0 && metroTextBox5.Text.Length == 0) { error = 1; MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbPorderNo.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select a Purchase Order Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (metroComboBox1.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (metroTextBox4.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error == 0) { int flag = 0; String date = txtdate.Text; int Purchase_OrderNo = Convert.ToInt32(cmbPorderNo.SelectedItem); DBGRN g = new DBGRN(); int GRN_No = g.setGRN(count_qty, count_tot, date, u_id, Purchase_OrderNo); DBGRN_Item_reference gp = new DBGRN_Item_reference(); foreach (DataGridViewRow Datarow in dataGridView1.Rows) { if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null) { String itemname = dataGridView1.CurrentRow.Cells["Item_Name"].Value.ToString(); int itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value); int itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value); DBItem di = new DBItem(); int itemno = di.getItemNo(itemname); line = gp.setData(itemno, itemqty, itemtot, GRN_No); di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag); } } if (line == 1) { MessageBox.Show("Data Entered Successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(" Database Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void cmbsupname_SelectedIndexChanged(object sender, EventArgs e) { DBItem dbi = new DBItem(); DR = dbi.getItemNames(cmbsupname.SelectedItem.ToString()); while (DR.Read()) { cmbitemname.Items.Add(DR[0]).ToString(); } }
private void mtAdd_Click(object sender, EventArgs e) { int error = 0; if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtqty.Text) || String.IsNullOrEmpty(txtprice.Text) || String.IsNullOrEmpty(txtstatus.Text) || String.IsNullOrEmpty(txtdes.Text) || comboBox1.Text == "") { error = 1; MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtprice.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtqty.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Quanity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtname.Text.Any(Char.IsDigit)) { error = 1; MessageBox.Show("Name cannot contain digits", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error == 1) { MessageBox.Show("Check if all the fields are filled correctly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { String name = txtname.Text; int price = Convert.ToInt32(txtprice.Text); int qty = Convert.ToInt32(txtqty.Text); String status = txtstatus.Text; String des = txtdes.Text; int sup = comboBox1.SelectedIndex; DBItem di = new DBItem(); int line = di.setItem(name, price, qty, status, des, u_id, sup); if (line == 1) { MessageBox.Show("Data entered successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Please re-enter the data", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception er) { MessageBox.Show("An Error occured, Please re-enter your data", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void CustomerMenu_Load(object sender, EventArgs e) { SqlDataAdapter da; DBItem i = new DBItem(); da = i.getItemDetails(); DataTable dt = new DataTable(); da.Fill(dt); metroGrid1.DataSource = dt; }
private void mtadd_Click_1(object sender, EventArgs e) { int flag = 1, error = 0; String date = txtdate.Text; String status = txtstatus.Text; DBSales ds = new DBSales(); if (txtqty.Text.Length == 0 && txtprice.Text.Length == 0 && txtstatus.Text.Length == 0) { MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); error = 1; } if (txtprice.Text.Any(Char.IsLetter)) { MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); error = 1; } if (txtqty.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbitemname.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error == 1) { MessageBox.Show("Check if all the fields are filled correctly", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { int so_no = ds.setSalesOrder(date, status, count_tot, count_qty, u_id, no); DBSales_Item_reference S_I_ref = new DBSales_Item_reference(); foreach (DataGridViewRow Datarow in dataGridView1.Rows) { if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null) { String itemName = dataGridView1.CurrentRow.Cells["itemName"].Value.ToString(); int itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["itemQty"].Value); int itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["itemPrice"].Value); DBItem di = new DBItem(); int itemno = di.getItemNo(itemName); S_I_ref.setReference(so_no, itemno, itemqty, itemtot); di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag); } } } }
private void mtadd_Click(object sender, EventArgs e) { int error = 0; if (txtprice.Text.Length == 0 && txtstatus.Text.Length == 0 && txtqty.Text.Length == 0) { error = 1; MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (cmbitemname.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select an Item Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbsupname.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select a Supplier Name", "Ërror", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtprice.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (txtqty.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Quantity cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error != 1) { String date = txtdate.Text; String status = txtstatus.Text; String supname = cmbsupname.SelectedItem.ToString(); DBSupplier sup = new DBSupplier(); int sup_no = sup.getSupNo(supname); DBPurchases dp = new DBPurchases(); int po_no = dp.setPurchaseOrder(date, status, count_tot, count_qty, Users_ID, sup_no); DBPurchase_Item_reference P_I_ref = new DBPurchase_Item_reference(); foreach (DataGridViewRow Datarow in dataGridView1.Rows) { if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null) { String itemName = dataGridView1.CurrentRow.Cells["Item_Name"].Value.ToString(); int itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value); int itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value); DBItem di = new DBItem(); int itemno = di.getItemNo(itemName); P_I_ref.setReference(po_no, itemno, itemqty, itemtot); } } } }
private void mtAdd_Click(object sender, EventArgs e) ////// editable { int error = 0; if (txttotqty.Text.Length == 0 && txtprice.Text.Length == 0) { error = 1; MessageBox.Show("Please fill out all the fields", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (numQty.Value == 0) { error = 1; MessageBox.Show("Please select Item Quantity to return", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbporder.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select a Purchase Order Number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbsupname.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select a Supplier Name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error == 0) { int flag = 0; int PurchNo = Convert.ToInt32(cmbporder.SelectedItem); String date = txtdate.Text; int Users_ID = u_id; String supname = cmbsupname.SelectedItem.ToString(); DBSupplier sup = new DBSupplier(); int sup_no = sup.getSupNo(supname); DBPurchaseReturn dp = new DBPurchaseReturn(); int pr_no = dp.setPurchaseReturn(count_tot, count_qty, date, Users_ID, sup_no, PurchNo); DBPurchaseReturns_Item_reference PR_I_ref = new DBPurchaseReturns_Item_reference(); foreach (DataGridViewRow Datarow in dataGridView1.Rows) { if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null) { // String itemName = dataGridView1.CurrentRow.Cells["Item_Name"].Value.ToString(); int itemno = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_No"].Value); int itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value); int itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value); DBItem di = new DBItem(); //int itemno = di.getItemNo(itemName); flag = PR_I_ref.setReference(pr_no, itemno, itemqty, itemtot); di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag); } } } }
private void Sales_Orders_Load(object sender, EventArgs e) { txtdate.Text = System.DateTime.Today.ToString("M/d/yyyy"); DBItem s = new DBItem(); SqlDataReader DR; DR = s.getName(); while (DR.Read()) { cmbitemname.Items.Add(DR[0]); } }
private void mtAdd_Click(object sender, EventArgs e) { int error = 0; if (cmbcusnic.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select a NIC number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (cmbitemname.SelectedIndex == 0) { error = 1; MessageBox.Show("Please select an Item Name"); } if (txttotqty.Text.Length == 0 && txtprice.Text.Length == 0) { error = 1; MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } if (txtprice.Text.Any(Char.IsLetter)) { error = 1; MessageBox.Show("Price cannot contain letters", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (error == 0) { int flag = 0; int salesno = Convert.ToInt32(cmbsorder.SelectedItem); String date = txtdate.Text; int Users_ID = u_id; DBSalesReturns dp = new DBSalesReturns(); int sr_no = dp.setSalesReturn(count_tot, count_qty, Users_ID, cusno, salesno); DBSalesReturns_Item_reference SR_I_ref = new DBSalesReturns_Item_reference(); foreach (DataGridViewRow Datarow in dataGridView1.Rows) { if (Datarow.Cells[0].Value != null && Datarow.Cells[1].Value != null && Datarow.Cells[2].Value != null) { int itemno = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_No"].Value); int itemqty = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Item_Qty"].Value); int itemtot = Convert.ToInt32(dataGridView1.CurrentRow.Cells["Sub_Total"].Value); DBItem di = new DBItem(); SR_I_ref.setReference(sr_no, itemno, itemqty, itemtot); di.updateQty(itemno, itemqty, txtdate.Text.ToString(), flag); } } } }
private void cmbitemname_SelectedIndexChanged(object sender, EventArgs e) { int Qty = 0; DBSales_Item_reference sal = new DBSales_Item_reference(); String itemname = cmbitemname.SelectedItem.ToString(); DBItem i = new DBItem(); int itemno = i.getItemNo(itemname); DR = sal.getQty(itemno); while (DR.Read()) { Qty = Convert.ToInt32(DR[0]); } numQty.Maximum = Qty; numQty.Value = Qty; }
private void mtUpdate_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Do you want to update?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dr.ToString() == "Yes") { if (String.IsNullOrEmpty(txtname.Text) || String.IsNullOrEmpty(txtqty.Text) || String.IsNullOrEmpty(txtprice.Text) || String.IsNullOrEmpty(txtstatus.Text) || String.IsNullOrEmpty(txtdes.Text) || comboBox1.Text == "") { MessageBox.Show("Check if all the fields are filled", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { try { String name = txtname.Text; int price = Convert.ToInt32(txtprice.Text); int qty = Convert.ToInt32(txtqty.Text); String status = txtstatus.Text; String des = txtdes.Text; int sup = comboBox1.SelectedIndex; DBItem di = new DBItem(); int line = di.updateItem(no, name, price, qty, status, des, u_id, sup, System.DateTime.Now.ToShortDateString()); if (line == 1) { MessageBox.Show("Data entered successfully", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); SqlDataAdapter da; DBItem i = new DBItem(); da = i.getItem(); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; } } catch (Exception) { MessageBox.Show("Error , please try again", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void btnAdd_Click(object sender, EventArgs e) { if (cmbsupname.SelectedIndex != 0 && cmbitemname.SelectedIndex != 0 && txtqty.Text.Length != 0) { String Item_Name = cmbitemname.SelectedItem.ToString(); DBItem dbi = new DBItem(); int price = dbi.getItemPrice(Item_Name); int subtot = price * Convert.ToInt32(txtqty.Text); count_qty = count_qty + Convert.ToInt32(txtqty.Text); count_tot = count_tot + subtot; txtprice.Text = count_tot.ToString(); txtstatus.Text = "Active"; String[] row = { Item_Name, txtqty.Text, subtot.ToString() }; dataGridView1.Rows.Add(row); } else { MessageBox.Show("Please enter data to all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void cmbsorder_SelectedIndexChanged(object sender, EventArgs e) { int so_no = Convert.ToInt32(cmbsorder.SelectedItem); DBSales_Item_reference si = new DBSales_Item_reference(); DR = si.getItems(so_no); int itemno; String itemname = ""; while (DR.Read()) { itemno = Convert.ToInt32(DR[0]); DBItem i = new DBItem(); DR2 = i.getName(itemno); while (DR2.Read()) { itemname = DR2[0].ToString(); } cmbitemname.Items.Add(itemname); } }
private void mt_ADD_Click(object sender, EventArgs e) { if (metroComboBox1.SelectedIndex != 0 && metroTextBox4.Text.Length != 0) { DBItem i = new DBItem(); String itemname = metroComboBox1.SelectedItem.ToString(); int no = i.getItemNo(itemname); int qty = Convert.ToInt32(metroTextBox4.Text); int price = i.getItemPrice(metroComboBox1.SelectedItem.ToString()); int subtot = price * qty; String[] row = { itemname, qty.ToString(), subtot.ToString() }; dataGridView1.Rows.Add(row); count_qty = count_qty + qty; count_tot = count_tot + subtot; metroTextBox3.Text = count_tot.ToString(); metroTextBox5.Text = count_qty.ToString(); } else { MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e) { DBItem i = new DBItem(); int itemno = Convert.ToInt32(dataGridView2.CurrentRow.Cells["Item_No"].Value); DR = i.getName(itemno); while (DR.Read()) { metroTextBox1.Text = DR[0].ToString(); } int Qty = Convert.ToInt32(dataGridView2.CurrentRow.Cells["Item_Qty"].Value); /* DBPurchases pu = new DBPurchases(); * DR = pu.getQty(metroTextBox1.Text.ToString()); * while (DR.Read()) * { * Qty = Convert.ToInt32(DR[0]); * * } */ numQty.Maximum = Qty; numQty.Value = Qty; }
private void metroButton1_Click(object sender, EventArgs e) { if (numQty.Value != 0) { DBItem i = new DBItem(); int no = i.getItemNo(cmbitemname.Text.ToString()); int qty = Convert.ToInt32(numQty.Value); int price = i.getItemPrice(cmbitemname.Text.ToString()); int subtot = price * qty; String[] row = { no.ToString(), qty.ToString(), subtot.ToString() }; dataGridView1.Rows.Add(row); count_qty = count_qty + qty; count_tot = count_tot + subtot; txtprice.Text = count_tot.ToString(); txttotqty.Text = count_qty.ToString(); } else { MessageBox.Show("Please select item return quantity", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnadd_Click(object sender, EventArgs e) { if (metroTextBox1.Text.Length != 0) { DBItem i = new DBItem(); int no = i.getItemNo(metroTextBox1.Text.ToString()); //dataGridView1.CurrentRow.Cells["Item_No"].Value = no.ToString(); // dataGridView1.CurrentRow.Cells["Item_Qty"].Value = txtqty.Text; int qty = Convert.ToInt32(numQty.Value); int price = i.getItemPrice(metroTextBox1.Text.ToString()); // dataGridView1.CurrentRow.Cells["Sub_Total"].Value = (price * Convert.ToInt32(txtqty.Text)); int subtot = price * qty; String[] row = { no.ToString(), qty.ToString(), subtot.ToString() }; dataGridView1.Rows.Add(row); count_qty = count_qty + qty; count_tot = count_tot + subtot; txtprice.Text = count_tot.ToString(); txttotqty.Text = count_qty.ToString(); } else { MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Items_Load(object sender, EventArgs e) { try { SqlDataAdapter da; DBItem i = new DBItem(); da = i.getItem(); DataTable dt = new DataTable(); da.Fill(dt); dataGridView1.DataSource = dt; DBSupplier s = new DBSupplier(); SqlDataReader DR; DR = s.getSupplier(); while (DR.Read()) { comboBox1.Items.Add(DR[0]); } } catch (Exception) { MessageBox.Show("Please fill out all the fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }