Esempio n. 1
0
        public int Update(List <EntityCustomerTransaction> lst, tblCustomerTransaction obj)
        {
            try
            {
                tblCustomerTransaction objTest = (from tbl in objData.tblCustomerTransactions
                                                  where tbl.IsDelete == false &&
                                                  tbl.ReceiptNo == obj.ReceiptNo
                                                  select tbl).FirstOrDefault();

                List <EntityCustomerTransaction> lstTemp = new List <EntityCustomerTransaction>();

                List <tblTestInvoice> lstCurrent = (from tbl in objData.tblTestInvoices
                                                    where tbl.PatientId == obj.PatientId &&
                                                    tbl.IsDelete == false
                                                    select tbl).ToList();

                if (objTest != null)
                {
                    objTest.ReceiptDate = obj.ReceiptDate;
                    objTest.BillAmount  = obj.BillAmount;
                    objTest.PayAmount   = obj.PayAmount;
                    objTest.Discount    = obj.Discount;
                    objTest.PatientId   = obj.PatientId;
                }

                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 2
0
        public int InsertPurchaseInvoice(EntityDebitNote entPurchaseInvoice, List <EntityDebitNoteDetails> lstInvoice)
        {
            try
            {
                int?id = 0;
                objData.STP_Insert_DebitNote(Convert.ToDateTime(entPurchaseInvoice.DNDate), Convert.ToInt32(entPurchaseInvoice.SupplierId), false, Convert.ToDecimal(entPurchaseInvoice.Amount), Convert.ToDecimal(entPurchaseInvoice.NetAmount), Convert.ToInt32(entPurchaseInvoice.Tax1), Convert.ToInt32(entPurchaseInvoice.Tax2), Convert.ToInt32(entPurchaseInvoice.Discount), ref id);
                foreach (EntityDebitNoteDetails item in lstInvoice)
                {
                    tblDebitNoteDetail obj = new tblDebitNoteDetail()
                    {
                        DNNo        = id,
                        ProductCode = item.ProductCode,
                        Quantity    = item.Quantity,
                        Price       = item.Price,
                        Amount      = item.Amount,
                        BatchNo     = item.BatchNo,
                        ExpiryDate  = item.ExpiryDate,
                        IsDelete    = false
                    };
                    tblStockDetail objStock = new tblStockDetail()
                    {
                        OpeningQty      = 0,
                        InwardQty       = 0,
                        InwardPrice     = 0,
                        InwardAmount    = 0,
                        BatchNo         = item.BatchNo,
                        ExpiryDate      = item.ExpiryDate,
                        OutwardQty      = item.Quantity,
                        OutwardPrice    = item.Price,
                        DocumentNo      = id,
                        IsDelete        = false,
                        ProductId       = Convert.ToInt32(item.ProductCode),
                        TransactionType = "DebitNote",
                        OutwardAmount   = item.Amount
                    };
                    objData.tblStockDetails.InsertOnSubmit(objStock);
                    objData.tblDebitNoteDetails.InsertOnSubmit(obj);
                }
                int TId = new PatientInvoiceBLL().GetTransactionId();

                tblCustomerTransaction objCust = new tblCustomerTransaction()
                {
                    PayAmount        = entPurchaseInvoice.NetAmount,
                    IsCash           = false,
                    IsDelete         = false,
                    SupplierId       = entPurchaseInvoice.SupplierId,
                    ReceiptDate      = entPurchaseInvoice.DNDate,
                    TransactionDocNo = id,
                    TransactionId    = TId,
                    TransactionType  = "DebitNote"
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objCust);
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(1);
        }
        public async void Withdraw()
        {
            if (WithdrawAmt < 0.01)
            {
                Application.Current.MainPage.DisplayAlert("Message", "Insert Valid Amount.", "Ok");
            }
            else
            {
                var Transaction = new tblPanelUserTransaction()
                {
                    iTransactionTypeID   = 8,
                    iTransactionRecordID = 0,
                    iMadeBy             = GlobalConstant.iPanelUserID,
                    iLocationID         = GlobalConstant.LocationId,
                    iShiftID            = Convert.ToInt32(ShiftId),
                    iCustomerID         = CustomerGridListObservCollection[0].CustomerID,
                    iManagerID          = -9999,
                    sTransactionDetails = "Withdrawal made by customer.",
                    decAmount           = Convert.ToDecimal(WithdrawAmt),
                    decNewBalance       = 0,
                    dtTransactionDate   = DateTime.UtcNow,
                    sMachineName        = "",
                    sTransactionGUID    = Guid.NewGuid()
                };
                var CustomerTransaction = new tblCustomerTransaction()
                {
                    iTransactionTypeID   = 8,
                    iTransactionRecordID = 0,
                    iMadeBy             = GlobalConstant.iPanelUserID,
                    sSessionID          = "dghjskjdghd",
                    sIPAddress          = "192.158.12.45",
                    dtCreateDateTime    = DateTime.UtcNow,
                    iCustomerID         = CustomerGridListObservCollection[0].CustomerID,
                    iManagerID          = -9999,
                    sTransactionDetails = "Customer Account Deposit.",
                    decAmount           = Convert.ToDecimal(WithdrawAmt),
                    decNewBalance       = 0,
                    dtTransactionDate   = DateTime.UtcNow,

                    sTransactionGUID = Guid.NewGuid()
                };
                var SaveCustomerTransaction = await new Service.CustomerService().PostCustomerTransaction(CustomerTransaction, CustomerApi.InsertCustomerTransaction);
                if (SaveCustomerTransaction.Status == 1)
                {
                    var SaveLottoTicket = await new VoidTicketService().PosttblLottoTicket(Transaction, VoidTicketApi.InsertUserTransaction);
                    if (SaveLottoTicket.Status == 1)
                    {
                        Clear();
                        Application.Current.MainPage.DisplayAlert("Message", "Success.", "Ok");
                    }
                }
            }
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                lbl.Text = "Patient Ledger";
                lblFrom.Text = ddlPatient.SelectedItem.Text;
                lblTo.Text = string.Format("{0:dd-MMM-yyyy}", DateTime.Now);
                lblMessage.Text = string.Empty;

                List<tblCustomerTransaction> lst = new CustomerTransactionBLL().GetPatientTransByPatientId(Convert.ToInt32(ddlPatient.SelectedValue));
                EntityPatientMaster objPatient = new PatientMasterBLL().GetPatientDetailsByPatientId(Convert.ToInt32(ddlPatient.SelectedValue));
                if (objPatient != null)
                {
                    lblAge.Text = Convert.ToString(objPatient.Age);
                    MRN.Text = Convert.ToString(objPatient.PatientCode);
                    lblSex.Text = Convert.ToString(objPatient.GenderDesc);
                    lblBloodGroup.Text = Convert.ToString(objPatient.BloodGroup);
                }
                tblCustomerTransaction obj = new tblCustomerTransaction() { };
                lst.Add(obj);
                tblCustomerTransaction objBills = new tblCustomerTransaction()
                {
                    TransactionType = "Total Invoices Amt",
                    BillAmount = Convert.ToDecimal(lst.Sum(p => p.BillAmount))
                };
                lst.Add(objBills);
                tblCustomerTransaction objReceived = new tblCustomerTransaction()
                {
                    TransactionType = "Total Received",
                    PayAmount = Convert.ToDecimal(lst.Sum(p => p.PayAmount)) + Convert.ToDecimal(lst.Sum(p => p.AdvanceAmount))
                };
                lst.Add(objReceived);

                tblCustomerTransaction objFinal = new tblCustomerTransaction()
                {
                    TransactionType = "Balance(+)/Refund(-) Amt",

                    BillAmount = objBills.BillAmount - objReceived.PayAmount
                };
                lst.Add(objFinal);

                dgvTestParameter.DataSource = lst;
                dgvTestParameter.DataBind();
                Session["PatientLedg"] = ListConverter.ToDataTable(lst);
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Esempio n. 5
0
 protected void BtnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         tblCustomerTransaction entcust = new tblCustomerTransaction();
         entcust.PayAmount   = Convert.ToDecimal(txtPayAmount.Text);
         entcust.ReceiptNo   = Convert.ToInt32(Session["ReceiptNo"]);
         entcust.BillAmount  = 0;
         entcust.IsCash      = true;
         entcust.ReceiptDate = Convert.ToDateTime(txtTransactDate.Text);
         entcust.SupplierId  = Convert.ToInt32(ddlSupplier.SelectedValue);
         EntityCustomerTransaction transact = null;
         if (IsCheque.Checked)
         {
             entcust.IsCash       = false;
             entcust.ISCheque     = true;
             entcust.ReceiptDate  = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeDate   = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeNo     = Convert.ToString(txtChequeNo.Text);
             entcust.BankName     = Convert.ToString(txtBankName.Text);
             transact             = new EntityCustomerTransaction();
             transact.BankId      = Convert.ToInt32(ddlBank.SelectedValue);
             transact.ReceiptDate = Convert.ToDateTime(txtChequeDate.Text);
             transact.PayAmount   = Convert.ToDecimal(txtPayAmount.Text);
             transact.ISCheque    = true;
             transact.BillAmount  = 0;
             transact.ChequeDate  = Convert.ToDateTime(txtChequeDate.Text);
             transact.ChequeNo    = Convert.ToString(txtChequeNo.Text);
             transact.BankName    = Convert.ToString(txtBankName.Text);
         }
         else if (RdoCard.Checked)
         {
             entcust.IsCash       = false;
             entcust.ISCheque     = false;
             transact             = new EntityCustomerTransaction();
             transact.BankId      = Convert.ToInt32(ddlBank.SelectedValue);
             transact.ReceiptDate = Convert.ToDateTime(txtTransactDate.Text);
             transact.PayAmount   = Convert.ToDecimal(txtPayAmount.Text);
             transact.BillAmount  = 0;
         }
         int i = new CustomerTransactionBLL().UpdateSupplierTransaction(entcust, transact, IsCash.Checked);
         GetSupplierTransactionList();
         MultiView1.SetActiveView(View2);
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Esempio n. 6
0
        public async Task <ResultModel> PostCustomerTransaction(tblCustomerTransaction model, string Url)
        {
            ResultModel _User = new ResultModel();

            try
            {
                _User = await _helper.Post <tblCustomerTransaction>(model, Url);

                return(_User);
            }
            catch (Exception ex)
            {
                // Crashes.TrackError(ex);
                return(_User);
            }
        }
Esempio n. 7
0
        public int Save(EntityCustomerTransaction entCust, bool IsCash)
        {
            int TransactionId = new PatientInvoiceBLL().GetTransactionId();
            int ReceiptNo     = GetReceiptNo();

            if (IsCash)
            {
                tblCustomerTransaction objDebit = new tblCustomerTransaction()
                {
                    ReceiptDate      = entCust.ReceiptDate,
                    PatientId        = entCust.PatientId,
                    TransactionId    = TransactionId,
                    TransactionType  = "Refund",
                    TransactionDocNo = ReceiptNo,
                    IsCash           = true,
                    BillAmount       = entCust.BillAmount,
                    PayAmount        = 0,
                    IsDelete         = false,
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
            }
            else
            {
                tblCustomerTransaction objDebit = new tblCustomerTransaction()
                {
                    ReceiptDate      = entCust.ReceiptDate,
                    PatientId        = entCust.PatientId,
                    TransactionId    = TransactionId,
                    TransactionType  = "Refund",
                    TransactionDocNo = ReceiptNo,
                    ISCheque         = true,
                    BillAmount       = entCust.BillAmount,
                    PayAmount        = 0,
                    ChequeDate       = entCust.ReceiptDate,
                    ChequeNo         = entCust.ChequeNo,
                    BankName         = entCust.BankName,
                    IsDelete         = false,
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
            }
            objData.SubmitChanges();
            return(1);
        }
Esempio n. 8
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime Curr = Convert.ToDateTime(DateTime.Now);
                DateTime Next = Curr.AddYears(1);
                lbl.Text = "SUPPLIER LEDGER REPORT" + " " + string.Format("{0:yyyy}", Curr) + "-" + string.Format("{0:yyyy}", Next);

                lblFrom.Text    = ddlSupplier.SelectedItem.Text;
                lblTo.Text      = string.Format("{0:dd-MMM-yyyy}", DateTime.Now);
                lblMessage.Text = string.Empty;
                List <tblCustomerTransaction> lst = new CustomerTransactionBLL().GetSupplierTransBySupplierId(Convert.ToInt32(ddlSupplier.SelectedValue));
                tblCustomerTransaction        obj = new tblCustomerTransaction()
                {
                };
                lst.Add(obj);
                tblCustomerTransaction objReceived = new tblCustomerTransaction()
                {
                    TransactionType = "Total Received",
                    PayAmount       = Convert.ToDecimal(lst.Sum(p => p.PayAmount))
                };
                lst.Add(objReceived);
                tblCustomerTransaction objBills = new tblCustomerTransaction()
                {
                    TransactionType = "Total Bills",
                    BillAmount      = Convert.ToDecimal(lst.Sum(p => p.BillAmount))
                };
                lst.Add(objBills);
                tblCustomerTransaction objFinal = new tblCustomerTransaction()
                {
                    TransactionType = "Total Bills",
                    BillAmount      = objBills.BillAmount - objReceived.PayAmount
                };
                lst.Add(objFinal);
                dgvTestParameter.DataSource = lst;
                dgvTestParameter.DataBind();
                Session["SuppLedg"] = ListConverter.ToDataTable(lst);
            }
            catch (Exception ex)
            {
                lblMessage.Text = ex.Message;
            }
        }
Esempio n. 9
0
        public int UpdateInvoice(List <EntityICUInvoiceDetail> lstEdited, List <EntityICUInvoiceDetail> lstUpdate, EntityICUInvoice entInvoice)
        {
            try
            {
                tblICUBedAlloc objTest = (from tbl in objData.tblICUBedAllocs
                                          where tbl.IsDelete == false &&
                                          tbl.ICUBedAllocId == entInvoice.ICUBedAllocId
                                          select tbl).FirstOrDefault();

                List <EntityICUInvoiceDetail> lstTemp = new List <EntityICUInvoiceDetail>();

                List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                         where tbl.IsDelete == false &&
                                                         tbl.TransactionDocNo == entInvoice.ICUBedAllocId &&
                                                         tbl.TransactionType == "ICUInvoice"
                                                         select tbl).ToList();
                if (objTest != null && objCust != null)
                {
                    if (objCust.Count == 1)
                    {
                        if (entInvoice.IsCash.Value)
                        {
                            tblCustomerTransaction objC = new tblCustomerTransaction()
                            {
                                PayAmount        = lstEdited[0].NetAmount,
                                ReceiptDate      = entInvoice.AllocationDate,
                                IsCash           = entInvoice.IsCash,
                                IsDelete         = false,
                                TransactionDocNo = entInvoice.ICUBedAllocId,
                                TransactionId    = objCust[0].TransactionId,
                                TransactionType  = "Invoice",
                                PatientId        = entInvoice.PatientId,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objC);
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = lstEdited[0].NetAmount;
                                item.ReceiptDate = entInvoice.AllocationDate;
                                item.IsCash      = entInvoice.IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    item.PayAmount = lstEdited[0].NetAmount;
                                }
                            }
                        }
                        else
                        {
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = entInvoice.NetAmount;
                                item.ReceiptDate = entInvoice.AllocationDate;
                                item.IsCash      = entInvoice.IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    item.PayAmount = lstEdited[0].NetAmount;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (tblCustomerTransaction item in objCust)
                        {
                            item.BillAmount  = lstEdited[0].NetAmount;
                            item.ReceiptDate = entInvoice.AllocationDate;
                            item.IsCash      = entInvoice.IsCash;
                            if (item.IsCash == false)
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.IsDelete = true;
                                }
                            }
                            else
                            {
                                item.PayAmount = lstEdited[0].NetAmount;
                            }
                        }
                    }

                    objTest.AllocationDate = entInvoice.AllocationDate;
                    objTest.TotalAmount    = entInvoice.TotalAmount;
                    objTest.NetAmount      = lstEdited[0].NetAmount;
                    objTest.Tax1           = entInvoice.Tax1;
                    objTest.Discount       = entInvoice.Discount;
                    objTest.Tax2           = entInvoice.Tax2;
                }
                foreach (EntityICUInvoiceDetail item in lstEdited)
                {
                    int cnt = (from tbl in objData.tblICUInvoiceDetails
                               where tbl.ICUBedAllocId == entInvoice.ICUBedAllocId &&
                               tbl.ChargesId == item.ChargesId &&
                               tbl.IsDelete == false
                               select tbl).ToList().Count;
                    if (cnt == 0)
                    {
                        tblICUInvoiceDetail objNewAdded = new tblICUInvoiceDetail()
                        {
                            ICUBedAllocId = entInvoice.ICUBedAllocId,
                            ChargesId     = item.ChargesId,
                            Amount        = item.Amount,
                            IsDelete      = false
                        };
                        objData.tblICUInvoiceDetails.InsertOnSubmit(objNewAdded);
                        objData.SubmitChanges();
                    }
                    else
                    {
                        lstTemp.Add(item);
                    }
                }

                foreach (EntityICUInvoiceDetail item in lstUpdate)
                {
                    tblICUInvoiceDetail cnt = (from tbl in objData.tblICUInvoiceDetails
                                               where tbl.ICUBedAllocId == entInvoice.ICUBedAllocId &&
                                               tbl.ChargesId == item.ChargesId
                                               select tbl).FirstOrDefault();

                    if (cnt != null)
                    {
                        int checkExist = (from tbl in lstTemp
                                          where tbl.ChargesId == item.ChargesId
                                          select tbl).ToList().Count;
                        if (checkExist == 0)
                        {
                            cnt.IsDelete = true;
                        }
                    }
                }
                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 10
0
        public int Update(EntityPurchaseInvoice invoice, List<EntityPurchaseInvoiceDetails> lst)
        {
            int i = 0;
            try
            {
                tblPurchaseInvoice objExistInvoice = (from tbl in objData.tblPurchaseInvoices
                                                      where tbl.IsDelete == false
                                                      && tbl.PINo == invoice.PINo
                                                      select tbl).FirstOrDefault();
                if (objExistInvoice != null)
                {
                    bool flagISPOComplete = false;
                    if (invoice.PONo > 0)
                    {
                        if (objExistInvoice.PONo > 0)
                        {
                            List<tblPurchaseInvoiceDetail> lstExistedItems = (from tbl in objData.tblPurchaseInvoiceDetails
                                                                              where tbl.PINo == invoice.PINo
                                                                              && tbl.IsDelete == false
                                                                              select tbl).ToList();
                            if (lstExistedItems.Count > lst.Count)
                            {
                                foreach (tblPurchaseInvoiceDetail item in lstExistedItems)
                                {
                                    int cnt = (from tbl in lst
                                               where tbl.ProductCode == item.ProductCode
                                               && tbl.PurchaseInvoiceNo == item.PINo
                                               select tbl).Count();
                                    if (cnt == 0)
                                    {
                                        item.IsDelete = true;
                                    }

                                    tblPurchaseOrderDetail objOrder = (from tbl in objData.tblPurchaseOrderDetails
                                                                       join tblPurchaseInv in objData.tblPurchaseInvoices
                                                                       on tbl.PO_Id equals tblPurchaseInv.PONo
                                                                       where tblPurchaseInv.PINo == item.PINo
                                                                       && tbl.IsDelete == false
                                                                       && tbl.Product_Id == item.ProductCode
                                                                       select tbl).FirstOrDefault();
                                    if (objOrder != null)
                                    {
                                        objOrder.InvoiceQuantity = 0;
                                    }
                                }
                                objData.SubmitChanges();
                            }


                            #region Update Invoice Details
                            foreach (EntityPurchaseInvoiceDetails item in lst)
                            {

                                tblPurchaseInvoiceDetail invoiceItem = (from tbl in objData.tblPurchaseInvoiceDetails
                                                                        where tbl.PINo == invoice.PINo
                                                                        && tbl.IsDelete == false
                                                                        && tbl.ProductCode == item.ProductCode
                                                                        select tbl).FirstOrDefault();
                                if (invoiceItem != null)
                                {
                                    invoiceItem.Amount = item.Amount;
                                    invoiceItem.BatchNo = item.BatchNo;
                                    invoiceItem.ExpiryDate = item.ExpiryDate;
                                    invoiceItem.InvoicePrice = item.InvoicePrice;
                                    invoiceItem.InvoiceQty = item.InvoiceQty;
                                    invoiceItem.PINo = item.PurchaseInvoiceNo;
                                }
                                else
                                {
                                    invoiceItem = new tblPurchaseInvoiceDetail()
                                    {
                                        PINo = invoice.PINo,
                                        ProductCode = item.ProductCode,
                                        InvoiceQty = item.InvoiceQty,
                                        InvoicePrice = item.InvoicePrice,
                                        Amount = item.Amount,
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        IsDelete = false
                                    };
                                    objData.tblPurchaseInvoiceDetails.InsertOnSubmit(invoiceItem);
                                }
                                tblPurchaseOrderDetail orderItem = (from tbl in objData.tblPurchaseOrderDetails
                                                                    where tbl.IsDelete == false
                                                                    && tbl.PO_Id == invoice.PONo
                                                                    && tbl.Product_Id == item.ProductCode
                                                                    select tbl).FirstOrDefault();
                                if (orderItem != null)
                                {
                                    if (orderItem.Quantity == item.InvoiceQty)
                                    {
                                        flagISPOComplete = true;
                                    }
                                    else
                                    {
                                        flagISPOComplete = false;
                                    }
                                    orderItem.InvoiceQuantity = item.InvoiceQty;
                                }

                                tblStockDetail stockItem = (from tbl in objData.tblStockDetails
                                                            where tbl.IsDelete == false
                                                            && tbl.TransactionType.Equals("PInvoice")
                                                            && Convert.ToInt32(tbl.DocumentNo) == invoice.PINo
                                                            && tbl.ProductId == Convert.ToInt32(item.ProductCode)
                                                            select tbl).FirstOrDefault();
                                if (stockItem != null)
                                {
                                    stockItem.ProductId = Convert.ToInt32(item.ProductCode);
                                    stockItem.InwardQty = item.InvoiceQty;
                                    stockItem.InwardPrice = item.InvoicePrice;
                                    stockItem.BatchNo = item.BatchNo;
                                    stockItem.ExpiryDate = item.ExpiryDate;
                                    stockItem.InwardAmount = item.Amount;
                                }
                                else
                                {
                                    stockItem = new tblStockDetail()
                                    {
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        InwardPrice = item.InvoicePrice,
                                        InwardQty = item.InvoiceQty,
                                        DocumentNo = invoice.PINo,
                                        IsDelete = false,
                                        ProductId = Convert.ToInt32(item.ProductCode),
                                        TransactionType = "PInvoice",
                                        InwardAmount = item.Amount
                                    };
                                }
                            }
                            #endregion

                            #region Update Status of Order and Transaction
                            tblCustomerTransaction transact = (from tbl in objData.tblCustomerTransactions
                                                               where tbl.SupplierId == invoice.SupplierId
                                                               && tbl.IsDelete == false
                                                               && tbl.TransactionDocNo == invoice.PINo
                                                               && tbl.TransactionType.Equals("PInvoice")
                                                               select tbl).FirstOrDefault();
                            if (transact != null)
                            {
                                transact.BillAmount = invoice.Amount;
                            }
                            tblPurchaseOrder orderMain = (from tbl in objData.tblPurchaseOrders
                                                          where tbl.IsDelete == false
                                                          && tbl.PO_Id == invoice.PONo
                                                          select tbl).FirstOrDefault();
                            if (orderMain != null)
                            {
                                if (GetPOProductForEdit(Convert.ToInt32(invoice.PONo)).Count == lst.Count)
                                {
                                    flagISPOComplete = true;
                                }
                                else
                                {
                                    flagISPOComplete = false;
                                }
                                orderMain.IsPOComplete = flagISPOComplete;
                            }
                            objExistInvoice.Amount = invoice.Amount;
                            objExistInvoice.Discount = invoice.Discount;
                            objExistInvoice.PIDate = invoice.PIDate;
                            objExistInvoice.Tax1 = invoice.Tax1;
                            objExistInvoice.Tax2 = invoice.Tax2;

                            objData.SubmitChanges();
                            #endregion
                        }
                        else
                        {
                            ///Specifies that Current Invoice with PO
                            foreach (EntityPurchaseInvoiceDetails item in lst)
                            {

                            }
                        }
                    }
                    else if (objExistInvoice.PONo > 0)
                    {
                        List<tblPurchaseInvoiceDetail> lstExistedItems = (from tbl in objData.tblPurchaseInvoiceDetails
                                                                          where tbl.PINo == invoice.PINo
                                                                          && tbl.IsDelete == false
                                                                          select tbl).ToList();
                        if (lstExistedItems.Count > lst.Count)
                        {
                            foreach (tblPurchaseInvoiceDetail item in lstExistedItems)
                            {
                                int cnt = (from tbl in lst
                                           where tbl.ProductCode == item.ProductCode
                                           && tbl.PurchaseInvoiceNo == item.PINo
                                           select tbl).Count();
                                if (cnt == 0)
                                {
                                    item.IsDelete = true;
                                }
                                tblPurchaseOrderDetail objOrder = (from tbl in objData.tblPurchaseOrderDetails
                                                                   join tblPurchaseInv in objData.tblPurchaseInvoices
                                                                   on tbl.PO_Id equals tblPurchaseInv.PONo
                                                                   where tblPurchaseInv.PINo == item.PINo
                                                                   && tbl.IsDelete == false
                                                                   && tbl.Product_Id == item.ProductCode
                                                                   select tbl).FirstOrDefault();
                                if (objOrder != null)
                                {
                                    objOrder.InvoiceQuantity = 0;
                                }
                            }
                            objData.SubmitChanges();
                        }
                        if (invoice.PONo > 0)
                        {
                            #region Update Invoice Details
                            foreach (EntityPurchaseInvoiceDetails item in lst)
                            {

                                tblPurchaseInvoiceDetail invoiceItem = (from tbl in objData.tblPurchaseInvoiceDetails
                                                                        where tbl.PINo == invoice.PINo
                                                                        && tbl.IsDelete == false
                                                                        && tbl.ProductCode == item.ProductCode
                                                                        select tbl).FirstOrDefault();
                                if (invoiceItem != null)
                                {
                                    invoiceItem.Amount = item.Amount;
                                    invoiceItem.BatchNo = item.BatchNo;
                                    invoiceItem.ExpiryDate = item.ExpiryDate;
                                    invoiceItem.InvoicePrice = item.InvoicePrice;
                                    invoiceItem.InvoiceQty = item.InvoiceQty;
                                    invoiceItem.PINo = item.PurchaseInvoiceNo;
                                }
                                else
                                {
                                    invoiceItem = new tblPurchaseInvoiceDetail()
                                    {
                                        PINo = invoice.PINo,
                                        ProductCode = item.ProductCode,
                                        InvoiceQty = item.InvoiceQty,
                                        InvoicePrice = item.InvoicePrice,
                                        Amount = item.Amount,
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        IsDelete = false
                                    };
                                    objData.tblPurchaseInvoiceDetails.InsertOnSubmit(invoiceItem);
                                }
                                tblPurchaseOrderDetail orderItem = (from tbl in objData.tblPurchaseOrderDetails
                                                                    where tbl.IsDelete == false
                                                                    && tbl.PO_Id == invoice.PONo
                                                                    && tbl.Product_Id == item.ProductCode
                                                                    select tbl).FirstOrDefault();
                                if (orderItem != null)
                                {
                                    if (orderItem.Quantity == item.InvoiceQty)
                                    {
                                        flagISPOComplete = true;
                                    }
                                    else
                                    {
                                        flagISPOComplete = false;
                                    }
                                    orderItem.InvoiceQuantity = item.InvoiceQty;
                                }

                                tblStockDetail stockItem = (from tbl in objData.tblStockDetails
                                                            where tbl.IsDelete == false
                                                            && tbl.TransactionType.Equals("PInvoice")
                                                            && Convert.ToInt32(tbl.DocumentNo) == invoice.PINo
                                                            && tbl.ProductId == Convert.ToInt32(item.ProductCode)
                                                            select tbl).FirstOrDefault();
                                if (stockItem != null)
                                {
                                    stockItem.ProductId = Convert.ToInt32(item.ProductCode);
                                    stockItem.InwardQty = item.InvoiceQty;
                                    stockItem.InwardPrice = item.InvoicePrice;
                                    stockItem.BatchNo = item.BatchNo;
                                    stockItem.ExpiryDate = item.ExpiryDate;
                                    stockItem.InwardAmount = item.Amount;
                                }
                                else
                                {
                                    stockItem = new tblStockDetail()
                                    {
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        InwardPrice = item.InvoicePrice,
                                        InwardQty = item.InvoiceQty,
                                        DocumentNo = invoice.PINo,
                                        IsDelete = false,
                                        ProductId = Convert.ToInt32(item.ProductCode),
                                        TransactionType = "PInvoice",
                                        InwardAmount = item.Amount
                                    };
                                }
                            }
                            #endregion

                            #region Update Status of PO and Transaction Update
                            tblCustomerTransaction transact = (from tbl in objData.tblCustomerTransactions
                                                               where tbl.SupplierId == invoice.SupplierId
                                                               && tbl.IsDelete == false
                                                               && tbl.TransactionDocNo == invoice.PINo
                                                               && tbl.TransactionType.Equals("PInvoice")
                                                               select tbl).FirstOrDefault();
                            if (transact != null)
                            {
                                transact.BillAmount = invoice.Amount;
                            }

                            tblPurchaseOrder orderMain = (from tbl in objData.tblPurchaseOrders
                                                          where tbl.IsDelete == false
                                                          && tbl.PO_Id == invoice.PONo
                                                          select tbl).FirstOrDefault();
                            if (orderMain != null)
                            {
                                if (GetPOProduct(Convert.ToInt32(invoice.PONo)).Count == lst.Count)
                                {
                                    flagISPOComplete = true;
                                }
                                else
                                {
                                    flagISPOComplete = false;
                                }
                                orderMain.IsPOComplete = flagISPOComplete;
                            }

                            objExistInvoice.Amount = invoice.Amount;
                            objExistInvoice.Discount = invoice.Discount;
                            objExistInvoice.PIDate = invoice.PIDate;
                            objExistInvoice.Tax1 = invoice.Tax1;
                            objExistInvoice.Tax2 = invoice.Tax2;

                            objData.SubmitChanges();
                            #endregion
                        }
                        else
                        {
                            ///Specifies that Existing Invoice With PO and Current Not With PO

                            #region Update Invoice Details
                            foreach (EntityPurchaseInvoiceDetails item in lst)
                            {
                                tblPurchaseInvoiceDetail invoiceItem = (from tbl in objData.tblPurchaseInvoiceDetails
                                                                        where tbl.PINo == invoice.PINo
                                                                        && tbl.IsDelete == false
                                                                        && tbl.ProductCode == item.ProductCode
                                                                        select tbl).FirstOrDefault();
                                if (invoiceItem != null)
                                {
                                    invoiceItem.Amount = item.Amount;
                                    invoiceItem.BatchNo = item.BatchNo;
                                    invoiceItem.ExpiryDate = item.ExpiryDate;
                                    invoiceItem.InvoicePrice = item.InvoicePrice;
                                    invoiceItem.InvoiceQty = item.InvoiceQty;
                                    invoiceItem.PINo = item.PurchaseInvoiceNo;
                                }
                                else
                                {
                                    invoiceItem = new tblPurchaseInvoiceDetail()
                                    {
                                        PINo = invoice.PINo,
                                        ProductCode = item.ProductCode,
                                        InvoiceQty = item.InvoiceQty,
                                        InvoicePrice = item.InvoicePrice,
                                        Amount = item.Amount,
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        IsDelete = false
                                    };
                                    objData.tblPurchaseInvoiceDetails.InsertOnSubmit(invoiceItem);
                                }
                                tblPurchaseOrderDetail orderItem = (from tbl in objData.tblPurchaseOrderDetails
                                                                    where tbl.IsDelete == false
                                                                    && tbl.PO_Id == objExistInvoice.PONo
                                                                    && tbl.Product_Id == item.ProductCode
                                                                    select tbl).FirstOrDefault();
                                if (orderItem != null)
                                {
                                    orderItem.InvoiceQuantity = 0;
                                }

                                tblStockDetail stockItem = (from tbl in objData.tblStockDetails
                                                            where tbl.IsDelete == false
                                                            && tbl.TransactionType.Equals("PInvoice")
                                                            && Convert.ToInt32(tbl.DocumentNo) == invoice.PINo
                                                            && tbl.ProductId == Convert.ToInt32(item.ProductCode)
                                                            select tbl).FirstOrDefault();
                                if (stockItem != null)
                                {
                                    stockItem.ProductId = Convert.ToInt32(item.ProductCode);
                                    stockItem.InwardQty = item.InvoiceQty;
                                    stockItem.InwardPrice = item.InvoicePrice;
                                    stockItem.BatchNo = item.BatchNo;
                                    stockItem.ExpiryDate = item.ExpiryDate;
                                    stockItem.InwardAmount = item.Amount;
                                }
                                else
                                {
                                    stockItem = new tblStockDetail()
                                    {
                                        BatchNo = item.BatchNo,
                                        ExpiryDate = item.ExpiryDate,
                                        InwardPrice = item.InvoicePrice,
                                        InwardQty = item.InvoiceQty,
                                        DocumentNo = invoice.PINo,
                                        IsDelete = false,
                                        ProductId = Convert.ToInt32(item.ProductCode),
                                        TransactionType = "PInvoice",
                                        InwardAmount = item.Amount
                                    };
                                }
                            }
                            #endregion

                            #region Update Status of PO and Transaction Update
                            tblCustomerTransaction transact = (from tbl in objData.tblCustomerTransactions
                                                               where tbl.SupplierId == invoice.SupplierId
                                                               && tbl.IsDelete == false
                                                               && tbl.TransactionDocNo == invoice.PINo
                                                               && tbl.TransactionType.Equals("PInvoice")
                                                               select tbl).FirstOrDefault();
                            if (transact != null)
                            {
                                transact.BillAmount = invoice.Amount;
                            }

                            tblPurchaseOrder orderMain = (from tbl in objData.tblPurchaseOrders
                                                          where tbl.IsDelete == false
                                                          && tbl.PO_Id == objExistInvoice.PONo
                                                          select tbl).FirstOrDefault();
                            if (orderMain != null)
                            {
                                orderMain.IsPOComplete = false;
                            }

                            objExistInvoice.Amount = invoice.Amount;
                            objExistInvoice.Discount = invoice.Discount;
                            objExistInvoice.PIDate = invoice.PIDate;
                            objExistInvoice.Tax1 = invoice.Tax1;
                            objExistInvoice.Tax2 = invoice.Tax2;
                            objExistInvoice.PONo = invoice.PONo;
                            objData.SubmitChanges();
                            #endregion
                        }
                    }
                }
                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return i;
        }
Esempio n. 11
0
 public int InsertInvoice(EntityICUInvoice entInvoice, List <EntityICUInvoiceDetail> lstInvoice, bool IsCash)
 {
     try
     {
         int?ICUInvoiceNo = 0;
         objData.STP_InserttblICUInvoiceDischarge(Convert.ToDateTime(entInvoice.AllocationDate), Convert.ToInt32(entInvoice.PatientId)
                                                  , Convert.ToDecimal(entInvoice.NetAmount), Convert.ToDecimal(entInvoice.TotalAmount),
                                                  Convert.ToInt32(entInvoice.Discount), Convert.ToInt32(entInvoice.Tax1), Convert.ToInt32(entInvoice.Tax2), false, Convert.ToBoolean(entInvoice.Is_ShiftIPD),
                                                  Convert.ToDateTime(entInvoice.ShiftDate), ref ICUInvoiceNo);
         foreach (EntityICUInvoiceDetail item in lstInvoice)
         {
             tblICUInvoiceDischargeDetail obj = new tblICUInvoiceDischargeDetail()
             {
                 ICUBedAllocId = entInvoice.ICUBedAllocId,
                 IsDelete      = false,
                 ChargesId     = item.ChargesId,
                 Amount        = item.Amount,
                 NoofDays      = item.NoofDays,
                 Charge        = item.Charges,
                 Quantity      = item.Quantity,
                 ICUInvoiceNo  = ICUInvoiceNo,
             };
             objData.tblICUInvoiceDischargeDetails.InsertOnSubmit(obj);
         }
         int TransactionId = new PatientInvoiceBLL().GetTransactionId();
         if (IsCash)
         {
             tblCustomerTransaction objDebit = new tblCustomerTransaction()
             {
                 TransactionId    = TransactionId,
                 IsCash           = true,
                 TransactionDocNo = ICUInvoiceNo,
                 TransactionType  = "ICUInvoice",
                 BillAmount       = entInvoice.NetAmount,
                 PayAmount        = 0,
                 PatientId        = entInvoice.PatientId,
                 IsDelete         = false,
                 ReceiptDate      = entInvoice.AllocationDate,
             };
             objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
             //objData.SubmitChanges();
             tblCustomerTransaction objCrReceipt = new tblCustomerTransaction()
             {
                 TransactionId    = TransactionId,
                 IsCash           = true,
                 TransactionDocNo = ICUInvoiceNo,
                 TransactionType  = "ICUInvoice",
                 PayAmount        = entInvoice.NetAmount,
                 BillAmount       = 0,
                 PatientId        = entInvoice.PatientId,
                 IsDelete         = false,
                 ReceiptDate      = entInvoice.AllocationDate,
             };
             objData.tblCustomerTransactions.InsertOnSubmit(objCrReceipt);
             //objData.SubmitChanges();
         }
         else
         {
             tblCustomerTransaction objDebit = new tblCustomerTransaction()
             {
                 TransactionId    = TransactionId,
                 IsCash           = false,
                 TransactionDocNo = ICUInvoiceNo,
                 TransactionType  = "ICUInvoice",
                 BillAmount       = entInvoice.NetAmount,
                 PatientId        = entInvoice.PatientId,
                 IsDelete         = false,
                 ReceiptDate      = entInvoice.AllocationDate,
             };
             objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
             //objData.SubmitChanges();
         }
         objData.SubmitChanges();
         return(1);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 12
0
        public int UpdateInvoice(List <EntityICUInvoiceDetail> lstUpdate, EntityICUInvoice entInvoice)
        {
            int count = 0;

            try
            {
                tblICUInvoiceDischarge obj = (from tbl in objData.tblICUInvoiceDischarges
                                              where tbl.IsDelete == false &&
                                              tbl.ICUInvoiceNo == entInvoice.InvoiceNo
                                              select tbl).FirstOrDefault();
                if (obj != null)
                {
                    obj.Discount    = entInvoice.Discount;
                    obj.Vat         = Convert.ToInt32(entInvoice.Tax1);
                    obj.ServiceTax  = Convert.ToInt32(entInvoice.Tax2);
                    obj.TotalAmount = entInvoice.TotalAmount;
                    obj.NetAmount   = entInvoice.NetAmount;
                }
                foreach (EntityICUInvoiceDetail item in lstUpdate)
                {
                    if (item.ICUSRlNo == 0)
                    {
                        tblICUInvoiceDischargeDetail objDetails = new tblICUInvoiceDischargeDetail()
                        {
                            ICUBedAllocId = entInvoice.ICUBedAllocId,
                            IsDelete      = false,
                            ChargesId     = item.ChargesId,
                            Amount        = item.Amount,
                            NoofDays      = item.NoofDays,
                            Charge        = item.Charges,
                            Quantity      = item.Quantity,
                            ICUInvoiceNo  = entInvoice.InvoiceNo,
                        };
                        objData.tblICUInvoiceDischargeDetails.InsertOnSubmit(objDetails);
                    }
                    else
                    {
                        tblICUInvoiceDischargeDetail objDetails = (from tbl in objData.tblICUInvoiceDischargeDetails
                                                                   where tbl.IsDelete == false &&
                                                                   tbl.ICUSRlNo == item.ICUSRlNo
                                                                   select tbl).FirstOrDefault();
                        if (objDetails != null)
                        {
                            objDetails.Amount        = item.Amount;
                            objDetails.Charge        = item.Charges;
                            objDetails.ChargesId     = item.ChargesId;
                            objDetails.NoofDays      = item.NoofDays;
                            objDetails.Quantity      = item.Quantity;
                            objDetails.IsDelete      = item.IsDelete;
                            objDetails.ICUBedAllocId = item.ICUBedAllocId;
                        }
                    }
                }

                List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                         where tbl.IsDelete == false &&
                                                         tbl.TransactionDocNo == entInvoice.InvoiceNo &&
                                                         tbl.TransactionType == "ICUInvoice"
                                                         select tbl).ToList();
                if (obj != null && objCust != null)
                {
                    if (objCust.Count == 1)
                    {
                        if (entInvoice.IsCash.Value)
                        {
                            tblCustomerTransaction objC = new tblCustomerTransaction()
                            {
                                PayAmount        = entInvoice.NetAmount,
                                ReceiptDate      = entInvoice.AllocationDate,
                                IsCash           = entInvoice.IsCash,
                                IsDelete         = false,
                                TransactionDocNo = entInvoice.ICUBedAllocId,
                                TransactionId    = objCust[0].TransactionId,
                                TransactionType  = "ICUInvoice",
                                PatientId        = entInvoice.PatientId,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objC);
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = entInvoice.NetAmount;
                                item.ReceiptDate = entInvoice.AllocationDate;
                                item.IsCash      = entInvoice.IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    item.PayAmount = entInvoice.NetAmount;
                                }
                            }
                        }
                        else
                        {
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = entInvoice.NetAmount;
                                item.ReceiptDate = entInvoice.AllocationDate;
                                item.IsCash      = entInvoice.IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    item.PayAmount = entInvoice.NetAmount;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (tblCustomerTransaction item in objCust)
                        {
                            item.BillAmount  = entInvoice.NetAmount;
                            item.ReceiptDate = entInvoice.AllocationDate;
                            item.IsCash      = entInvoice.IsCash;
                            if (item.IsCash == false)
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.IsDelete = true;
                                }
                            }
                            else
                            {
                                item.PayAmount = entInvoice.NetAmount;
                            }
                        }
                    }
                }
                objData.SubmitChanges();
                count++;
            }
            catch (Exception ex)
            {
                count = 0;
                throw ex;
            }
            return(count);
        }
Esempio n. 13
0
        public int InsertPurchaseInvoice(EntityPurchaseInvoice entPurchaseInvoice, List<EntityPurchaseInvoiceDetails> lstInvoice)
        {
            try
            {
                int? id = 0;
                bool flagISPOComplete = false;
                objData.STP_Insert_PurchaseInvoice(Convert.ToDateTime(entPurchaseInvoice.PIDate), Convert.ToInt32(entPurchaseInvoice.PONo), Convert.ToInt32(entPurchaseInvoice.SupplierId), false, Convert.ToDecimal(entPurchaseInvoice.Amount), Convert.ToInt32(entPurchaseInvoice.Tax1), Convert.ToInt32(entPurchaseInvoice.Tax2), Convert.ToInt32(entPurchaseInvoice.Discount), ref id);
                foreach (EntityPurchaseInvoiceDetails item in lstInvoice)
                {
                    tblPurchaseInvoiceDetail obj = new tblPurchaseInvoiceDetail()
                    {
                        PINo = id,
                        ProductCode = item.ProductCode,
                        InvoiceQty = item.InvoiceQty,
                        InvoicePrice = item.InvoicePrice,
                        Amount = item.Amount,
                        BatchNo = item.BatchNo,
                        ExpiryDate = item.ExpiryDate,
                        IsDelete = false
                    };
                    tblPurchaseOrderDetail orderItem = (from tbl in objData.tblPurchaseOrderDetails
                                                        where tbl.IsDelete == false
                                                        && tbl.PO_Id == entPurchaseInvoice.PONo
                                                        && tbl.Product_Id == item.ProductCode
                                                        select tbl).FirstOrDefault();
                    if (orderItem != null)
                    {
                        if (orderItem.Quantity == item.InvoiceQty)
                        {
                            flagISPOComplete = true;
                        }
                        else
                        {
                            flagISPOComplete = false;
                        }
                        orderItem.InvoiceQuantity = item.InvoiceQty;
                    }
                    tblStockDetail objStock = new tblStockDetail()
                    {
                        BatchNo = item.BatchNo,
                        ExpiryDate = item.ExpiryDate,
                        InwardPrice = item.InvoicePrice,
                        InwardQty = item.InvoiceQty,
                        DocumentNo = id,
                        IsDelete = false,
                        ProductId = Convert.ToInt32(item.ProductCode),
                        TransactionType = "PInvoice",
                        InwardAmount = item.Amount
                    };
                    objData.tblStockDetails.InsertOnSubmit(objStock);
                    objData.tblPurchaseInvoiceDetails.InsertOnSubmit(obj);
                }
                int TId = new PatientInvoiceBLL().GetTransactionId();
                tblPurchaseOrder po = (from tbl in objData.tblPurchaseOrders
                                       where tbl.IsDelete == false
                                       && tbl.PO_Id == entPurchaseInvoice.PONo
                                       select tbl).FirstOrDefault();

                if (po != null)
                {
                    List<EntityProduct> lstProducts = GetPOProduct(Convert.ToInt32(entPurchaseInvoice.PONo));
                    if (lstProducts.Count == lstInvoice.Count)
                    {
                        flagISPOComplete = true;
                    }
                    else
                    {
                        flagISPOComplete = false;
                    }
                    po.IsPOComplete = flagISPOComplete;
                }
                tblCustomerTransaction objCust = new tblCustomerTransaction()
                {
                    BillAmount = entPurchaseInvoice.Amount,
                    IsCash = false,
                    IsDelete = false,
                    SupplierId = entPurchaseInvoice.SupplierId,
                    ReceiptDate = entPurchaseInvoice.PIDate,
                    TransactionDocNo = id,
                    TransactionId = TId,
                    TransactionType = "PInvoice"
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objCust);
                objData.SubmitChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return 1;
        }
Esempio n. 14
0
        public int UpdateInvoice(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lst)
        {
            int i = 0;

            try
            {
                tblPatientInvoice objTest = (from tbl in objData.tblPatientInvoices
                                             where tbl.IsDelete == false &&
                                             tbl.BillNo == entInvoice.BillNo
                                             select tbl).FirstOrDefault();
                if (objTest != null)
                {
                    objTest.Amount         = entInvoice.Amount;
                    objTest.BillType       = entInvoice.BillType;
                    objTest.NetAmount      = entInvoice.NetAmount;
                    objTest.TotalAdvance   = entInvoice.TotalAdvance;
                    objTest.BalanceAmount  = entInvoice.BalanceAmount;
                    objTest.ReceivedAmount = entInvoice.ReceivedAmount;
                    objTest.RefundAmount   = entInvoice.RefundAmount;
                    objTest.FixedDiscount  = entInvoice.FixedDiscount;
                    objTest.PreparedByName = entInvoice.PreparedByName;
                    //objTest.Service = entInvoice.Service;
                    //objTest.Vat = entInvoice.Vat;
                    if (entInvoice.BillType != "Estimated")
                    {
                        int TransactionId = GetTransactionId();
                        if (entInvoice.IsCash)
                        {
                            tblCustomerTransaction objDebit = new tblCustomerTransaction()
                            {
                                TransactionId    = TransactionId,
                                IsCash           = true,
                                TransactionDocNo = entInvoice.BillNo,
                                TransactionType  = "Invoice",
                                BillAmount       = entInvoice.NetAmount,
                                PayAmount        = entInvoice.NetAmount,
                                Discount         = entInvoice.FixedDiscount,
                                PatientId        = entInvoice.PatientId,
                                PreparedByName   = entInvoice.PreparedByName,
                                IsDelete         = false,
                                ReceiptDate      = entInvoice.BillDate,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        }
                        else
                        {
                            tblCustomerTransaction objDebit = new tblCustomerTransaction()
                            {
                                TransactionId    = TransactionId,
                                IsCash           = false,
                                TransactionDocNo = entInvoice.BillNo,
                                TransactionType  = "Invoice",
                                BillAmount       = entInvoice.NetAmount,
                                Discount         = entInvoice.FixedDiscount,
                                PatientId        = entInvoice.PatientId,
                                PreparedByName   = entInvoice.PreparedByName,
                                IsDelete         = false,
                                ReceiptDate      = entInvoice.BillDate,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                            //objData.SubmitChanges();
                        }
                    }
                    else
                    {
                        List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                                 where tbl.IsDelete == false &&
                                                                 tbl.TransactionDocNo == entInvoice.BillNo &&
                                                                 tbl.TransactionType == "Invoice"
                                                                 select tbl).ToList();
                        if (objCust != null)
                        {
                            if (objCust.Count == 1)
                            {
                                if (entInvoice.IsCash)
                                {
                                    tblCustomerTransaction objC = new tblCustomerTransaction()
                                    {
                                        PayAmount        = entInvoice.NetAmount,
                                        BillAmount       = entInvoice.NetAmount,
                                        Discount         = entInvoice.FixedDiscount,
                                        ReceiptDate      = entInvoice.BillDate,
                                        IsCash           = entInvoice.IsCash,
                                        IsDelete         = false,
                                        TransactionDocNo = entInvoice.BillNo,
                                        TransactionId    = objCust[0].TransactionId,
                                        TransactionType  = "Invoice",
                                        PatientId        = entInvoice.PatientId,
                                        PreparedByName   = entInvoice.PreparedByName,
                                    };
                                    objData.tblCustomerTransactions.InsertOnSubmit(objC);
                                    foreach (tblCustomerTransaction item in objCust)
                                    {
                                        item.BillAmount  = entInvoice.NetAmount;
                                        item.ReceiptDate = entInvoice.BillDate;
                                        item.IsCash      = entInvoice.IsCash;
                                        if (item.IsCash == false)
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.IsDelete = true;
                                            }
                                        }
                                        else
                                        {
                                            item.PayAmount = 0;
                                        }
                                    }
                                }
                                else
                                {
                                    foreach (tblCustomerTransaction item in objCust)
                                    {
                                        item.BillAmount  = entInvoice.NetAmount;
                                        item.ReceiptDate = entInvoice.BillDate;
                                        item.IsCash      = entInvoice.IsCash;
                                        if (item.IsCash == false)
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.IsDelete = true;
                                            }
                                        }
                                        else
                                        {
                                            if (item.PayAmount > 0)
                                            {
                                                item.PayAmount = entInvoice.NetAmount;
                                            }
                                            else
                                            {
                                                item.PayAmount = 0;
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                foreach (tblCustomerTransaction item in objCust)
                                {
                                    item.BillAmount  = entInvoice.NetAmount;
                                    item.ReceiptDate = entInvoice.BillDate;
                                    item.IsCash      = entInvoice.IsCash;
                                    if (item.IsCash == false)
                                    {
                                        if (item.PayAmount > 0)
                                        {
                                            item.IsDelete = true;
                                        }
                                    }
                                    else
                                    {
                                        if (item.PayAmount > 0)
                                        {
                                            item.PayAmount = entInvoice.NetAmount;
                                        }
                                        else
                                        {
                                            item.PayAmount = 0;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    foreach (EntityInvoiceDetails item in lst)
                    {
                        if (item.BillSRNo > 0)
                        {
                            tblPatientInvoiceDetail cnt = (from tbl in objData.tblPatientInvoiceDetails
                                                           where tbl.BillNo == item.BillNo &&
                                                           tbl.BillSRNo == item.BillSRNo &&
                                                           tbl.IsDelete == false
                                                           select tbl).FirstOrDefault();
                            if (cnt != null)
                            {
                                cnt.BillNo         = entInvoice.BillNo;
                                cnt.Quantity       = item.Quantity;
                                cnt.NoOfDays       = item.NoOfDays;
                                cnt.Remarks        = item.Remarks;
                                cnt.Amount         = item.Amount;
                                cnt.ChargePerDay   = item.PerDayCharge;
                                cnt.OtherChargesId = item.OtherChargesId;
                                cnt.IsDelete       = item.IsDelete;
                            }
                        }
                        else
                        {
                            tblPatientInvoiceDetail objNewAdded = new tblPatientInvoiceDetail()
                            {
                                BillNo         = entInvoice.BillNo,
                                BedAllocId     = item.BedAllocId,
                                OTAllocId      = item.OTBedAllocId,
                                DocAllocId     = item.DocAllocationId,
                                OtherChargesId = item.OtherChargesId,
                                Amount         = item.Amount,
                                ChargePerDay   = item.PerDayCharge,
                                NetAmount      = item.NetAmount,
                                Remarks        = item.Remarks,
                                NoOfDays       = item.NoOfDays,
                                Quantity       = item.Quantity,
                                IsDelete       = false
                            };
                            objData.tblPatientInvoiceDetails.InsertOnSubmit(objNewAdded);
                            if (entInvoice.BillType == "Original")
                            {
                                if (objNewAdded.BedAllocId > 0)
                                {
                                    int p = new BedStatusBLL().DischargePatient(entInvoice.PatientId, entInvoice.BillDate);
                                }
                            }
                        }
                    }

                    tblPatientAdmitDetail admit = (from tbl in objData.tblPatientAdmitDetails
                                                   where tbl.IsDelete == false &&
                                                   tbl.AdmitId == entInvoice.PatientId
                                                   select tbl).FirstOrDefault();
                    if (entInvoice.BillType == "Estimated")
                    {
                        if (admit != null)
                        {
                            admit.IsDischarge = false;
                        }
                    }

                    if (entInvoice.BillType == "Original")
                    {
                        if (admit != null)
                        {
                            admit.IsDischarge = true;
                        }
                    }

                    objData.SubmitChanges();
                }
                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return(i);
        }
Esempio n. 15
0
        public int UpdateOPDRefund(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lst)
        {
            int i = 0;

            try
            {
                tblPatientInvoice objTest = (from tbl in objData.tblPatientInvoices
                                             where tbl.IsDelete == false &&
                                             tbl.BillNo == entInvoice.BillNo
                                             select tbl).FirstOrDefault();
                if (objTest != null)
                {
                    objTest.Amount         = 0;
                    objTest.NetAmount      = 0;
                    objTest.ReceivedAmount = 0;
                    objTest.RefundAmount   = entInvoice.NetAmount;
                    objTest.TotalAdvance   = 0;

                    tblCustomerTransaction objCust = (from tbl in objData.tblCustomerTransactions
                                                      where tbl.IsDelete == false &&
                                                      tbl.TransactionDocNo == entInvoice.BillNo &&
                                                      tbl.TransactionType == "Invoice"
                                                      select tbl).FirstOrDefault();


                    if (objCust != null)
                    {
                        objCust.PayAmount  = 0;
                        objCust.BillAmount = 0;
                    }

                    foreach (EntityInvoiceDetails item in lst)
                    {
                        if (item.BillSRNo > 0)
                        {
                            tblPatientInvoiceDetail cnt = (from tbl in objData.tblPatientInvoiceDetails
                                                           where tbl.BillNo == item.BillNo &&
                                                           tbl.BillSRNo == item.BillSRNo &&
                                                           tbl.IsDelete == false
                                                           select tbl).FirstOrDefault();
                            if (cnt != null)
                            {
                                cnt.BillNo         = entInvoice.BillNo;
                                cnt.ChargePerDay   = 0;
                                cnt.NetAmount      = 0;
                                cnt.Amount         = 0;
                                cnt.OtherChargesId = item.OtherChargesId;
                                cnt.IsDelete       = item.IsDelete;
                            }
                            objData.SubmitChanges();
                        }
                    }
                    objData.SubmitChanges();
                }
                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return(i);
        }
Esempio n. 16
0
        public int InsertInvoice(EntityPatientInvoice entInvoice, List <EntityInvoiceDetails> lstInvoice, bool IsCash)
        {
            try
            {
                int?BillNo = 0;
                objData.STP_InsertInvoice(Convert.ToDateTime(entInvoice.BillDate),
                                          ref BillNo, Convert.ToString(entInvoice.BillType), Convert.ToInt32(entInvoice.PatientId), Convert.ToString(entInvoice.PreparedByName),
                                          Convert.ToDecimal(entInvoice.Amount), Convert.ToDecimal(entInvoice.Discount),
                                          //Convert.ToDecimal(entInvoice.Vat), Convert.ToDecimal(entInvoice.Service),
                                          Convert.ToDecimal(entInvoice.NetAmount), Convert.ToDecimal(entInvoice.TotalAdvance),
                                          Convert.ToDecimal(entInvoice.BalanceAmount), Convert.ToDecimal(entInvoice.ReceivedAmount),
                                          Convert.ToDecimal(entInvoice.RefundAmount),
                                          true, Convert.ToDecimal(entInvoice.FixedDiscount));
                foreach (EntityInvoiceDetails entInvoiceDetails in lstInvoice)
                {
                    tblPatientInvoiceDetail obj = new tblPatientInvoiceDetail()
                    {
                        BillNo         = BillNo,
                        BedAllocId     = entInvoiceDetails.BedAllocId,
                        OTAllocId      = entInvoiceDetails.OTBedAllocId,
                        DocAllocId     = entInvoiceDetails.DocAllocationId,
                        OtherChargesId = entInvoiceDetails.OtherChargesId,
                        Amount         = entInvoiceDetails.Amount,
                        NetAmount      = entInvoice.NetAmount,
                        ChargePerDay   = entInvoiceDetails.PerDayCharge,
                        Remarks        = entInvoiceDetails.Remarks,
                        NoOfDays       = entInvoiceDetails.NoOfDays,
                        Quantity       = entInvoiceDetails.Quantity,
                        IsDelete       = false
                    };
                    objData.tblPatientInvoiceDetails.InsertOnSubmit(obj);
                    if (entInvoice.BillType == "Original")
                    {
                        if (entInvoiceDetails.BedAllocId > 0)
                        {
                            int i = new BedStatusBLL().DischargePatient(entInvoice.PatientId, entInvoice.BillDate);
                        }
                    }
                }
                //int i = new BedStatusBLL().DischargePatient(entInvoiceDetails.PatientID, entInvoice.BillDate);
                if (entInvoice.BillType != "Estimated")
                {
                    int TransactionId = GetTransactionId();
                    if (IsCash)
                    {
                        tblCustomerTransaction objDebit = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = true,
                            TransactionDocNo = BillNo,
                            TransactionType  = "Invoice",
                            BillAmount       = entInvoice.NetAmount,
                            PayAmount        = entInvoice.NetAmount,
                            Discount         = entInvoice.FixedDiscount,
                            PatientId        = entInvoice.PatientId,
                            PreparedByName   = entInvoice.PreparedByName,
                            IsDelete         = false,
                            ReceiptDate      = entInvoice.BillDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        //objData.SubmitChanges();
                        //tblCustomerTransaction objCrReceipt = new tblCustomerTransaction()
                        //{
                        //    TransactionId = TransactionId,
                        //    IsCash = true,
                        //    TransactionDocNo = BillNo,
                        //    TransactionType = "Invoice",
                        //    PayAmount = entInvoice.NetAmount,
                        //    BillAmount=0,
                        //    PatientId = entInvoice.PatientId,
                        //    IsDelete = false,
                        //    ReceiptDate = entInvoice.BillDate,
                        //};
                        //objData.tblCustomerTransactions.InsertOnSubmit(objCrReceipt);
                        //objData.SubmitChanges();
                    }
                    else
                    {
                        tblCustomerTransaction objDebit = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            TransactionDocNo = BillNo,
                            TransactionType  = "Invoice",
                            BillAmount       = entInvoice.NetAmount,
                            Discount         = entInvoice.FixedDiscount,
                            PatientId        = entInvoice.PatientId,
                            PreparedByName   = entInvoice.PreparedByName,
                            IsDelete         = false,
                            ReceiptDate      = entInvoice.BillDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                        //objData.SubmitChanges();
                    }
                }

                tblPatientAdmitDetail admit = (from tbl in objData.tblPatientAdmitDetails
                                               where tbl.IsDelete == false &&
                                               tbl.IsDischarge == false &&
                                               tbl.AdmitId == entInvoice.PatientId
                                               select tbl).FirstOrDefault();
                if (entInvoice.BillType == "Estimated")
                {
                    if (admit != null)
                    {
                        admit.IsDischarge = false;
                    }
                }

                if (entInvoice.BillType == "Original")
                {
                    if (admit != null)
                    {
                        admit.IsDischarge = true;
                    }
                    //if (admit != null && entInvoice.PatientType == "OPD")
                    //{
                    //    admit.IsDischarge = false;

                    //}
                }
                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 17
0
        public int UpdateInvoice(List <EntityInvoiceDetails> lstEdited, List <EntityInvoiceDetails> lstUpdate)
        {
            try
            {
                tblPatientInvoice objTest = (from tbl in objData.tblPatientInvoices
                                             where tbl.IsDelete == false &&
                                             tbl.BillNo == lstEdited[0].BillNo
                                             select tbl).FirstOrDefault();

                List <EntityInvoiceDetails> lstTemp = new List <EntityInvoiceDetails>();

                List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                         where tbl.IsDelete == false &&
                                                         tbl.TransactionDocNo == lstEdited[0].BillNo &&
                                                         tbl.TransactionType == "Invoice"
                                                         select tbl).ToList();
                if (objTest != null && objCust != null)
                {
                    if (objCust.Count == 1)
                    {
                        if (lstEdited[0].IsCash)
                        {
                            tblCustomerTransaction objC = new tblCustomerTransaction()
                            {
                                PayAmount        = lstEdited[0].NetAmount,
                                ReceiptDate      = lstEdited[0].BillDate,
                                IsCash           = lstEdited[0].IsCash,
                                IsDelete         = false,
                                TransactionDocNo = lstEdited[0].BillNo,
                                TransactionId    = objCust[0].TransactionId,
                                TransactionType  = "Invoice",
                                PatientId        = lstEdited[0].PatientID,
                            };
                            objData.tblCustomerTransactions.InsertOnSubmit(objC);
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = lstEdited[0].NetAmount;
                                item.ReceiptDate = lstEdited[0].BillDate;
                                item.IsCash      = lstEdited[0].IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    item.PayAmount = 0;
                                }
                            }
                        }
                        else
                        {
                            foreach (tblCustomerTransaction item in objCust)
                            {
                                item.BillAmount  = lstEdited[0].NetAmount;
                                item.ReceiptDate = lstEdited[0].BillDate;
                                item.IsCash      = lstEdited[0].IsCash;
                                if (item.IsCash == false)
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.IsDelete = true;
                                    }
                                }
                                else
                                {
                                    if (item.PayAmount > 0)
                                    {
                                        item.PayAmount = lstEdited[0].NetAmount;
                                    }
                                    else
                                    {
                                        item.PayAmount = 0;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (tblCustomerTransaction item in objCust)
                        {
                            item.BillAmount  = lstEdited[0].NetAmount;
                            item.ReceiptDate = lstEdited[0].BillDate;
                            item.IsCash      = lstEdited[0].IsCash;
                            if (item.IsCash == false)
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.IsDelete = true;
                                }
                            }
                            else
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.PayAmount = lstEdited[0].NetAmount;
                                }
                                else
                                {
                                    item.PayAmount = 0;
                                }
                            }
                        }
                    }

                    objTest.BillDate  = lstEdited[0].BillDate;
                    objTest.Amount    = lstEdited[0].Total;
                    objTest.NetAmount = lstEdited[0].NetAmount;
                    //objTest.Vat = lstEdited[0].Vat;
                    objTest.Discount = lstEdited[0].Discount;
                    //objTest.Service = lstEdited[0].Service;
                }
                foreach (EntityInvoiceDetails item in lstEdited)
                {
                    int cnt = (from tbl in objData.tblPatientInvoiceDetails
                               where tbl.BillNo == item.BillNo &&
                               tbl.OtherChargesId == item.OtherChargesId &&
                               tbl.IsDelete == false
                               select tbl).ToList().Count;
                    if (cnt == 0)
                    {
                        tblPatientInvoiceDetail objNewAdded = new tblPatientInvoiceDetail()
                        {
                            BillNo         = lstEdited[0].BillNo,
                            BedAllocId     = item.BedAllocId,
                            OTAllocId      = item.OTBedAllocId,
                            DocAllocId     = item.DocAllocationId,
                            OtherChargesId = item.OtherChargesId,
                            Amount         = item.Amount,
                            NetAmount      = item.NetAmount,
                            IsDelete       = false
                        };
                        objData.tblPatientInvoiceDetails.InsertOnSubmit(objNewAdded);
                        objData.SubmitChanges();
                    }
                    else
                    {
                        lstTemp.Add(item);
                    }
                }

                foreach (EntityInvoiceDetails item in lstUpdate)
                {
                    tblPatientInvoiceDetail cnt = (from tbl in objData.tblPatientInvoiceDetails
                                                   where tbl.BillNo == item.BillNo &&
                                                   tbl.OtherChargesId == item.OtherChargesId
                                                   select tbl).FirstOrDefault();

                    if (cnt != null)
                    {
                        int checkExist = (from tbl in lstTemp
                                          where tbl.OtherChargesId == item.OtherChargesId
                                          select tbl).ToList().Count;
                        if (checkExist == 0)
                        {
                            cnt.IsDelete = true;
                        }
                    }
                }
                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 18
0
        public void InsertData(tblInsuranceClaim tblins, EntityCustomerTransaction objPatient, EntityCustomerTransaction objBank, bool IsCash, bool IsNeft, bool IsCheque)
        {
            try
            {
                tblInsuranceClaim objcurrent = (from tbl in objData.tblInsuranceClaims
                                                where tbl.ClaimId == tblins.ClaimId
                                                select tbl).FirstOrDefault();
                if (objcurrent != null)
                {
                    objcurrent.ApprovedAmount = tblins.ApprovedAmount;
                    objcurrent.ApprovedDate   = tblins.ApprovedDate;
                    objcurrent.IsApproved     = tblins.IsApproved;
                    objcurrent.TDS            = tblins.TDS;
                    //objcurrent.Discount = tblins.Discount;
                    int TransactionId = new PatientInvoiceBLL().GetTransactionId();
                    if (IsCash)
                    {
                        tblCustomerTransaction tblcust = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = true,
                            ISCheque         = false,
                            TransactionDocNo = objPatient.TransactionDocNo,
                            TransactionType  = "Claim",
                            BillAmount       = 0,
                            PayAmount        = objPatient.PayAmount,
                            PatientId        = objPatient.PatientId,
                            IsDelete         = false,
                            ReceiptDate      = objPatient.ReceiptDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(tblcust);
                    }
                    else if (IsNeft)
                    {
                        tblCustomerTransaction tblcust = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            ISCheque         = false,
                            TransactionDocNo = objPatient.TransactionDocNo,
                            TransactionType  = "Claim",
                            BillAmount       = 0,
                            PayAmount        = objPatient.PayAmount,
                            PatientId        = objPatient.PatientId,
                            IsDelete         = false,
                            ReceiptDate      = objPatient.ReceiptDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(tblcust);
                        tblCustomerTransaction tblcustBank = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            ISCheque         = false,
                            TransactionDocNo = objBank.TransactionDocNo,
                            TransactionType  = "Claim",
                            BillAmount       = objBank.BillAmount,
                            PayAmount        = 0,
                            PatientId        = 0,
                            IsDelete         = false,
                            ReceiptDate      = objBank.ReceiptDate,
                            BankId           = objBank.BankId
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(tblcustBank);
                    }
                    else if (IsCheque)
                    {
                        tblCustomerTransaction tblcust = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            ISCheque         = true,
                            TransactionDocNo = objPatient.TransactionDocNo,
                            TransactionType  = "Claim",
                            BillAmount       = 0,
                            PayAmount        = objPatient.PayAmount,
                            PatientId        = objPatient.PatientId,
                            IsDelete         = false,
                            ReceiptDate      = objPatient.ReceiptDate,
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(tblcust);
                        tblCustomerTransaction tblcustnew = new tblCustomerTransaction()
                        {
                            TransactionId    = TransactionId,
                            IsCash           = false,
                            ISCheque         = true,
                            TransactionDocNo = objBank.TransactionDocNo,
                            TransactionType  = "Claim",
                            BillAmount       = objBank.BillAmount,
                            PayAmount        = 0,
                            PatientId        = 0,
                            IsDelete         = false,
                            ReceiptDate      = objBank.ReceiptDate,
                            BankName         = objBank.BankName,
                            ChequeDate       = objBank.ChequeDate,
                            ChequeNo         = objBank.ChequeNo
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(tblcustnew);
                    }
                }

                objData.SubmitChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 19
0
        public int Update(EntityDebitNote lstEdited, List <EntityDebitNoteDetails> lst)
        {
            int i = 0;

            try
            {
                tblDebitNote objTest = (from tbl in objData.tblDebitNotes
                                        where tbl.IsDelete == false &&
                                        tbl.DNNo == lstEdited.DNNo
                                        select tbl).FirstOrDefault();

                if (objTest != null)
                {
                    objTest.Amount     = lstEdited.Amount;
                    objTest.NetAmount  = lstEdited.NetAmount;
                    objTest.SupplierId = lstEdited.SupplierId;
                    objTest.DNDate     = lstEdited.DNDate;
                    objTest.Discount   = lstEdited.Discount;
                    objTest.Tax1       = lstEdited.Tax1;
                    objTest.Tax2       = lstEdited.Tax2;
                }
                foreach (EntityDebitNoteDetails item in lst)
                {
                    if (item.DNSrNo == 0)
                    {
                        tblDebitNoteDetail objNewAdded = new tblDebitNoteDetail()
                        {
                            DNNo        = lstEdited.DNNo,
                            ProductCode = item.ProductCode,
                            Quantity    = item.Quantity,
                            Price       = item.Price,
                            Amount      = item.Amount,
                            BatchNo     = item.BatchNo,
                            ExpiryDate  = item.ExpiryDate,
                            IsDelete    = false
                        };
                        objData.tblDebitNoteDetails.InsertOnSubmit(objNewAdded);
                        tblStockDetail stock = new tblStockDetail()
                        {
                            ProductId       = Convert.ToInt32(item.ProductCode),
                            OpeningQty      = 0,
                            InwardQty       = 0,
                            InwardPrice     = 0,
                            InwardAmount    = 0,
                            BatchNo         = item.BatchNo,
                            ExpiryDate      = item.ExpiryDate,
                            OutwardQty      = item.Quantity,
                            OutwardPrice    = item.Price,
                            OutwardAmount   = item.Amount,
                            TransactionType = "DebitNote",
                            IsDelete        = false,
                        };
                        objData.tblStockDetails.InsertOnSubmit(stock);
                    }
                    else
                    {
                        tblDebitNoteDetail cnt = (from tbl in objData.tblDebitNoteDetails
                                                  where tbl.IsDelete == false &&
                                                  tbl.DNSrNo == item.DNSrNo
                                                  select tbl).FirstOrDefault();
                        if (cnt != null)
                        {
                            cnt.BatchNo     = item.BatchNo;
                            cnt.ExpiryDate  = item.ExpiryDate;
                            cnt.ProductCode = Convert.ToInt32(item.ProductCode);
                            cnt.Quantity    = item.Quantity;
                            cnt.Price       = item.Price;
                            cnt.Amount      = Convert.ToDecimal(item.Amount);
                            cnt.IsDelete    = item.IsDelete;
                        }
                        tblStockDetail stock = (from tbl in objData.tblStockDetails
                                                where tbl.IsDelete == false &&
                                                tbl.DocumentNo == lstEdited.DNNo &&
                                                tbl.ProductId == item.ProductCode &&
                                                tbl.TransactionType.Equals("DebitNote")
                                                select tbl).FirstOrDefault();
                        if (stock != null)
                        {
                            stock.ProductId     = Convert.ToInt32(item.ProductCode);
                            stock.OpeningQty    = 0;
                            stock.InwardQty     = 0;
                            stock.InwardPrice   = 0;
                            stock.InwardAmount  = 0;
                            stock.BatchNo       = item.BatchNo;
                            stock.ExpiryDate    = item.ExpiryDate;
                            stock.OutwardQty    = item.Quantity;
                            stock.OutwardPrice  = item.Price;
                            stock.OutwardAmount = item.Amount;
                            stock.IsDelete      = Convert.ToBoolean(item.IsDelete);
                        }
                    }
                }

                #region Update Status of Order and Transaction
                tblCustomerTransaction transact = (from tbl in objData.tblCustomerTransactions
                                                   where tbl.SupplierId == lstEdited.SupplierId &&
                                                   tbl.IsDelete == false &&
                                                   tbl.TransactionDocNo == lstEdited.DNNo &&
                                                   tbl.TransactionType.Equals("DebitNote")
                                                   select tbl).FirstOrDefault();
                if (transact != null)
                {
                    transact.PayAmount   = lstEdited.NetAmount;
                    transact.ReceiptDate = lstEdited.DNDate;
                }



                objData.SubmitChanges();
                #endregion

                i++;
            }
            catch (Exception ex)
            {
                i = 0;
                throw ex;
            }
            return(i);
        }
Esempio n. 20
0
        public int Update(List <TestAllocation> lst, tblTestInvoice obj, bool IsCash)
        {
            try
            {
                tblTestInvoice objTest = (from tbl in objData.tblTestInvoices
                                          where tbl.IsDelete == false &&
                                          tbl.TestInvoiceNo == obj.TestInvoiceNo
                                          select tbl).FirstOrDefault();

                List <TestAllocation> lstTemp = new List <TestAllocation>();

                List <tblTestInvoiceDetail> lstCurrent = (from tbl in objData.tblTestInvoiceDetails
                                                          where tbl.TestInvoiceId == obj.TestInvoiceNo &&
                                                          tbl.IsDelete == false
                                                          select tbl).ToList();

                List <tblCustomerTransaction> objCust = (from tbl in objData.tblCustomerTransactions
                                                         where tbl.IsDelete == false &&
                                                         tbl.TransactionDocNo.Equals(Convert.ToString(obj.TestInvoiceNo)) &&
                                                         tbl.TransactionType.Equals("TestInvoice")
                                                         select tbl).ToList();
                if (objTest != null)
                {
                    objTest.TestInvoiceDate = obj.TestInvoiceDate;
                    objTest.Amount          = obj.Amount;
                    objTest.Discount        = obj.Discount;
                    objTest.PatientId       = obj.PatientId;
                }
                if (objCust.Count == 1)
                {
                    if (IsCash)
                    {
                        tblCustomerTransaction objC = new tblCustomerTransaction()
                        {
                            PayAmount        = obj.Amount,
                            ReceiptDate      = obj.TestInvoiceDate,
                            IsCash           = IsCash,
                            IsDelete         = false,
                            TransactionDocNo = obj.TestInvoiceNo,
                            TransactionId    = objCust[0].TransactionId,
                            TransactionType  = "TestInvoice",
                            PatientId        = obj.PatientId,
                            BillAmount       = 0
                        };
                        objData.tblCustomerTransactions.InsertOnSubmit(objC);
                        foreach (tblCustomerTransaction item in objCust)
                        {
                            item.BillAmount  = obj.Amount;
                            item.ReceiptDate = obj.TestInvoiceDate;
                            item.IsCash      = IsCash;
                            if (item.IsCash == false)
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.IsDelete = true;
                                }
                            }
                            else
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.PayAmount = obj.Amount;
                                }
                                else
                                {
                                    item.PayAmount = 0;
                                }
                            }
                        }
                    }
                    else
                    {
                        foreach (tblCustomerTransaction item in objCust)
                        {
                            item.BillAmount  = obj.Amount;
                            item.ReceiptDate = obj.TestInvoiceDate;
                            item.IsCash      = IsCash;
                            if (item.IsCash == false)
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.IsDelete = true;
                                }
                            }
                            else
                            {
                                if (item.PayAmount > 0)
                                {
                                    item.PayAmount = obj.Amount;
                                }
                                else
                                {
                                    item.PayAmount = 0;
                                }
                            }
                        }
                    }
                }
                else
                {
                    foreach (tblCustomerTransaction item in objCust)
                    {
                        item.BillAmount  = obj.Amount;
                        item.ReceiptDate = obj.TestInvoiceDate;
                        item.IsCash      = IsCash;
                        if (item.IsCash == false)
                        {
                            if (item.PayAmount > 0)
                            {
                                item.IsDelete = true;
                            }
                        }
                        else
                        {
                            if (item.PayAmount > 0)
                            {
                                item.PayAmount = obj.Amount;
                            }
                            else
                            {
                                item.PayAmount = 0;
                            }
                        }
                    }
                }

                foreach (TestAllocation item in lst)
                {
                    int cnt = (from tbl in objData.tblTestInvoiceDetails
                               where tbl.TestInvoiceId == obj.TestInvoiceNo &&
                               tbl.TestId == item.TestId &&
                               tbl.IsDelete == false
                               select tbl).ToList().Count;
                    if (cnt == 0)
                    {
                        tblTestInvoiceDetail objNewAdded = new tblTestInvoiceDetail()
                        {
                            TestInvoiceId = obj.TestInvoiceNo,
                            TestId        = item.TestId,
                            Charges       = item.Charges,
                            IsDelete      = false,
                        };
                        objData.tblTestInvoiceDetails.InsertOnSubmit(objNewAdded);
                        objData.SubmitChanges();
                    }
                    else
                    {
                        lstTemp.Add(item);
                    }
                }


                foreach (tblTestInvoiceDetail item in lstCurrent)
                {
                    int cnt = (from tbl in lst
                               where tbl.TestInvoiceNo == item.TestInvoiceId &&
                               tbl.TestId == item.TestId
                               select tbl).ToList().Count;

                    if (cnt == 0)
                    {
                        int checkExist = (from tbl in lstTemp
                                          where tbl.TestId == item.TestId
                                          select tbl).ToList().Count;
                        if (checkExist == 0)
                        {
                            item.IsDelete = true;
                        }
                    }
                }
                objData.SubmitChanges();
                return(1);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 21
0
 protected void BtnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         tblCustomerTransaction entcust = new tblCustomerTransaction();
         entcust.PayAmount      = Convert.ToDecimal(txtPayAmount.Text);
         entcust.AdvanceAmount  = Convert.ToDecimal(txtAdvanceAmount.Text);
         entcust.ReceiptNo      = Convert.ToInt32(Session["ReceiptNo"]);
         entcust.BillAmount     = 0;
         entcust.IsCash         = true;
         entcust.ReceiptDate    = Convert.ToDateTime(txtTransactDate.Text);
         entcust.PatientId      = Convert.ToInt32(ddlPatient.SelectedValue);
         entcust.PreparedByName = Convert.ToString(Session["AdminName"]);
         EntityCustomerTransaction transact = null;
         if (IsCheque.Checked && ddlPatientCategory.SelectedItem.Text == "Self")
         {
             entcust.IsCash          = false;
             entcust.ISCheque        = true;
             entcust.IsCard          = false;
             entcust.IsRTGS          = false;
             entcust.ReceiptDate     = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeDate      = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeNo        = Convert.ToString(txtChequeNo.Text);
             entcust.BankName        = Convert.ToString(txtBankName.Text);
             entcust.PatientCategory = Convert.ToString(ddlPatientCategory.SelectedItem.Text);
             transact               = new EntityCustomerTransaction();
             transact.InsuranceId   = 0;
             transact.CompanyId     = 0;
             transact.CompanyName   = "";
             transact.InsuranceName = "";
             transact.ReceiptDate   = Convert.ToDateTime(txtChequeDate.Text);
             transact.BillAmount    = Convert.ToDecimal(txtPayAmount.Text);
             transact.AdvanceAmount = Convert.ToDecimal(txtAdvanceAmount.Text);
             transact.ISCheque      = true;
             transact.PayAmount     = 0;
             transact.ChequeDate    = Convert.ToDateTime(txtChequeDate.Text);
             transact.ChequeNo      = Convert.ToString(txtChequeNo.Text);
             transact.BankName      = Convert.ToString(txtBankName.Text);
         }
         else if (IsCheque.Checked && ddlPatientCategory.SelectedItem.Text == "Company")
         {
             entcust.IsCash          = false;
             entcust.ISCheque        = true;
             entcust.IsCard          = false;
             entcust.IsRTGS          = false;
             entcust.ReceiptDate     = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeDate      = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeNo        = Convert.ToString(txtChequeNo.Text);
             entcust.BankName        = Convert.ToString(txtBankName.Text);
             entcust.PatientCategory = Convert.ToString(ddlPatientCategory.SelectedItem.Text);
             transact               = new EntityCustomerTransaction();
             transact.InsuranceId   = 0;
             transact.CompanyId     = Convert.ToInt32(ddlCompany.SelectedValue);
             transact.CompanyName   = Convert.ToString(ddlCompany.SelectedItem.Text);
             transact.InsuranceName = "";
             transact.ReceiptDate   = Convert.ToDateTime(txtChequeDate.Text);
             transact.BillAmount    = Convert.ToDecimal(txtPayAmount.Text);
             transact.AdvanceAmount = Convert.ToDecimal(txtAdvanceAmount.Text);
             transact.ISCheque      = true;
             transact.PayAmount     = 0;
             transact.ChequeDate    = Convert.ToDateTime(txtChequeDate.Text);
             transact.ChequeNo      = Convert.ToString(txtChequeNo.Text);
             transact.BankName      = Convert.ToString(txtBankName.Text);
         }
         else if (IsCheque.Checked && ddlPatientCategory.SelectedItem.Text == "Insurance")
         {
             entcust.IsCash          = false;
             entcust.ISCheque        = false;
             entcust.IsCard          = false;
             entcust.IsRTGS          = false;
             entcust.ReceiptDate     = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeDate      = Convert.ToDateTime(txtChequeDate.Text);
             entcust.ChequeNo        = Convert.ToString(txtChequeNo.Text);
             entcust.BankName        = Convert.ToString(txtBankName.Text);
             entcust.PatientCategory = Convert.ToString(ddlPatientCategory.SelectedItem.Text);
             transact               = new EntityCustomerTransaction();
             transact.InsuranceId   = Convert.ToInt32(ddlCompany.SelectedValue);
             transact.CompanyId     = 0;
             transact.InsuranceName = Convert.ToString(ddlCompany.SelectedItem.Text);
             transact.CompanyName   = "";
             transact.ReceiptDate   = Convert.ToDateTime(txtChequeDate.Text);
             transact.BillAmount    = Convert.ToDecimal(txtPayAmount.Text);
             transact.AdvanceAmount = Convert.ToDecimal(txtAdvanceAmount.Text);
             transact.ISCheque      = true;
             transact.PayAmount     = 0;
             transact.ChequeDate    = Convert.ToDateTime(txtChequeDate.Text);
             transact.ChequeNo      = Convert.ToString(txtChequeNo.Text);
             transact.BankName      = Convert.ToString(txtBankName.Text);
         }
         int i = new CustomerTransactionBLL().Update(entcust, transact, IsCash.Checked);
         GetCustTransactionList();
         MultiView1.SetActiveView(View2);
     }
     catch (Exception ex)
     {
         lblMsg.Text = ex.Message;
     }
 }
Esempio n. 22
0
        public int Save(List <TestAllocation> lst, tblTestInvoice obj, bool IsCash)
        {
            int?Id = 0;

            objData.STP_Insert_tblTestInvoice(Convert.ToDateTime(DateTime.Now.Date), ref Id, Convert.ToInt32(obj.PatientId), Convert.ToDecimal(obj.Amount), Convert.ToDecimal(obj.Discount));
            foreach (TestAllocation item in lst)
            {
                tblTestInvoiceDetail objtestDetails = new tblTestInvoiceDetail()
                {
                    TestInvoiceId = Convert.ToInt32(Id),
                    TestId        = item.TestId,
                    IsDelete      = false,
                    Charges       = Convert.ToDecimal(item.Charges)
                };
                objData.tblTestInvoiceDetails.InsertOnSubmit(objtestDetails);
            }
            int TransactionId = new PatientInvoiceBLL().GetTransactionId();

            if (IsCash)
            {
                tblCustomerTransaction objDebit = new tblCustomerTransaction()
                {
                    TransactionId    = TransactionId,
                    IsCash           = true,
                    TransactionDocNo = Id,
                    TransactionType  = "TestInvoice",
                    BillAmount       = obj.Amount,
                    PayAmount        = 0,
                    PatientId        = obj.PatientId,
                    IsDelete         = false,
                    ReceiptDate      = obj.TestInvoiceDate,
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                //objData.SubmitChanges();
                tblCustomerTransaction objCrReceipt = new tblCustomerTransaction()
                {
                    TransactionId    = TransactionId,
                    IsCash           = true,
                    TransactionDocNo = Id,
                    TransactionType  = "TestInvoice",
                    PayAmount        = obj.Amount,
                    BillAmount       = 0,
                    PatientId        = obj.PatientId,
                    IsDelete         = false,
                    ReceiptDate      = obj.TestInvoiceDate,
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objCrReceipt);
                //objData.SubmitChanges();
            }
            else
            {
                tblCustomerTransaction objDebit = new tblCustomerTransaction()
                {
                    TransactionId    = TransactionId,
                    IsCash           = false,
                    TransactionDocNo = Id,
                    TransactionType  = "TestInvoice",
                    BillAmount       = obj.Amount,
                    PatientId        = obj.PatientId,
                    IsDelete         = false,
                    ReceiptDate      = obj.TestInvoiceDate,
                };
                objData.tblCustomerTransactions.InsertOnSubmit(objDebit);
                //objData.SubmitChanges();
            }
            objData.SubmitChanges();
            return(1);
        }