Exemplo n.º 1
0
        private void Billing_Load(object sender, EventArgs e)
        {
            metroLabelStdId.Text  = StudentHome.stdId;
            metroLabelModId.Text  = StudentHome.modId;
            metroLabelAmount.Text = StudentHome.modFee;
            b.setsid(StudentHome.stdId);
            b.setmId(StudentHome.modId);
            b.setAmount(StudentHome.modFee);
            b.setbid(metroTextBoxBillno.Text);
            b.setDate(metroLabelDate.Text);
            BillTransaction bt = new BillTransaction();

            bt.updateBill();
        }
Exemplo n.º 2
0
        public void RecordBillTransaction(BillDetail billDetail, User user, bool isCancel)
        {
            DateTime dateTimeNow = DateTime.Now;

            BillTransaction billTransaction = new BillTransaction();

            billTransaction.OrderNo           = billDetail.ActingBill.OrderNo;
            billTransaction.ExternalReceiptNo = billDetail.ActingBill.ExternalReceiptNo;
            billTransaction.ReceiptNo         = billDetail.ActingBill.ReceiptNo;
            billTransaction.Item                   = billDetail.ActingBill.Item.Code;
            billTransaction.ItemDescription        = billDetail.ActingBill.Item.Description;
            billTransaction.Uom                    = billDetail.ActingBill.Uom.Code;
            billTransaction.BillAddress            = billDetail.ActingBill.BillAddress.Code;
            billTransaction.BillAddressDescription = billDetail.ActingBill.BillAddress.Address;
            billTransaction.Party                  = billDetail.ActingBill.BillAddress.Party.Code;
            billTransaction.PartyName              = billDetail.ActingBill.BillAddress.Party.Name;
            if (!isCancel)
            {
                billTransaction.Qty = billDetail.BilledQty;
            }
            else
            {
                billTransaction.Qty = billDetail.BilledQty * -1;
            }
            billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString());   //仅保留年月日;
            if (billDetail.ActingBill.TransactionType == BusinessConstants.BILL_TRANS_TYPE_PO)
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_PO_BILL;
            }
            else
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_SO_BILL;
            }
            //billTransaction.PlannedBill = billDetail.ActingBill.Id;
            billTransaction.BillDetail        = billDetail.Id;
            billTransaction.CreateUser        = user.Code;
            billTransaction.CreateDate        = dateTimeNow;
            billTransaction.ActingBill        = billDetail.ActingBill.Id;
            billTransaction.LocationFrom      = billDetail.ActingBill.LocationFrom;
            billTransaction.IpNo              = billDetail.ActingBill.IpNo;
            billTransaction.ReferenceItemCode = billDetail.ActingBill.ReferenceItemCode;
            //billTransaction.Location = billDetail.ActingBill.LocationFrom;
            //billTransaction.LocationName = locationLotDetail.Location.Name;
            //billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty;
            //billTransaction.LotNo = locationLotDetail.LotNo;
            //billTransaction.BatchNo = locationLotDetail.Id;

            this.CreateBillTransaction(billTransaction);
        }
        public void RecordBillTransaction(BillDetail billDetail, User user, bool isCancel)
        {
            DateTime dateTimeNow = DateTime.Now;

            BillTransaction billTransaction = new BillTransaction();
            billTransaction.OrderNo = billDetail.ActingBill.OrderHead.OrderNo;
            billTransaction.ExternalReceiptNo = billDetail.ActingBill.ExternalReceiptNo;
            billTransaction.ReceiptNo = billDetail.ActingBill.ReceiptNo;
            billTransaction.Item = billDetail.ActingBill.Item.Code;
            billTransaction.ItemDescription = billDetail.ActingBill.Item.Description;
            billTransaction.Uom = billDetail.ActingBill.Uom.Code;
            billTransaction.BillAddress = billDetail.ActingBill.BillAddress.Code;
            billTransaction.BillAddressDescription = billDetail.ActingBill.BillAddress.Address;
            billTransaction.Party = billDetail.ActingBill.BillAddress.Party.Code;
            billTransaction.PartyName = billDetail.ActingBill.BillAddress.Party.Name;
            if (!isCancel)
            {
                billTransaction.Qty = billDetail.BilledQty;
            }
            else
            {
                billTransaction.Qty = billDetail.BilledQty * -1;
            }
            billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString());   //仅保留年月日;
            if (billDetail.ActingBill.TransactionType == BusinessConstants.BILL_TRANS_TYPE_PO)
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_PO_BILL;
            }
            else
            {
                billTransaction.TransactionType = BusinessConstants.BILL_TRANS_TYPE_SO_BILL;
            }
            //billTransaction.PlannedBill = billDetail.ActingBill.Id;
            billTransaction.BillDetailId = billDetail.Id;
            billTransaction.CreateUser = user.Code;
            billTransaction.CreateDate = dateTimeNow;
            billTransaction.ActingBill = billDetail.ActingBill.Id;
            billTransaction.LocationFrom = billDetail.ActingBill.LocationFrom;
            billTransaction.IpNo = billDetail.ActingBill.IpNo;
            billTransaction.ReferenceItemCode = billDetail.ActingBill.ReferenceItemCode;
            //billTransaction.Location = billDetail.ActingBill.LocationFrom;
            //billTransaction.LocationName = locationLotDetail.Location.Name;
            //billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty;
            //billTransaction.LotNo = locationLotDetail.LotNo;
            //billTransaction.BatchNo = locationLotDetail.Id;

            this.CreateBillTransaction(billTransaction);
        }
