private void btnupdate_Click(object sender, EventArgs e) { PurchaseInfo purchaseInfo = new PurchaseInfo(); GetTxtFieldData(purchaseInfo); purchaseInfo.AddUpdateDate(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt")); purchaseInfo.UpdateComputer = Environment.MachineName; PurchaseBLL objUpdate = new PurchaseBLL(); objUpdate.Update(purchaseInfo); FillDataGridView(); ClearTxtField(); }
private void btnSave_Click(object sender, EventArgs e) { PurchaseInfo purchaseInfo = new PurchaseInfo(); // Validation should be in separate class. GetTxtFieldData(purchaseInfo); purchaseInfo.UpdateComputer = Environment.MachineName; purchaseInfo.AddPurchaseDate(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt")); purchaseInfo.AddUpdateDate(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt")); // Inserting value by a data link layer. // Should be via BLL. Change will come PurchaseDLL purchaseDll = new PurchaseDLL(); purchaseDll.Save(purchaseInfo); FillDataGridView(); ClearTxtField(); }
public void Delete(PurchaseInfo obj) { PurchaseDLL objDll = new PurchaseDLL(); objDll.Delete(obj); }
public void Update(PurchaseInfo obj) { PurchaseDLL objDll = new PurchaseDLL(); objDll.Update(obj); }
public void Save(PurchaseInfo obj) { PurchaseDLL objDll = new PurchaseDLL(); objDll.Save(obj); }
private void GetTxtFieldData(PurchaseInfo purchaseInfo) { purchaseInfo.PurchaseId = txtID.Text; purchaseInfo.SupplierId = cmbSupplierId.SelectedValue.ToString(); purchaseInfo.MedicineId = cmbMedicineID.SelectedValue.ToString(); purchaseInfo.Price = Convert.ToDecimal(txtPrice.Text); purchaseInfo.Quantity = Convert.ToInt32(txtPurchaseQty.Text); }
private void FillTxtField(PurchaseInfo purchaseInfo) { txtID.Text = purchaseInfo.PurchaseId; String pharmaName = new PharmacuticlesDAL().GetPharmaName(purchaseInfo.SupplierId); String medicineName = new MedicineDAL().GetMedicineName(purchaseInfo.MedicineId); cmbSupplierId.SelectedIndex = cmbSupplierId.FindStringExact(pharmaName); cmbMedicineID.SelectedIndex = cmbMedicineID.FindStringExact(medicineName); txtPurchaseQty.Text = purchaseInfo.Quantity.ToString(); txtPrice.Text = purchaseInfo.Price.ToString(); }
private void dgv_MouseDoubleClick(object sender, MouseEventArgs e) { int row = dgvPurchaseInfo.CurrentRow.Index; PurchaseInfo purchaseInfo = new PurchaseInfo(); purchaseInfo.PurchaseId = dgvPurchaseInfo[1, row].Value.ToString(); purchaseInfo.SupplierId = dgvPurchaseInfo[3, row].Value.ToString(); purchaseInfo.Quantity = Convert.ToInt32(dgvPurchaseInfo[4, row].Value); purchaseInfo.Price = Convert.ToInt32(dgvPurchaseInfo[6, row].Value); purchaseInfo.MedicineId = dgvPurchaseInfo[14, row].Value.ToString(); FillTxtField(purchaseInfo); }
private void btndelete_Click(object sender, EventArgs e) { PurchaseInfo deleteInfo = new PurchaseInfo(); GetTxtFieldData(deleteInfo); DialogResult dialog = MessageBox.Show("Do you want to delete the selected row?","Delete", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { PurchaseBLL objBll = new PurchaseBLL(); objBll.Delete(deleteInfo); } FillDataGridView(); ClearTxtField(); }
public bool Delete(PurchaseInfo obj) { String Qry = "DELETE FROM PurchaseInfo WHERE PurchaseID='" + obj.PurchaseId + "'"; DbUtility.ExecuteQuery(Qry); return true; }
public bool Update(PurchaseInfo obj) { String Qry = "update PurchaseInfo set SupplierID= '" + obj.SupplierId + "', PurchaseQty= " + obj.Quantity + ", PurchaseValue= " + obj.Price + ", [UpdatedDate]='" + obj.UpdateDate + "', UpdatedComputer= '" + obj.UpdateComputer + "', MedicineID= '" + obj.MedicineId + "' where PurchaseID= '" + obj.PurchaseId + "'"; DbUtility.ExecuteQuery(Qry); return true; }
public bool Save(PurchaseInfo obj) { string Qry = "INSERT INTO [CureDB].[dbo].[PurchaseInfo]([PurchaseID],[PurchaseDate],[SupplierID],[PurchaseQty],[PurchaseValue],[UpdatedComputer], [MedicineID])VALUES('" + obj.PurchaseId + "','" + obj.PurchaseDate + "','" + obj.SupplierId + "'," + obj.Quantity + "," + obj.Price + ",'" + obj.UpdateComputer + "' , '" + obj.MedicineId + "') "; DbUtility.ExecuteQuery(Qry); return true; }