예제 #1
0
        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();
        }
예제 #2
0
        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();
        }
예제 #3
0
 public void Delete(PurchaseInfo obj)
 {
     PurchaseDLL objDll = new PurchaseDLL();
     objDll.Delete(obj);
 }
예제 #4
0
 public void Update(PurchaseInfo obj)
 {
     PurchaseDLL objDll = new PurchaseDLL();
     objDll.Update(obj);
 }
예제 #5
0
 public void Save(PurchaseInfo obj)
 {
     PurchaseDLL objDll = new PurchaseDLL();
     objDll.Save(obj);
 }
예제 #6
0
 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);
 }
예제 #7
0
 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();
 }
예제 #8
0
        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);

        }
예제 #9
0
 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();
 }
예제 #10
0
 public bool Delete(PurchaseInfo obj)
 {
     String Qry = "DELETE FROM PurchaseInfo WHERE PurchaseID='" + obj.PurchaseId + "'";
     DbUtility.ExecuteQuery(Qry);
     return true;
 }
예제 #11
0
 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;
 }
예제 #12
0
 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;
 }