Exemplo n.º 4
0
 private void metroButtonPay_Click(object sender, EventArgs e)
 {
     if (metroComboBoxPay.Text == "")
     {
         MetroMessageBox.Show(this, "Please Select payment option!");
     }
     else
     {
         BillTransaction bt = new BillTransaction();
         bt.addPayment();
         Graphics g = this.CreateGraphics();
         bmp = new Bitmap(this.Size.Width, this.Size.Height, g);
         Graphics mg = Graphics.FromImage(bmp);
         mg.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, this.Size);
         printPreviewDialog.ShowDialog();
     }
 }
 private void metroButtonRegister_Click(object sender, EventArgs e)
 {
     //validate data
     if (metroTextBoxModId.Text == "" || metroTextBoxMod.Text == "" || metroComboBoxFaculty.Text == "" || metroTextBoxSem.Text == "" || metroTextBoxDuration.Text == "" || metroTextBoxMFee.Text == "" || metroTextBoxMOverview.Text == "")
     {
         MetroMessageBox.Show(this, "Fields cannot be left empty");
     }
     else
     {
         modId = metroTextBoxModId.Text;
         StudentTransactions st       = new StudentTransactions();
         string uname                 = metroLabelUser.Text;
         CommonDBTransaction c        = new CommonDBTransaction();
         string              sqlcheck = "SELECT SId FROM Student WHERE username= '******'";
         DataTable           d        = c.searchData(sqlcheck);//validate data from db
         string              profid   = d.ToString();
         CommonDBTransaction co       = new CommonDBTransaction();
         modId = metroTextBoxModId.Text;
         string    sql = "SELECT * FROM StudentModule WHERE sid = '" + profid + "'AND mid='" + modId + "'";
         DataTable dt  = co.searchData(sql);//validate data from db
         if (dt.Rows.Count > 0)
         {
             MetroMessageBox.Show(this, "You have already registered for this module!", "Warning");
             metroGridModules.DataSource = dt;
             metroGridModules.Refresh();
         }
         else
         {
             st.addstudentModule(); // insert data
             modFee = metroTextBoxMFee.Text;
             Bill            b  = new Bill(modFee, stdId, modId);
             BillTransaction bt = new BillTransaction();
             bt.addBill(b); //insert data
             this.Hide();
             Billing bill = new Billing();
             bill.Show();
             MetroMessageBox.Show(this, "Registration successful");
         }
     }
 }
