Beispiel #1
0
        /// <summary>
        /// This method is used to save category contents with associated category
        /// </summary>
        /// <param name="content"></param>
        public void SaveCategoryContent(ContentModel content)
        {
            using (SASEntitiesEDM objCategoryEntities = new SASEntitiesEDM())
            {
                var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault();
                if (obj != null)
                {
                    obj.Set_Default = false;
                    objCategoryEntities.SaveChanges();
                }

                try
                {
                    CategoriesContent catContent = new CategoriesContent();
                    catContent.Cat_Contents  = content.ContentName.Trim();
                    catContent.Content_Limit = content.Limit;
                    catContent.Cat_Id        = content.CategoryID;
                    catContent.IsDeleted     = false;
                    catContent.Set_Default   = content.IsSelected;
                    catContent.CreatedDate   = DateTime.Now;
                    objCategoryEntities.CategoriesContents.Add(catContent);
                    objCategoryEntities.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        public int AddEditCashBank(CashBankDetailEntity cashbankentity)
        {
            try
            {
                var cashbank       = entites.Accounts.Where(x => x.ID == cashbankentity.AccountID).FirstOrDefault();
                var checkduplicate = entites.Accounts.Where(x => x.Acc_Name.ToLower() == cashbankentity.AccountName.ToLower() && x.IsDeleted != true).FirstOrDefault();
                //if (checkduplicate != null)
                //{
                //    return 2;
                //}
                //else
                //{
                if (cashbank != null)
                {
                    cashbank.Acc_Name     = cashbankentity.AccountName;
                    cashbank.Acc_Open_Bal = cashbankentity.AccountOpeningBal == null ? null as decimal? : Convert.ToDecimal(cashbankentity.AccountOpeningBal);
                    cashbank.Acc_Inactive = cashbankentity.IsInActivestring;
                    entites.SaveChanges();
                    return(1);
                }
                else
                {
                    if (checkduplicate != null)
                    {
                        return(2);
                    }
                    Account AccDetail = new Account()
                    {
                        Acc_Name     = cashbankentity.AccountName,
                        Acc_Open_Bal = cashbankentity.AccountOpeningBal == null ? null as decimal? : Convert.ToDecimal(cashbankentity.AccountOpeningBal),
                        Acc_Inactive = cashbankentity.IsInActivestring
                    };
                    if (cashbankentity.AccountName.ToLower().Trim() == "cash")
                    {
                        //var accType = entites.AccountTypes.Where(x => x.Acc_Type_Code == "CAB").FirstOrDefault();
                        //if (accType != null)
                        //    AccDetail.Acc_Type = accType.ID;
                        return(2);
                    }
                    else
                    {
                        var accType = entites.AccountTypes.Where(x => x.Acc_Type_Code == "ACB").FirstOrDefault();
                        if (accType != null)
                        {
                            AccDetail.Acc_Type = accType.ID;
                        }
                    }
                    entites.Accounts.Add(AccDetail);
                    entites.SaveChanges();
                    return(1);
                }
                //}
            }
            catch (Exception ex)
            {
                return(3);

                throw ex;
            }
        }
        public void UpdateRefreshData(int psID)
        {
            try
            {
                using (SASEntitiesEDM objEntities = new SASEntitiesEDM())
                {
                    ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == psID).SingleOrDefault();
                    if (pands != null)
                    {
                        pands.IsRefresh   = true;
                        pands.RefreshDate = DateTime.Now.Date;
                        objEntities.SaveChanges();
                    }

                    List <ProductsAndService> pandsOther = objEntities.ProductsAndServices.Where(e => e.ID != psID).ToList();
                    if (pandsOther != null)
                    {
                        foreach (var item in pandsOther)
                        {
                            item.IsRefresh   = false;
                            item.RefreshDate = null;
                            objEntities.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool RefreshCustomer(int custId)
        {
            bool result = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var obj = entities.Customers.Where(x => x.IsRefreshed == true).FirstOrDefault();
                    if (obj != null)
                    {
                        obj.IsRefreshed = false;
                        entities.SaveChanges();
                    }
                    var obj2 = entities.Customers.Where(x => x.ID == custId).FirstOrDefault();
                    if (obj2 != null)
                    {
                        obj2.IsRefreshed   = true;
                        obj2.RefreshedDate = System.DateTime.UtcNow;
                        entities.SaveChanges();
                    }
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
 public bool SaveSearchJson(string jsonSearch, int ScreenId, string ScreenName)
 {
     try
     {
         var result = entities.LastSelectionHistories.Where(x => x.Screen_Id == ScreenId).FirstOrDefault();
         if (result != null)
         {
             result.Last_Selection = jsonSearch;
             result.Last_Updated   = DateTime.Now;
             entities.SaveChanges();
             return(true);
         }
         else
         {
             LastSelectionHistory lastSelection = new LastSelectionHistory()
             {
                 Screen_Id      = ScreenId,
                 Screen_Name    = ScreenName,
                 Last_Selection = jsonSearch,
                 Last_Updated   = DateTime.Now
             };
             entities.LastSelectionHistories.Add(lastSelection);
             entities.SaveChanges();
             return(true);
         }
     }
     catch
     {
         return(false);
     }
 }
        public int UpdateRefundFromSupplier(RefundFromSupplierForm psForm)
        {
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    foreach (var item in psForm.RefundFromSupplierDetails)
                    {
                        CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == psForm.RefundFromSupplier.CashChequeNo &&
                                                                                            e.SO_CN_PO_DN_No == item.PurchaseNo).SingleOrDefault();
                        if (obj != null)
                        {
                            obj.Acc_Id           = psForm.RefundFromSupplier.AccountId;
                            obj.Amount           = psForm.RefundFromSupplier.Amount;
                            obj.Cash_Cheque_No   = psForm.RefundFromSupplier.CashChequeNo;
                            obj.Cash_Cheque_Date = Convert.ToDateTime(psForm.RefundFromSupplier.DateStr);
                            obj.Remarks          = psForm.RefundFromSupplier.Remarks;

                            obj.Is_Cheque = psForm.RefundFromSupplier.IsCheque;

                            //saving details entity
                            obj.SO_CN_PO_DN_No   = item.PurchaseNo;
                            obj.SO_CN_PO_DN_Date = item.PurchaseDate;
                            obj.SO_CN_PO_DN_Amt  = item.PurchaseAmount;
                            obj.Amt_Due          = obj.Amt_Due = item.AmountDue - item.AmountAdjusted;
                            obj.Amt_Refunded     = item.AmountAdjusted;
                            obj.Discount         = item.Discount;

                            obj.UpdatedBy   = 0;
                            obj.UpdatedDate = DateTime.Now;
                            entities.SaveChanges();

                            if (item.AmountAdjusted == item.PurchaseAmount)
                            {
                                DebitNote     dn    = entities.DebitNotes.Where(e => e.DN_No == item.PurchaseNo).SingleOrDefault();
                                PurchaseOrder order = entities.PurchaseOrders.Where(e => e.PO_No == item.PurchaseNo).SingleOrDefault();
                                if (dn != null)
                                {
                                    dn.DN_Status = Convert.ToByte(DN_Status.Refunded);
                                    entities.SaveChanges();
                                }
                                else if (order != null)
                                {
                                    order.PO_Status = Convert.ToByte(PO_Status.Refunded);
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(psForm.RefundFromSupplier.ID);
        }
        public int SaveCountAndAdjustStock(CountAndAdjustStockForm casForm)
        {
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    foreach (var item in casForm.CountAndAdjustStockDetails)
                    {
                        StockCount obj = new StockCount();
                        obj.Stock_count_no = casForm.CountAndAdjustStock.StockCountNo;
                        obj.StockDate      = casForm.CountAndAdjustStock.StockDate;
                        obj.StockType      = casForm.CountAndAdjustStock.StockType;

                        //saving details entity
                        obj.PSID       = item.PSID;
                        obj.PandS_Code = item.PandSCode;
                        obj.PandS_Name = item.PandSName;
                        //obj.SysQty = Math.Abs(Convert.ToInt32(item.SystemQty));
                        obj.SysQty          = item.SystemQty;
                        obj.CountQty        = item.CountQty;
                        obj.Difference      = item.Difference;
                        obj.Average_Cost    = Convert.ToDecimal(item.AvgCost);
                        obj.Amount          = item.Amount;
                        obj.Adjusted_Amount = Convert.ToDecimal(item.AdjustedAmount);
                        obj.UpdatedBy       = 0;
                        obj.UpdatedDate     = DateTime.Now;

                        entities.StockCounts.Add(obj);
                        entities.SaveChanges();

                        ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == item.PSID);
                        if (ps != null)
                        {
                            if (casForm.CountAndAdjustStock.StockType == Convert.ToByte(Stock_Type.StockTake))
                            {
                                ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock + item.Difference;
                                ps.PandS_Stock_Value  = ps.PandS_Stock_Value - Convert.ToDecimal(item.AdjustedAmount);
                                entities.SaveChanges();
                            }
                            else
                            {
                                ps.PandS_Qty_in_stock = ps.PandS_Qty_in_stock + item.Difference;
                                entities.SaveChanges();
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(0);

                throw ex;
            }
            return(1);
        }
Beispiel #8
0
        public bool DeleteQuotatoin(int pqID)
        {
            bool result = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var detailList = entities.SalesOrderDetails.Where(x => x.SO_ID == pqID).ToList();
                    if (detailList != null)
                    {
                        foreach (SalesOrderDetail pqdetail in detailList)
                        {
                            int PSId = Convert.ToInt32(pqdetail.SO_No);
                            if (PSId != 0)
                            {
                                ProductsAndService ps = entities.ProductsAndServices.SingleOrDefault(e => e.ID == PSId);
                                if (ps != null)
                                {
                                    ps.PandS_Qty_for_SO = ps.PandS_Qty_for_SO - pqdetail.SO_Qty;
                                    entities.SaveChanges();
                                }
                            }

                            pqdetail.SO_Qty      = 0;
                            pqdetail.SO_Price    = 0;
                            pqdetail.SO_Discount = 0;
                            pqdetail.SO_Amount   = 0;
                            pqdetail.GST_Rate    = 0;
                            entities.SaveChanges();
                        }
                    }
                    var obj = entities.SalesOrders.Where(x => x.ID == pqID).FirstOrDefault();
                    //entities.SalesOrders.Remove(obj);
                    if (obj != null)
                    {
                        obj.SO_Status      = Convert.ToByte(PO_Status.Cancelled);
                        obj.SO_Tot_bef_Tax = 0;
                        obj.SO_Tot_aft_Tax = 0;
                        obj.SO_GST_Amt     = 0;
                        obj.IsDeleted      = true;
                        obj.ModifiedDate   = DateTime.Now;
                        entities.SaveChanges();
                    }
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Beispiel #9
0
 public bool SavePromisedDate(List <TodoUnpaidDetailEntity> TodoInvList, string DateFormat)
 {
     try
     {
         ToDoList todoinv;
         foreach (var item in TodoInvList)
         {
             if (item.PromisedDateStr != null)
             {
                 todoinv = entities.ToDoLists.Where(e => e.InvoiceNo == item.InvoiceNo).SingleOrDefault();
                 if (todoinv != null)
                 {
                     todoinv.AmountDue      = item.AmountDue;
                     todoinv.CreditDays     = item.CreditDueDays;
                     todoinv.InvoiceDate    = item.InvoiceDate;
                     todoinv.InvoiceNo      = item.InvoiceNo;
                     todoinv.Name           = item.Name;
                     todoinv.OverdueDays    = item.OverDueDays;
                     todoinv.PaymentDueDate = item.PaymentDueDate;
                     //todoinv.PromisedDate =Convert.ToDateTime(item.PromisedDateStr);
                     todoinv.PromisedDate = Convert.ToDateTime(DateTime.ParseExact(item.PromisedDateStr, DateFormat, CultureInfo.InvariantCulture)
                                                               .ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
                     todoinv.Type = item.Type;
                     //entities.ToDoLists.Add(todoinv);
                     entities.SaveChanges();
                 }
                 else
                 {
                     todoinv                = new ToDoList();
                     todoinv.AmountDue      = item.AmountDue;
                     todoinv.CreditDays     = item.CreditDueDays;
                     todoinv.InvoiceDate    = item.InvoiceDate;
                     todoinv.InvoiceNo      = item.InvoiceNo;
                     todoinv.Name           = item.Name;
                     todoinv.OverdueDays    = item.OverDueDays;
                     todoinv.PaymentDueDate = item.PaymentDueDate;
                     //todoinv.PromisedDate =Convert.ToDateTime(item.PromisedDateStr);
                     todoinv.PromisedDate = Convert.ToDateTime(DateTime.ParseExact(item.PromisedDateStr, DateFormat, CultureInfo.InvariantCulture)
                                                               .ToString("MM/dd/yyyy", CultureInfo.InvariantCulture));
                     todoinv.Type = item.Type;
                     entities.ToDoLists.Add(todoinv);
                     entities.SaveChanges();
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw ex;
     }
     // return true;
 }
Beispiel #10
0
        /// <summary>
        /// This method is used to update category contents with associated category
        /// </summary>
        /// <param name="content"></param>
        public void UpdateCategoryContent(ContentModel content)
        {
            using (SASEntitiesEDM objCategoryEntities = new SASEntitiesEDM())
            {
                try
                {
                    var obj = objCategoryEntities.CategoriesContents.Where(x => x.Cat_Id == content.CategoryID && x.IsDeleted != true && x.Set_Default == true && content.IsSelected == true).FirstOrDefault();
                    if (obj != null)
                    {
                        obj.Set_Default = false;
                        objCategoryEntities.SaveChanges();
                    }

                    CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == content.ContentID);
                    if (catContent != null)
                    {
                        catContent.Cat_Contents  = content.ContentName;
                        catContent.Content_Limit = content.Limit;
                        catContent.Set_Default   = content.IsSelected;
                        catContent.ModifiedDate  = DateTime.Now;
                        objCategoryEntities.SaveChanges();
                    }

                    //var categoryContent = objCategoryEntities.CategoriesContents.Where(e => e.Cat_Id == content.CategoryID && e.ID!=content.ContentID).ToList();
                    //if (categoryContent != null)
                    //{
                    //    foreach (var c in categoryContent)
                    //    {
                    //        if (content.IsSelected == true)
                    //        {
                    //            if (c.Set_Default == true)
                    //            {
                    //                c.Set_Default = false;
                    //            }
                    //        }
                    //        else
                    //        {
                    //            if(c.Set_Default==true)
                    //            {
                    //                c.Set_Default = true;
                    //            }
                    //        }
                    //        objCategoryEntities.SaveChanges();
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 private void CreateCreditNote(SalesInvoiceForm invoiceData)
 {
     try
     {
         using (SASEntitiesEDM entities = new SASEntitiesEDM())
         {
             CreditNote deb = entities.CreditNotes.Where(e => e.SI_Id == invoiceData.Invoice.ID).SingleOrDefault();
             if (Convert.ToDecimal(invoiceData.Invoice.TotalBeforeTax) < 0)
             {
                 if (deb != null)
                 {
                     deb.CN_Date = DateTime.Now.Date;
                     // deb.CN_No = "CN-" + (GetLastCreditNoteNo() + 1);
                     //deb.SI_Id = obj.ID;
                     deb.Cus_Id = invoiceData.Invoice.CustomerID;
                     // deb.Cus_DN_Amount = Convert.ToDecimal(invoiceData.Invoice.TotalBeforeTax);
                     deb.ModifiedDate = DateTime.Now;
                     entities.SaveChanges();
                 }
                 else
                 {
                     deb           = new CreditNote();
                     deb.CN_Date   = DateTime.Now.Date;
                     deb.CN_No     = "CN-" + (GetLastCreditNoteNo() + 1);
                     deb.SI_Id     = invoiceData.Invoice.ID;
                     deb.Cus_Id    = invoiceData.Invoice.CustomerID;
                     deb.CN_Status = Convert.ToByte(DN_Status.UnAdjusted);
                     deb.CN_Amount = Convert.ToDecimal(invoiceData.Invoice.TotalAfterTax);//change 3/13/2018
                     //deb.CN_Amount= Math.Abs(Convert.ToDecimal(invoiceData.Invoice.TotalAfterTax));
                     deb.CreatedDate = DateTime.Now;
                     entities.CreditNotes.Add(deb);
                     entities.SaveChanges();
                 }
             }
             else
             {
                 if (deb != null)
                 {
                     entities.CreditNotes.Remove(deb);
                     entities.SaveChanges();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public void UpdateDebitNote(DebitNoteForm debitNote)
 {
     try
     {
         using (SASEntitiesEDM entities = new SASEntitiesEDM())
         {
             DebitNote obj = entities.DebitNotes.Where(e => e.DN_No == debitNote.DebitNote.DebitNo
                                                       ).SingleOrDefault();
             if (obj != null)
             {
                 if (!string.IsNullOrEmpty(debitNote.DebitNote.SupplierCreditNoteAmount))
                 {
                     debitNote.DebitNote.SCNAmount = Convert.ToDecimal(debitNote.DebitNote.SupplierCreditNoteAmount);
                 }
                 obj.DN_Reason     = debitNote.DebitNote.TermsAndConditions;
                 obj.Sup_CN_No     = debitNote.DebitNote.SupplierCreditNoteNo;
                 obj.Sup_CN_Date   = debitNote.DebitNote.SupplierCreditNoteDate;
                 obj.Sup_CN_Amount = debitNote.DebitNote.SCNAmount;
                 obj.ModifiedDate  = DateTime.Now;
                 entities.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int SaveReceiveMoney(ReceiveMoneyEntity receiveMoney)
        {
            int autoId = 0;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    ReceiveMoney cbt = new ReceiveMoney();
                    cbt.LinkedAccountID   = receiveMoney.SelectedLinkedAcntID;
                    cbt.CashBankAccountID = receiveMoney.SelectedCashBankAcntID;
                    cbt.IsCheque          = receiveMoney.IsCheque;
                    cbt.CashChequeNo      = receiveMoney.CashChequeNo;
                    cbt.CashChequeDate    = receiveMoney.CashChequeDate;
                    cbt.Remarks           = receiveMoney.Remarks;
                    cbt.TaxID             = receiveMoney.SelectedTaxID;
                    cbt.TotalBeforeTax    = receiveMoney.TotalBeforeTax;
                    cbt.TotalTax          = receiveMoney.TotalTax;
                    cbt.TotalAfterTax     = receiveMoney.TotalAfterTax;
                    cbt.Remarks           = receiveMoney.Remarks;
                    cbt.CreatedBy         = 1;
                    cbt.CreatedDate       = DateTime.Now;
                    entities.ReceiveMoneys.Add(cbt);
                    entities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(autoId);
        }
        public bool DeleteQuotatoin(int pqID)
        {
            bool result = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    //var detailList = entities.PurchaseQuotationDetails.Where(x => x.PQ_ID == pqID).ToList();
                    //if (detailList != null)
                    //{
                    //    //foreach (PurchaseQuotationDetail pqdetail in detailList)
                    //    //{
                    //    //    entities.PurchaseQuotationDetails.Remove(pqdetail);
                    //    //}

                    //}
                    var obj = entities.PurchaseQuotations.Where(x => x.ID == pqID).FirstOrDefault();
                    //entities.PurchaseQuotations.Remove(obj);
                    if (obj != null)
                    {
                        obj.IsDeleted    = true;
                        obj.ModifiedDate = DateTime.Now;
                        entities.SaveChanges();
                    }
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
        public bool DeleteQuotatoin(int pqID)
        {
            bool result = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var obj = entities.SalesQuotations.Where(x => x.ID == pqID).FirstOrDefault();
                    //entities.SalesQuotations.Remove(obj);
                    if (obj != null)
                    {
                        obj.IsDeleted    = true;
                        obj.ModifiedDate = DateTime.Now;
                        entities.SaveChanges();
                    }
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
 public void UpdateCreditNote(CreditNoteForm CreditNote)
 {
     try
     {
         using (SASEntitiesEDM entities = new SASEntitiesEDM())
         {
             CreditNote obj = entities.CreditNotes.Where(e => e.CN_No == CreditNote.CreditNote.CreditNo
                                                         ).SingleOrDefault();
             if (obj != null)
             {
                 if (!string.IsNullOrEmpty(CreditNote.CreditNote.CustomerDebitNoteAmount))
                 {
                     CreditNote.CreditNote.CDNAmount = Convert.ToDecimal(CreditNote.CreditNote.CustomerDebitNoteAmount);
                 }
                 obj.CN_Reason = CreditNote.CreditNote.TermsAndConditions;
                 obj.Cus_DN_No = CreditNote.CreditNote.CustomerDebitNoteNo;
                 //obj.Cus_DN_Date = CreditNote.CreditNote.CustomerDebitNoteDate;
                 obj.Cus_DN_Date   = CreditNote.CreditNote.CustomerDebitNoteDate;
                 obj.Cus_DN_Amount = CreditNote.CreditNote.CDNAmount;
                 obj.ModifiedDate  = DateTime.Now;
                 entities.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void CreateDebitNote(PurchaseInvoiceForm invoiceData)
 {
     try
     {
         using (SASEntitiesEDM entities = new SASEntitiesEDM())
         {
             DebitNote deb = entities.DebitNotes.Where(e => e.PI_Id == invoiceData.Invoice.ID).SingleOrDefault();
             if (Convert.ToDecimal(invoiceData.Invoice.TotalBeforeTax) < 0)
             {
                 if (deb != null)
                 {
                     deb.DN_Date = DateTime.Now;
                     // deb.DN_No = "DN-" + (GetLastDebitNoteNo() + 1);
                     //deb.PI_Id = obj.ID;
                     deb.Sup_Id        = invoiceData.Invoice.SupplierID;
                     deb.Sup_CN_Amount = Convert.ToDecimal(invoiceData.Invoice.TotalBeforeTax);
                     //deb.ModifiedDate = DateTime.Now;
                     entities.SaveChanges();
                 }
                 else
                 {
                     deb               = new DebitNote();
                     deb.DN_Date       = DateTime.Now;
                     deb.DN_No         = "DN-" + (GetLastDebitNoteNo() + 1);
                     deb.PI_Id         = invoiceData.Invoice.ID;
                     deb.Sup_Id        = invoiceData.Invoice.SupplierID;
                     deb.Sup_CN_Amount = Convert.ToDecimal(invoiceData.Invoice.TotalBeforeTax);
                     deb.CreatedDate   = DateTime.Now;
                     entities.DebitNotes.Add(deb);
                     entities.SaveChanges();
                 }
             }
             else
             {
                 if (deb != null)
                 {
                     entities.DebitNotes.Remove(deb);
                     entities.SaveChanges();
                 }
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int SaveStockData(StockModel JForm)
        {
            //int autoId = 0;
            // UnpaidSalesInvoice obj = new UnpaidSalesInvoice();
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    Stock obj1;
                    if (JForm.StockDetailsData != null)
                    {
                        foreach (StockEntity JEntity in JForm.StockDetailsData)
                        {
                            //save entity value
                            obj1                   = new Stock();
                            obj1.Product_ID        = JEntity.ID;
                            obj1.Quantity_In_Stock = JEntity.QtyInStock;
                            obj1.Average_Cost      = JEntity.AverageCost;
                            obj1.Amount            = JEntity.Amount;
                            obj1.CreatedDate       = DateTime.Now;

                            if (entities.Stocks.AsNoTracking().FirstOrDefault(x => x.ID == JEntity.ID) == null)
                            {
                                entities.Stocks.Add(obj1);
                                entities.SaveChanges();
                            }
                            else
                            {
                                entities.Entry(obj1).State = EntityState.Modified;
                                entities.SaveChanges();
                            }
                        }
                    }

                    else
                    {
                    }
                }
                return(1);
            }
            catch (Exception e)
            {
                return(0);

                throw e;
            }
        }
        /// <summary>
        /// This method is used to save new tax
        /// </summary>
        /// <param name="taxModel"></param>
        public void SaveTax(TaxModel taxModel)
        {
            try
            {
                using (SASEntitiesEDM objEntities = new SASEntitiesEDM())
                {
                    TaxCodesAndRate tax = new TaxCodesAndRate();

                    tax.Tax_Name        = taxModel.TaxName;
                    tax.Tax_Description = taxModel.TaxDescription.Trim();
                    tax.Tax_Code        = taxModel.TaxCode.Trim();
                    tax.Tax_Rate        = taxModel.TaxRate;
                    if (taxModel.IsInActive == null)
                    {
                        tax.Tax_Inactive = "N";
                    }
                    else
                    {
                        tax.Tax_Inactive = taxModel.IsInActive;
                    }
                    tax.Tax_Default = false;
                    tax.CreatedDate = DateTime.Now;
                    tax.IsDeleted   = false;

                    objEntities.TaxCodesAndRates.Add(tax);
                    objEntities.SaveChanges();

                    var taxes = objEntities.TaxCodesAndRates.ToList();
                    if (taxes != null)
                    {
                        foreach (var taxItem in taxes)
                        {
                            taxItem.Tax_Name = taxModel.TaxName;
                            objEntities.SaveChanges();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int SaveTransferMoney(TransferMoneyEntity transferMoney)
        {
            int autoId = 0;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    TransferMoney cbt = new TransferMoney();
                    cbt.From_Acc_Id = transferMoney.SelectedtransferFromCashAndBankAcntID;
                    cbt.To_Acc_Id   = transferMoney.SelectedtransferToCashBankAcntID;
                    cbt.Cheque      = transferMoney.IsCheque;
                    cbt.Cheque_No   = transferMoney.CashChequeNo;
                    cbt.Cheque_Date = transferMoney.CashChequeDate;
                    cbt.Remarks     = transferMoney.Remarks;
                    cbt.Amount      = transferMoney.Amount;
                    cbt.Remarks     = transferMoney.Remarks;
                    cbt.CreatedBy   = 1;
                    cbt.CreatedDate = DateTime.Now;
                    entities.TransferMoneys.Add(cbt);
                    entities.SaveChanges();

                    Account acntFrom = entities.Accounts.SingleOrDefault(e => e.ID == transferMoney.SelectedtransferFromCashAndBankAcntID);
                    if (acntFrom != null)
                    {
                        acntFrom.Acc_Cur_Bal = (acntFrom.Acc_Cur_Bal == null?0:acntFrom.Acc_Cur_Bal) - transferMoney.Amount;
                        entities.SaveChanges();
                    }

                    Account acntTo = entities.Accounts.SingleOrDefault(e => e.ID == transferMoney.SelectedtransferToCashBankAcntID);
                    if (acntTo != null)
                    {
                        acntTo.Acc_Cur_Bal = (acntTo.Acc_Cur_Bal == null?0:acntTo.Acc_Cur_Bal) + transferMoney.Amount;
                        entities.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(autoId);
        }
 public bool SaveUsers(List <UsersSecurityEntity> Users)
 {
     try
     {
         foreach (var item in Users)
         {
             if (item.Password != null && item.Password != "")
             {
                 item.EncryptedPassword = Encrypt(item.Password);
             }
             var checkuser = entites.Users.Where(x => x.UserId == item.ID).FirstOrDefault();
             if (checkuser != null)
             {
                 checkuser.User_Name     = item.UserName;
                 checkuser.User_Password = item.EncryptedPassword;
                 checkuser.Active        = item.Isinactive;
                 checkuser.CreatedDate   = DateTime.Now;
                 checkuser.User_Email    = "*****@*****.**";
                 entites.SaveChanges();
             }
             else
             {
                 User user = new User()
                 {
                     User_Name     = item.UserName.ToLower(),
                     User_Password = item.EncryptedPassword,
                     Active        = item.Isinactive,
                     CreatedDate   = DateTime.Now,
                     User_Email    = "*****@*****.**"
                 };
                 entites.Users.Add(user);
                 entites.SaveChanges();
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
         //throw ex;
     }
 }
Beispiel #22
0
        public int SaveUndeliveredPurchaseOrdersDepositsData(UndeliveredPurchaseOrdersDepositsModel JForm)
        {
            //int autoId = 0;
            // UnpaidSalesInvoice obj = new UnpaidSalesInvoice();
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    UndeliveredPurchaseOrdersWithDeposit obj1;
                    if (JForm.UndeliveredPurchaseOrdersDepositsDetailsData != null)
                    {
                        foreach (UndeliveredPurchaseOrdersDepositsEntity JEntity in JForm.UndeliveredPurchaseOrdersDepositsDetailsData)
                        {
                            //save entity value
                            obj1      = new UndeliveredPurchaseOrdersWithDeposit();
                            obj1.S_ID = JEntity.ID;
                            obj1.UPurchaseOrder_No            = JEntity.OrderNo;
                            obj1.UPurchaseOrder_Date          = JEntity.OrderDateTime;
                            obj1.UPurchaseOrder_Amount        = JEntity.UndeliveredAmount;
                            obj1.UPurchaseOrderDeposit_Amount = JEntity.DepositAmount;
                            obj1.CreatedDate = DateTime.Now;
                            obj1.IsDeleted   = false;
                            if (obj1 != null)
                            {
                                entities.UndeliveredPurchaseOrdersWithDeposits.Add(obj1);
                                entities.SaveChanges();
                            }
                            //if (entities.UndeliveredPurchaseOrdersWithDeposits.AsNoTracking().FirstOrDefault(x => x.ID == JEntity.ID) == null)
                            //{
                            //    entities.UndeliveredPurchaseOrdersWithDeposits.Add(obj1);
                            //    entities.SaveChanges();

                            //}
                            //else
                            //{
                            //    entities.Entry(obj1).State = EntityState.Modified;
                            //    entities.SaveChanges();
                            //}
                        }
                    }

                    else
                    {
                    }
                }
                return(1);
            }
            catch (Exception e)
            {
                return(0);

                throw e;
            }
        }
 public void UpdatePandS(PandSDetailsModel pandsModel)
 {
     try
     {
         using (SASEntitiesEDM objEntities = new SASEntitiesEDM())
         {
             ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == pandsModel.ID).SingleOrDefault();
             if (pands != null)
             {
                 pands.PandS_Code          = pandsModel.PSCode;
                 pands.PandS_Name          = pandsModel.PSName;
                 pands.PandS_Type          = pandsModel.PSType;
                 pands.PandS_Cat1          = pandsModel.PSCategory1;
                 pands.PandS_Cat2          = pandsModel.PSCategory2;
                 pands.Tax_Rate            = pandsModel.TaxRate;
                 pands.Tax_ID              = pandsModel.TaxID;
                 pands.PandS_Description   = pandsModel.PSDescription;
                 pands.PandS_Inactive      = pandsModel.IsInActive == null ? null : pandsModel.IsInActive;
                 pands.PandS_Stock_Picture = pandsModel.ImgSource;
                 //Standard Sell and cost price
                 pands.PandS_Std_Sell_Price_bef_GST = Convert.ToDecimal(pandsModel.StandardSellPriceBeforeGST);
                 pands.PandS_Std_Sell_Price_aft_GST = Convert.ToDecimal(pandsModel.StandardSellPriceAfterGST);
                 pands.PandS_Std_Cost_Price_bef_GST = Convert.ToDecimal(pandsModel.StandardCostpriceBeforeGST);
                 pands.PandS_Std_Cost_Price_aft_GST = Convert.ToDecimal(pandsModel.StandardCostpriceAfterGST);
                 //Average
                 pands.PandS_Ave_Sell_Price_bef_GST = Convert.ToDecimal(pandsModel.AverageSellPriceBeforeGST);
                 pands.PandS_Ave_Sell_Price_aft_GST = Convert.ToDecimal(pandsModel.AverageSellPriceAfterGST);
                 pands.PandS_Ave_Cost_Price_bef_GST = Convert.ToDecimal(pandsModel.AverageCostPriceBeforeGST);
                 pands.PandS_Ave_Cost_Price_aft_GST = Convert.ToDecimal(pandsModel.AverageCostPriceAfterGST);
                 //Last
                 pands.PandS_Last_Sold_Price_bef_GST = Convert.ToDecimal(pandsModel.LastSoldPriceBeforeGST);
                 pands.PandS_Last_Sold_Price_aft_GST = Convert.ToDecimal(pandsModel.LastSoldPriceAfterGST);
                 pands.PandS_Last_Pur_Price_bef_GST  = Convert.ToDecimal(pandsModel.LastPurchasePriceBeforeGST);
                 pands.PandS_Last_Pur_Price_aft_GST  = Convert.ToDecimal(pandsModel.LastPurchasePriceAfterGST);
                 //Stock
                 pands.PandS_Min_Qty      = pandsModel.MinimumQuantity;
                 pands.PandS_Qty_in_stock = pandsModel.QuantityInStock;
                 pands.PandS_Qty_for_SO   = pandsModel.ReservedForSalesOrders;
                 pands.PandS_Qty_on_PO    = pandsModel.OnPurchaseOrders;
                 pands.PandS_Stock_Value  = pandsModel.StockValue;
                 pands.ModifiedBy         = pandsModel.LoggedinUserID;
                 pands.ModifiedDate       = DateTime.Now;
                 pands.IsRefresh          = false;
                 pands.RefreshDate        = null;
                 objEntities.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public int CreateCustomer(Customer entity)
        {
            Customer obj = new Customer();

            using (SASEntitiesEDM entities = new SASEntitiesEDM())
            {
                if (entities.Customers.AsNoTracking().FirstOrDefault(x => x.ID == entity.ID) == null)
                {
                    entities.Customers.Add(entity);
                }
                else
                {
                    entities.Entry(entity).State = EntityState.Modified;
                }
                return(entities.SaveChanges());
            }
        }
        /// <summary>
        /// This method is used to delete the tax
        /// </summary>
        /// <param name="id"></param>
        public void DeleteTax(int id)
        {
            try
            {
                using (SASEntitiesEDM objEntities = new SASEntitiesEDM())
                {
                    TaxCodesAndRate tax = objEntities.TaxCodesAndRates.SingleOrDefault(t => t.ID == id);

                    tax.IsDeleted    = true;
                    tax.ModifiedDate = DateTime.Now;
                    objEntities.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #26
0
 /// <summary>
 /// This method is used to save Purchase and sales Category Content
 /// </summary>
 /// <param name="content"></param>
 public void SavePSCategoryContent(ContentModel content)
 {
     using (SASEntitiesEDM objCategoryEntities = new SASEntitiesEDM())
     {
         try
         {
             var tandc = objCategoryEntities.TermsAndConditions.Where(e => e.Cat_Code == content.CategoryCode).SingleOrDefault();
             if (tandc != null)
             {
                 tandc.Cat_Content = content.ContentName;
                 objCategoryEntities.SaveChanges();
             }
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
        public int DeleteInvoice(string pqNo)
        {
            int PIStatus = 0;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var PInvoice = entities.BusinessExpenses.Where(e => e.PI_No == pqNo).FirstOrDefault();
                    if (PInvoice != null)
                    {
                        var PO_PI = entities.CashAndBankTransactions.Where(x => x.SO_CN_PO_DN_No == pqNo
                                                                           ).FirstOrDefault();

                        if (PO_PI != null)
                        {
                            if (PO_PI.Amt_Due != null)
                            {
                                PInvoice.PI_Status = Convert.ToByte(PI_Status.UnPaid);
                                PIStatus           = Convert.ToByte(PI_Status.UnPaid);
                            }
                            else
                            {
                                PInvoice.PI_Status = Convert.ToByte(PI_Status.Paid);
                                PIStatus           = Convert.ToByte(PI_Status.Paid);
                            }
                        }
                        else
                        {
                            PInvoice.PI_Status = Convert.ToByte(PI_Status.Cancelled);
                            PIStatus           = Convert.ToByte(PI_Status.Cancelled);
                        }
                        entities.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(PIStatus);
        }
        public bool DeleteCustomer(int custId)
        {
            bool result = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var obj = entities.Customers.Where(x => x.ID == custId).FirstOrDefault();
                    entities.Customers.Remove(obj);
                    entities.SaveChanges();
                }
                result = true;
            }
            catch
            {
                result = false;
            }
            return(result);
        }
Beispiel #29
0
        /// <summary>
        /// This method is used to delete Category Content
        /// </summary>
        /// <param name="catId"></param>
        public void DeleteCategoryContent(int contentID)
        {
            using (SASEntitiesEDM objCategoryEntities = new SASEntitiesEDM())
            {
                try
                {
                    CategoriesContent catContent = objCategoryEntities.CategoriesContents.SingleOrDefault(i => i.ID == contentID);
                    if (catContent != null)
                    {
                        catContent.IsDeleted = true;

                        objCategoryEntities.SaveChanges();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
 public void DeletePandS(PandSDetailsModel pandsModel)
 {
     try
     {
         using (SASEntitiesEDM objEntities = new SASEntitiesEDM())
         {
             ProductsAndService pands = objEntities.ProductsAndServices.Where(p => p.ID == pandsModel.ID).SingleOrDefault();
             if (pands != null)
             {
                 pands.IsDeleted    = true;
                 pands.ModifiedBy   = pandsModel.LoggedinUserID;
                 pands.ModifiedDate = DateTime.Now;
                 objEntities.SaveChanges();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }