示例#1
0
        private void EditBill()
        {
            dealer = SharedRepo.DBRepo.GetDealerByID(_dealerId);
            if (dealer == null)
            {
                MessageBox.Show("Dealer details not found");
                Close();
                return;
            }
            txtDealerName.Text = dealer.Name;

            if (_dealerBillId != 0)
            {
                Text                  = "Edit Dealer Bill";
                dealerBill            = SharedRepo.DBRepo.GetDealerBillByID(_dealerBillId);
                dtBillEntryDate.Value = DateHelper.GetDateObject(dealerBill.EntryDate);
                dtBillDate.Value      = DateHelper.GetDateObject(dealerBill.BillDate);
                numBillAmount.Value   = dealerBill.TotalAmount;
                txtRemarks.Text       = dealerBill.Remarks;
            }
            else
            {
                Text                  = "Add Dealer Bill";
                dealerBill            = new DealerBill();
                dtBillEntryDate.Value = DateHelper.GetDateNowObject();
            }
        }
示例#2
0
 public void SaveDealerBill(DealerBill bill)
 {
     bill.TimeStamp = DateHelper.GetDateNowString_Sortable();
     if (bill.Id == 0)
     {
         context.DealerBills.Add(bill);
         context.SaveChanges();
     }
     else
     {
         context.DealerBills.Attach(bill);
         context.Entry(bill).State = EntityState.Modified;
         context.SaveChanges();
     }
 }