Exemplo n.º 6
0
        public void RecordBillTransaction(PlannedBill plannedBill, ActingBill actingBill, LocationLotDetail locationLotDetail, User user)
        {
            #region 记BillTransaction
            DateTime dateTimeNow = DateTime.Now;

            BillTransaction billTransaction = new BillTransaction();
            billTransaction.OrderNo = plannedBill.OrderNo;
            billTransaction.ExternalReceiptNo = plannedBill.ExternalReceiptNo;
            billTransaction.ReceiptNo = plannedBill.ReceiptNo;
            billTransaction.Item = plannedBill.Item.Code;
            billTransaction.ItemDescription = plannedBill.Item.Description;
            billTransaction.Uom = plannedBill.Uom.Code;
            billTransaction.BillAddress = plannedBill.BillAddress.Code;
            billTransaction.BillAddressDescription = plannedBill.BillAddress.Address;
            billTransaction.Party = plannedBill.BillAddress.Party.Code;
            billTransaction.PartyName = plannedBill.BillAddress.Party.Name;
            billTransaction.Qty = plannedBill.CurrentActingQty;
            billTransaction.EffectiveDate = DateTime.Parse(dateTimeNow.ToShortDateString());   //仅保留年月日;
            billTransaction.TransactionType = plannedBill.TransactionType;
            billTransaction.PlannedBill = plannedBill.Id;
            billTransaction.CreateUser = user.Code;
            billTransaction.CreateDate = dateTimeNow;
            billTransaction.ActingBill = actingBill.Id;
            billTransaction.LocationFrom = plannedBill.LocationFrom;
            billTransaction.PartyFrom = plannedBill.PartyFrom;
            billTransaction.IpNo = plannedBill.IpNo;
            billTransaction.ReferenceItemCode = plannedBill.ReferenceItemCode;
            if (locationLotDetail != null)
            {
                billTransaction.Location = locationLotDetail.Location.Code;
                billTransaction.LocationName = locationLotDetail.Location.Name;
                billTransaction.HuId = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty;
                billTransaction.LotNo = locationLotDetail.LotNo;
                billTransaction.BatchNo = locationLotDetail.Id;
            }

            this.CreateBillTransaction(billTransaction);
            #endregion
        }
Exemplo n.º 7
0
        public void RecordBillTransaction(PlannedBill plannedBill, ActingBill actingBill, LocationLotDetail locationLotDetail, User user)
        {
            #region 记BillTransaction
            DateTime dateTimeNow = DateTime.Now;

            BillTransaction billTransaction = new BillTransaction();
            billTransaction.OrderNo           = plannedBill.OrderNo;
            billTransaction.ExternalReceiptNo = plannedBill.ExternalReceiptNo;
            billTransaction.ReceiptNo         = plannedBill.ReceiptNo;
            billTransaction.Item                   = plannedBill.Item.Code;
            billTransaction.ItemDescription        = plannedBill.Item.Description;
            billTransaction.Uom                    = plannedBill.Uom.Code;
            billTransaction.BillAddress            = plannedBill.BillAddress.Code;
            billTransaction.BillAddressDescription = plannedBill.BillAddress.Address;
            billTransaction.Party                  = plannedBill.BillAddress.Party.Code;
            billTransaction.PartyName              = plannedBill.BillAddress.Party.Name;
            billTransaction.Qty                    = plannedBill.CurrentActingQty;
            billTransaction.EffectiveDate          = DateTime.Parse(dateTimeNow.ToShortDateString()); //仅保留年月日;
            billTransaction.TransactionType        = plannedBill.TransactionType;
            billTransaction.PlannedBill            = plannedBill.Id;
            billTransaction.CreateUser             = user.Code;
            billTransaction.CreateDate             = dateTimeNow;
            billTransaction.ActingBill             = actingBill.Id;
            billTransaction.LocationFrom           = plannedBill.LocationFrom;
            billTransaction.PartyFrom              = plannedBill.PartyFrom;
            billTransaction.IpNo                   = plannedBill.IpNo;
            billTransaction.ReferenceItemCode      = plannedBill.ReferenceItemCode;
            if (locationLotDetail != null)
            {
                billTransaction.Location     = locationLotDetail.Location.Code;
                billTransaction.LocationName = locationLotDetail.Location.Name;
                billTransaction.HuId         = locationLotDetail.Hu != null ? locationLotDetail.Hu.HuId : string.Empty;
                billTransaction.LotNo        = locationLotDetail.LotNo;
                billTransaction.BatchNo      = locationLotDetail.Id;
            }

            this.CreateBillTransaction(billTransaction);
            #endregion
        }
 public virtual void DeleteBillTransaction(BillTransaction entity)
 {
     Delete(entity);
 }
 public virtual void UpdateBillTransaction(BillTransaction entity)
 {
     entityDao.UpdateBillTransaction(entity);
 }
