private void billitemgrid_CellClick(object sender, DataGridViewCellEventArgs e) { DataGridViewRow r = new DataGridViewRow(); r = billitemgrid.Rows[e.RowIndex]; if (DialogResult.Yes == MessageBox.Show("Are you want to Delete", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Information)) { billgrid b = billsitem.FirstOrDefault(m => m.Stockid == Int32.Parse(r.Cells["Stockid"].Value.ToString()) && m.Quantity == Int32.Parse(r.Cells["Quantity"].Value.ToString())); billsitem.Remove(b); ServiceSale.Sale s = new ServiceSale.Sale(); s = saledata.FirstOrDefault(m => m.Stock_ID == b.Stockid && m.Quantity == b.Quantity); saledata.Remove(s); load_sale(); } }
private void addtobill_Click(object sender, EventArgs e) { ServiceStock.StockData s = new ServiceStock.StockData(); s = sdata.FirstOrDefault(m => m.Id == stockid[brproductlist.SelectedIndex]); ServiceSale.Sale row = new ServiceSale.Sale(); row.Quantity = Int32.Parse(productquntity.Text); row.Stock_ID = stockid[brproductlist.SelectedIndex]; row.Total = row.Quantity * s.Price; saledata.Add(row); billgrid b = new billgrid(); b.Name = s.Name; b.Quantity = row.Quantity; b.Stockid = row.Stock_ID; b.Price = s.Price; b.Total = (int)row.Total; billsitem.Add(b); load_sale(); }