public bool deletefromChart(SaleMedicine m) { string query = "DELETE from addToChart WHERE Id = '" + m.MadId + "'"; try { dcc.ConnectWithDB(); int n = dcc.ExecuteSQL(query); dcc.CloseConnection(); return(true); } catch (Exception ex) { dcc.CloseConnection(); return(false); } finally { dcc.CloseConnection(); } var item = listToSale.Find(x => x.MadId == m.MadId); listToSale.Remove(item); var del = listToUpdateMedicin.Find(x => x.MadId == m.MadId); listToUpdateMedicin.Remove(del); }
public List <SaleMedicine> viewSoldMedicine() { List <SaleMedicine> soldMDCNList = new List <SaleMedicine>(); string query = "SELECT * from SoldMedicine"; dcc.ConnectWithDB(); SqlDataReader sdr = dcc.GetData(query); while (sdr.Read()) { SaleMedicine md = new SaleMedicine(); md.MadId = sdr["Id"].ToString(); md.MadName = sdr["Name"].ToString(); md.MadCompanyname = sdr["Company Name"].ToString(); md.ManufacturingDate = sdr["Manufcturing Date"].ToString(); md.Expiringdate = sdr["Expired date"].ToString(); md.StockDate = sdr["Stock date"].ToString(); md.Price = Convert.ToDouble(sdr["Price"].ToString()); md.Quantity = Convert.ToInt32(sdr["Quantity"]); md.SaleDate = sdr["Sold date"].ToString(); soldMDCNList.Add(md); } dcc.CloseConnection(); return(soldMDCNList); }
private void cell_Click_SoldTable_Method(object sender, DataGridViewCellEventArgs e) { SaleMedicine sm = new SaleMedicine(); sm.MadId = AddtoCharGridDataView.Rows[e.RowIndex].Cells[0].Value.ToString(); sm.MadName = AddtoCharGridDataView.Rows[e.RowIndex].Cells[1].Value.ToString(); sm.MadCompanyname = AddtoCharGridDataView.Rows[e.RowIndex].Cells[2].Value.ToString(); sm.ManufacturingDate = AddtoCharGridDataView.Rows[e.RowIndex].Cells[3].Value.ToString(); sm.Expiringdate = AddtoCharGridDataView.Rows[e.RowIndex].Cells[4].Value.ToString(); sm.StockDate = AddtoCharGridDataView.Rows[e.RowIndex].Cells[5].Value.ToString(); sm.Quantity = Convert.ToInt32(AddtoCharGridDataView.Rows[e.RowIndex].Cells[6].Value); sm.Price = Convert.ToDouble(AddtoCharGridDataView.Rows[e.RowIndex].Cells[7].Value); sm.SaleDate = AddtoCharGridDataView.Rows[e.RowIndex].Cells[8].Value.ToString(); sr.deletefromChart(sm); this.viewinChart_Method(sender, e); }
public bool addtoChart_Method(Medicine m, string quantity) { SaleMedicine sl; DateTime d = new DateTime(); int u = m.Quantity; int q = int.Parse(quantity); int k = u - q; quantityOfMdcn = k.ToString(); string query = "INSERT into addToChart values('" + m.MadId + "', '" + m.MadName + "', '" + m.MadCompanyname + "', '" + m.ManufacturingDate + "', '" + m.Expiringdate + "', '" + m.StockDate + "', " + m.Price + " , " + quantity + ", '" + d + "')"; sl = new SaleMedicine(); sl.MadId = m.MadId; sl.MadName = m.MadName; sl.MadCompanyname = m.MadCompanyname; sl.ManufacturingDate = m.ManufacturingDate; sl.Expiringdate = m.Expiringdate; sl.StockDate = m.StockDate; sl.Price = m.Price; sl.Quantity = int.Parse(quantity); sl.SaleDate = d.ToString(); listToSale.Add(sl); m.Quantity = k; listToUpdateMedicin.Add(m); try { dcc.ConnectWithDB(); int n = dcc.ExecuteSQL(query); dcc.CloseConnection(); return(true); } catch (Exception ex) { dcc.CloseConnection(); return(false); } finally { dcc.CloseConnection(); } }