Exemplo n.º 10
0
 public virtual void UpdateBillTransaction(BillTransaction entity)
 {
     Update(entity);
 }
Exemplo n.º 11
0
 public virtual void CreateBillTransaction(BillTransaction entity)
 {
     Create(entity);
 }
 public virtual void DeleteBillTransaction(BillTransaction entity)
 {
     entityDao.DeleteBillTransaction(entity);
 }
 public virtual void UpdateBillTransaction(BillTransaction entity)
 {
     entityDao.UpdateBillTransaction(entity);
 }
 public virtual void CreateBillTransaction(BillTransaction entity)
 {
     entityDao.CreateBillTransaction(entity);
 }
 public virtual void DeleteBillTransaction(BillTransaction entity)
 {
     entityDao.DeleteBillTransaction(entity);
 }
Exemplo n.º 16
0
        public ServiceResult<Bill> AddBill(string name, decimal amount, int billGroupId, int? categoryId, int? vendorId, DateTime startDate, DateTime endDate, int frequency, DateTime? secondaryStartDate, DateTime? secondaryEndDate)
        {
            ServiceResult<Bill> result = new ServiceResult<Bill>();

            if (categoryId.HasValue && categoryId.Value == 0)
                categoryId = null;
            if (vendorId.HasValue && vendorId.Value == 0)
                vendorId = null;

            // get bill group
            var billGroup = _billGroupRepository.GetById(billGroupId);
            if (billGroup == null)
            {
                // if we don't have any bill groups at all, create one
                if (_billGroupRepository.GetAll().Count() == 0)
                {
                    billGroup = new BillGroup() { IsActive = true, Name = "Bills" };
                    _billGroupRepository.Add(billGroup);
                    _unitOfWork.Commit();
                }
                else
                {
                    result.AddError(ErrorType.NotFound, "Bill Group {0} not found", billGroupId);
                    return result;
                }
            }

            // create bill
            var bill = new Bill()
            {
                Name = name,
                Amount = amount,
                BillGroupId = billGroup.Id,
                CategoryId = categoryId,
                VendorId = vendorId,
                StartDate = startDate,
                EndDate = endDate,
                RecurrenceFrequency = frequency,
                StartDate2 = secondaryStartDate,
                EndDate2 = secondaryEndDate
            };

            // create transactions
            int count = 0;
            DateTime cur = new DateTime(startDate.Year, startDate.Month, startDate.Day);

            while (cur <= endDate)
            {
                BillTransaction trx = new BillTransaction()
                {
                    Amount = amount,
                    OriginalAmount = amount,
                    CategoryId = categoryId,
                    OriginalCategoryId = categoryId,
                    VendorId = vendorId,
                    OriginalVendorId = vendorId,
                    Timestamp = cur,
                    OriginalTimestamp = cur
                };
                bill.BillTransactions.Add(trx);

                count++;
                if (frequency == 0)
                    cur = endDate.AddDays(1);
                else if (frequency > 0)
                    cur = startDate.AddDays(count * frequency);
                else
                    cur = startDate.AddMonths(count * -1 * frequency);
            }

            if (secondaryStartDate.HasValue)
            {
                if (secondaryEndDate.HasValue)
                    endDate = secondaryEndDate.Value;

                count = 0;
                cur = new DateTime(secondaryStartDate.Value.Year, secondaryStartDate.Value.Month, secondaryStartDate.Value.Day);

                while (cur <= endDate)
                {
                    BillTransaction trx = new BillTransaction()
                    {
                        Amount = amount,
                        OriginalAmount = amount,
                        CategoryId = categoryId,
                        OriginalCategoryId = categoryId,
                        VendorId = vendorId,
                        OriginalVendorId = vendorId,
                        Timestamp = cur,
                        OriginalTimestamp = cur
                    };
                    bill.BillTransactions.Add(trx);

                    count++;
                    if (frequency == 0)
                        cur = endDate.AddDays(1);
                    else if (frequency > 0)
                        cur = secondaryStartDate.Value.AddDays(count * frequency);
                    else
                        cur = secondaryStartDate.Value.AddMonths(count * -1 * frequency);
                }
            }

            _billRepository.Add(bill);
            _unitOfWork.Commit();

            return result;
        }
Exemplo n.º 17
0
        public ServiceResult<Bill> UpdateBill(int billId, string name, decimal amount, int billGroupId, int? categoryId, int? vendorId, DateTime startDate, DateTime endDate, int frequency, bool updateExisting, DateTime? secondaryStartDate, DateTime? secondaryEndDate)
        {
            ServiceResult<Bill> result = new ServiceResult<Bill>();

            var bill = _billRepository.GetById(billId);
            if (bill == null)
            {
                result.AddError(ErrorType.NotFound, "Bill {0} not found", billId);
                return result;
            }

            // TODO do we need to do exist checks for billGroupId, categoryId, vendorId?

            if (categoryId.HasValue && categoryId.Value == 0)
                categoryId = null;
            if (vendorId.HasValue && vendorId.Value == 0)
                vendorId = null;

            if (updateExisting)
            {
                if (bill.StartDate != startDate || bill.EndDate != endDate || bill.RecurrenceFrequency != frequency || bill.StartDate2 != secondaryStartDate || bill.EndDate2 != secondaryEndDate)
                {
                    List<BillTransaction> existing = _billTransactionRepository.GetMany(x => x.BillId == billId).ToList();
                    List<BillTransaction> expected = new List<BillTransaction>();

                    #region Generate expected transactions

                    int count = 0;
                    DateTime cur = new DateTime(startDate.Year, startDate.Month, startDate.Day);
                    while (cur <= endDate)
                    {
                        BillTransaction trx = new BillTransaction()
                        {
                            Amount = amount,
                            OriginalAmount = amount,
                            CategoryId = categoryId,
                            OriginalCategoryId = categoryId,
                            VendorId = vendorId,
                            OriginalVendorId = vendorId,
                            Timestamp = cur,
                            OriginalTimestamp = cur
                        };

                        expected.Add(trx);

                        count++;
                        if (frequency == 0)
                            cur = endDate.AddDays(1);
                        else if (frequency > 0)
                            cur = startDate.AddDays(count * frequency);
                        else
                            cur = startDate.AddMonths(count * -1 * frequency);
                    }

                    if (secondaryStartDate.HasValue)
                    {
                        if (secondaryEndDate.HasValue)
                            endDate = secondaryEndDate.Value;

                        count = 0;
                        cur = new DateTime(secondaryStartDate.Value.Year, secondaryStartDate.Value.Month, secondaryStartDate.Value.Day);

                        while (cur <= endDate)
                        {
                            BillTransaction trx = new BillTransaction()
                            {
                                Amount = amount,
                                OriginalAmount = amount,
                                CategoryId = categoryId,
                                OriginalCategoryId = categoryId,
                                VendorId = vendorId,
                                OriginalVendorId = vendorId,
                                Timestamp = cur,
                                OriginalTimestamp = cur
                            };

                            expected.Add(trx);

                            count++;
                            if (frequency == 0)
                                cur = endDate.AddDays(1);
                            else if (frequency > 0)
                                cur = secondaryStartDate.Value.AddDays(count * frequency);
                            else
                                cur = secondaryStartDate.Value.AddMonths(count * -1 * frequency);
                        }
                    }

                    #endregion

                    List<BillTransaction> reused = new List<BillTransaction>();

                    while (existing.Any() && expected.Any())
                    {
                        var existingProjections = existing.Select(e => new
                        {
                            Item = e,
                            Comparisons = expected.Select(x => new
                            {
                                Item = x,
                                Days = Math.Abs((x.Timestamp - e.Timestamp).TotalDays)
                            })
                        });

                        var bestExisting = existingProjections.OrderBy(x => x.Comparisons.Min(y => y.Days)).FirstOrDefault();
                        if (bestExisting != null)
                        {
                            // shift existing record's timestamp to closest match in expected
                            var bestMatch = bestExisting.Comparisons.OrderBy(x => x.Days).FirstOrDefault().Item;
                            bestExisting.Item.Timestamp = bestMatch.Timestamp;
                            bestExisting.Item.OriginalTimestamp = bestMatch.OriginalTimestamp;
                            expected.Remove(bestMatch);
                            existing.Remove(bestExisting.Item);
                            reused.Add(bestExisting.Item);
                        }
                    }

                    // delete unused transactions
                    var complete = reused.Union(expected).Select(x => x.Id);
                    _billTransactionRepository.Delete(x => x.BillId == billId && !complete.Contains(x.Id));

                    //reused.ForEach(x => bill.BillTransactions.Add(x));
                    expected.ForEach(x => bill.BillTransactions.Add(x));
                }

                if (bill.Amount != amount || bill.CategoryId != categoryId || bill.VendorId != vendorId)
                {
                    var billTransasctions = _billTransactionRepository.GetMany(x => x.BillId == billId);
                    if (billTransasctions != null)
                    {
                        foreach (var trx in billTransasctions)
                        {
                            if (bill.Amount != amount)
                            {
                                // only update a transaction amount if it hadn't been edited from it's original value (ie don't change modified amounts)
                                if (trx.Amount == trx.OriginalAmount)
                                    trx.Amount = amount;
                                trx.OriginalAmount = amount;
                            }

                            if (bill.CategoryId != categoryId)
                                trx.CategoryId = categoryId;

                            if (bill.VendorId != vendorId)
                                trx.VendorId = vendorId;
                        }
                    }
                }
            }

            bill.Name = name;
            bill.Amount = amount;
            bill.BillGroupId = billGroupId;
            bill.CategoryId = categoryId;
            bill.VendorId = vendorId;
            bill.StartDate = startDate;
            bill.EndDate = endDate;
            bill.StartDate2 = secondaryStartDate;
            bill.EndDate2 = secondaryEndDate;

            bill.RecurrenceFrequency = frequency;

            _unitOfWork.Commit();

            result.Result = bill;
            return result;
        }
