private void button5_Click(object sender, EventArgs e) { dataGridView3.Rows.Clear(); string cname = textBox1.Text.Trim(); double totalAmt = 0; string product = ""; int qty = 0; if (cname.Length > 0) { int imageWidth, tbQty = 0; if (Int32.TryParse(textBox2.Text, out imageWidth)) { tbQty = imageWidth; } TransactionMgnt.TransactionMgntClient txClient = new TransactionMgnt.TransactionMgntClient(); List <TransactionMgnt.GSTRates> gstrates = txClient.GetGSTRates().ToList(); if (tbQty > 0) { StockMgntRef.StockMgntClient stockMgntClient = new StockMgntRef.StockMgntClient(); var reg = stockMgntClient.GetRegulators(); int regStock = reg.Quentity; if (regStock >= tbQty) { double cgst = gstrates.Where(x => x.Comodity.Equals("Regulator")).FirstOrDefault().CGST; double sgst = gstrates.Where(x => x.Comodity.Equals("Regulator")).FirstOrDefault().SGST; DataGridViewRow nrow = (DataGridViewRow)dataGridView3.Rows[0].Clone(); nrow.Cells[0].Value = "Regulator(s)"; nrow.Cells[1].Value = tbQty; nrow.Cells[2].Value = reg.Price; nrow.Cells[3].Value = (100 + cgst + sgst) * (reg.Price * tbQty) / 100; totalAmt += double.Parse(nrow.Cells[3].Value.ToString()); dataGridView3.Rows.Add(nrow); } else { MessageBox.Show("Not Enough Stock of Regulators!!!"); } } foreach (DataGridViewRow row1 in dataGridView1.Rows) { if (row1.Cells[0].Value != null) { product = row1.Cells[0].Value.ToString(); if (int.Parse(row1.Cells[1].Value.ToString()) > 0) { var selectedStove = stoves.Where(x => x.Product.Equals(product)).FirstOrDefault(); if (selectedStove.Quentity >= qty) { qty = int.Parse(row1.Cells[1].Value.ToString()); double cgst = gstrates.Where(x => x.Comodity.Equals("Stove")).FirstOrDefault().CGST; double sgst = gstrates.Where(x => x.Comodity.Equals("Stove")).FirstOrDefault().SGST; DataGridViewRow nrow = (DataGridViewRow)dataGridView3.Rows[0].Clone(); nrow.Cells[0].Value = product; nrow.Cells[1].Value = qty; nrow.Cells[2].Value = selectedStove.Price; nrow.Cells[3].Value = (100 + cgst + sgst) * (selectedStove.Price * qty) / 100; totalAmt += double.Parse(nrow.Cells[3].Value.ToString()); dataGridView3.Rows.Add(nrow); } else { MessageBox.Show("Not Enough Stock of Stove '" + product + "' !!!"); } } } } label7.Text = totalAmt.ToString(); } }
private void button3_Click(object sender, EventArgs e) { string cname = textBox1.Text.Trim(); int cmnum = 0; string product = ""; int qty = 0; if (cname.Length > 0) { int imageWidth, tbQty = 0; if (Int32.TryParse(textBox2.Text, out imageWidth)) { tbQty = imageWidth; } if (tbQty > 0) { StockMgntRef.StockMgntClient stockMgntClient = new StockMgntRef.StockMgntClient(); int regStock = stockMgntClient.GetRegulators().Quentity; if (regStock >= tbQty) { TransactionMgnt.TransactionMgntClient client = new TransactionMgnt.TransactionMgntClient(); cmnum = client.RegulatorTx(cname, tbQty); //PrintBill(); } else { MessageBox.Show("Not Enough Stock of Regulators!!!"); } } foreach (DataGridViewRow row1 in dataGridView1.Rows) { if (row1.Cells[0].Value != null) { product = row1.Cells[0].Value.ToString(); if (int.Parse(row1.Cells[1].Value.ToString()) > 0) { int stoveStock = stoves.Where(x => x.Product.Equals(product)).FirstOrDefault().Quentity; if (stoveStock >= qty) { qty = int.Parse(row1.Cells[1].Value.ToString()); TransactionMgnt.TransactionMgntClient client1 = new TransactionMgnt.TransactionMgntClient(); cmnum = client1.StoveTx(cname, product, qty, cmnum); } else { MessageBox.Show("Not Enough Stock of Stove '" + product + "' !!!"); } } } } if (cmnum > 0) { textBox1.Text = ""; textBox2.Text = ""; dataGridView1.Rows.Clear(); MessageBox.Show("Transaction is done Successfully !!! \nCashmemo Number is " + cmnum); } TransactionMgnt.TransactionMgntClient txClient = new TransactionMgnt.TransactionMgntClient(); List <TransactionMgnt.GSTRates> gstrates = txClient.GetGSTRates().ToList(); int f = 0; foreach (DataGridViewRow r in dataGridView1.Rows) { if (r.Cells[1].Value != null) { if (int.Parse(r.Cells[1].Value.ToString()) != 0) { f = 1; break; } else { f = 0; } } } if (tbQty > 0) { f = 1; } if (f == 1) { //MessageBox.Show("In Print"); PrintReceipt(cname, cmnum, stoves, dataGridView3, gstrates); } else { MessageBox.Show("Can't Generate Invoice for zero Quentity !!!"); } } }