Ejemplo n.º 1
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);
        }