Exemplo n.º 18
0
 public virtual void DeleteBillTransaction(BillTransaction entity)
 {
     Delete(entity);
 }
 public virtual void CreateBillTransaction(BillTransaction entity)
 {
     Create(entity);
 }
 public virtual void UpdateBillTransaction(BillTransaction entity)
 {
     Update(entity);
 }
Exemplo n.º 21
0
        public ActionResult InvoiceCheckOut(InvoiceCheckoutViewModel InvoiceCheckoutViewModel)
        {
            if (InvoiceCheckoutViewModel != null)
            {
                var data = db.InvoiceCheckouts.FirstOrDefault(x => x.OrderNumber == InvoiceCheckoutViewModel.OrderNumber);

                if (data != null)
                {
                    db.InvoiceCheckouts.Remove(data);
                    db.SaveChanges();
                }

                InvoiceCheckout invoiceCheckout = new InvoiceCheckout();
                invoiceCheckout.Id = Guid.NewGuid();

                invoiceCheckout.Doctor_Id    = InvoiceCheckoutViewModel.Doctor_Id;
                invoiceCheckout.Patient_Id   = InvoiceCheckoutViewModel.Patient_Id;
                invoiceCheckout.OrderNumber  = InvoiceCheckoutViewModel.OrderNumber;
                invoiceCheckout.TotalPayable = InvoiceCheckoutViewModel.TotalPayable;
                invoiceCheckout.Branch_Id    = InvoiceCheckoutViewModel.Branch_Id;

                invoiceCheckout.Bill_Generator = InvoiceCheckoutViewModel.Bill_Generator;

                invoiceCheckout.InvoiceDate = InvoiceCheckoutViewModel.InvoiceDate;

                invoiceCheckout.PaymentMode = InvoiceCheckoutViewModel.PaymentMode;

                invoiceCheckout.PaymentMethod = InvoiceCheckoutViewModel.PaymentMethod;

                invoiceCheckout.TotalBill = InvoiceCheckoutViewModel.TotalBill;
                invoiceCheckout.Discount  = InvoiceCheckoutViewModel.Discount;

                invoiceCheckout.SampleReceiveDate = InvoiceCheckoutViewModel.SampleReceiveDate;
                invoiceCheckout.SampleReceiveTime = InvoiceCheckoutViewModel.SampleReceiveTime;

                invoiceCheckout.IsCorporateCustomer = InvoiceCheckoutViewModel.IsCorporateCustomer;


                invoiceCheckout.ReferelLabId = InvoiceCheckoutViewModel.ReferelLabId;


                invoiceCheckout.Remarks = InvoiceCheckoutViewModel.Remarks;

                invoiceCheckout.ReportDeliveryDate = InvoiceCheckoutViewModel.ReportDeliveryDate;

                invoiceCheckout.ReportDeliveryTime = InvoiceCheckoutViewModel.ReportDeliveryTime;

                db.InvoiceCheckouts.Add(invoiceCheckout);
                db.SaveChanges();


                var ExistData = db.BillTransactions.FirstOrDefault(x => x.OrderNumber == InvoiceCheckoutViewModel.OrderNumber);

                if (ExistData != null)
                {
                    db.BillTransactions.Remove(ExistData);
                    db.SaveChanges();
                }


                BillTransaction billTransaction = new BillTransaction();
                billTransaction.Id          = Guid.NewGuid();
                billTransaction.OrderNumber = InvoiceCheckoutViewModel.OrderNumber;
                billTransaction.Patient_Id  = InvoiceCheckoutViewModel.Patient_Id;
                billTransaction.Doctor_Id   = InvoiceCheckoutViewModel.Doctor_Id;
                billTransaction.Branch_Id   = InvoiceCheckoutViewModel.Branch_Id;
                billTransaction.BillDate    = InvoiceCheckoutViewModel.InvoiceDate;
                billTransaction.Transtype   = "Bill";

                billTransaction.BillAmount = InvoiceCheckoutViewModel.TotalPayable;
                db.BillTransactions.Add(billTransaction);
                db.SaveChanges();


                var existingDataPaymentTrans = db.PaymentTransactions.Where(x => x.OrderNumber == InvoiceCheckoutViewModel.OrderNumber);
                if (existingDataPaymentTrans.Count() != 0)
                {
                    db.ExecuteNonQuery("Delete from PaymentTransactions where OrderNumber='" + InvoiceCheckoutViewModel.OrderNumber + "'");
                }
                if (InvoiceCheckoutViewModel.AmountReceived > 0)
                {
                    PaymentTransaction PaymentTransaction = new PaymentTransaction();
                    PaymentTransaction.Id          = Guid.NewGuid();
                    PaymentTransaction.OrderNumber = InvoiceCheckoutViewModel.OrderNumber;
                    PaymentTransaction.Patient_Id  = InvoiceCheckoutViewModel.Patient_Id;
                    PaymentTransaction.Doctor_Id   = InvoiceCheckoutViewModel.Doctor_Id;
                    PaymentTransaction.Branch_Id   = InvoiceCheckoutViewModel.Branch_Id;
                    PaymentTransaction.PaymentDate = InvoiceCheckoutViewModel.InvoiceDate;
                    PaymentTransaction.Transtype   = "Payment";
                    PaymentTransaction.TransAmount = InvoiceCheckoutViewModel.AmountReceived;
                    db.PaymentTransactions.Add(PaymentTransaction);
                    db.SaveChanges();
                }

                return(RedirectToAction("InvoiceCheckOut", new
                {
                    Doctor_Id = InvoiceCheckoutViewModel.Doctor_Id,
                    Patient_Id = InvoiceCheckoutViewModel.Patient_Id,
                    OrderNumber = InvoiceCheckoutViewModel.OrderNumber
                }));
            }
            ViewBag.ReferelLabId = new SelectList(db.ReferelLabs, "Id", "ReferelLabName");
            return(View(InvoiceCheckoutViewModel));
        }
 public virtual void CreateBillTransaction(BillTransaction entity)
 {
     entityDao.CreateBillTransaction(entity);
 }