public bool DeleteQuotatoin(int pqID)
        {
            bool result = false;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    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 List <AdjustCreditNoteEntity> GetCreditNotes(string CustomerId)
        {
            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                int supid = 0;
                //List<CustomerEntity> suppliersource = entities.Customers.Where(x => x.IsDeleted != true).Select(x => new CustomerEntity
                //{
                //    ID = x.ID,
                //    CustomerName = x.Sup_Name,
                //    Createddate = x.CreatedDate,
                //}).ToList();
                if (CustomerId != null || CustomerId != "" || CustomerId != " ")
                {
                    supid = Convert.ToInt32(CustomerId);
                }
                List <AdjustCreditNoteEntity> debitnotelist = (from p in entities.SalesInvoices
                                                               join d in entities.CreditNotes on p.ID equals d.SI_Id
                                                               where d.IsDeleted != true && d.Cus_Id == supid
                                                               select new AdjustCreditNoteEntity
                {
                    Date = d.CN_Date,
                    Amount = p.SI_Tot_aft_Tax,
                    CreditNoteNo = d.CN_No
                }).ToList();

                return(debitnotelist);
            }
        }
        public string GetCountOfSOCustomers()
        {
            string POCount = string.Empty;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var po = (from e in entities.SalesOrders
                              join p in entities.Customers
                              on e.Cus_Id equals p.ID
                              where e.IsDeleted == false
                              select new
                    {
                        e.Cus_Id,
                        p.Cus_Name
                    }
                              ).Distinct().ToList();

                    if (po != null)
                    {
                        POCount = Convert.ToString(po.Count);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(POCount);
        }
        public string GetCountOfSICustomers()
        {
            string PICount = string.Empty;
            byte   status  = Convert.ToByte(SI_Status.UnPaid);

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var po = (from e in entities.SalesInvoices
                              join p in entities.Customers
                              on e.Cus_Id equals p.ID
                              where e.IsDeleted == false &&
                              e.SI_Status == status
                              select new
                    {
                        e.Cus_Id,
                        p.Cus_Name
                    }
                              ).Distinct().ToList();
                    if (po != null)
                    {
                        PICount = Convert.ToString(po.Count);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(PICount);
        }
Example #5
0
        /// <summary>
        /// This method is used to get category content
        /// </summary>
        /// <returns></returns>
        public string GetCategoryContent(string catType)
        {
            string tandCContent = string.Empty;

            using (SDNSalesDBEntities objProdEntities = new SDNSalesDBEntities())
            {
                try
                {
                    var tandC = (from content in objProdEntities.TermsAndConditions
                                 where content.Cat_Code == catType
                                 select new ContentModel
                    {
                        ContentName = content.Cat_Content,
                        ContentID = content.ID
                    });
                    if (tandC != null)
                    {
                        tandCContent = tandC.SingleOrDefault().ContentName;
                    }
                    return(tandCContent);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
        ///// <summary>
        ///// This method is used to get latest quitation no
        ///// </summary>
        ///// <returns></returns>
        //public int GetLastOrderNo()
        //{
        //    int qno = 0;
        //    try
        //    {
        //        using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
        //        {
        //            var pq = (from pqs in entities.SalesOrders
        //                      orderby pqs.ID descending
        //                      select new
        //                      {
        //                          pqs.ID,
        //                          pqs.CreatedDate
        //                      }

        //                     );
        //            if (pq != null)
        //            {
        //                qno = pq.Take(1).SingleOrDefault().ID;
        //            }
        //            else
        //            {
        //                qno = 0;
        //            }
        //        }
        //        return qno;
        //    }
        //    catch (Exception ex)
        //    {
        //        throw ex;
        //    }
        //}
        /// <summary>
        /// This method is used to get all sales orders
        /// </summary>
        /// <returns></returns>
        public List <SalesOrderEntity> GetAllSalesOrders()
        {
            // List<SalesOrderModel> lstSOF = new List<SalesOrderForm>();
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var lstSOs = (from pq in entities.SalesOrders
                                  where (pq.IsDeleted == false || pq.IsDeleted == null)

                                  select new SalesOrderEntity
                    {
                        CustomerID = pq.Cus_Id,
                        OrderNo = pq.SO_No,
                        OrderDate = pq.SO_Date,
                        //ValidForDays = pq.SO_Valid_for,,
                        DeliveryDate = pq.SO_Del_Date,
                        Cus_Po_No = pq.Cus_PO_No,
                        TotalBeforeTax = pq.SO_Tot_bef_Tax,
                        TotalTax = pq.SO_GST_Amt,
                        TotalAfterTax = pq.SO_Tot_aft_Tax,
                        TermsAndConditions = pq.SO_TandC,
                        CreatedBy = pq.CreatedBy,
                        CreatedDate = pq.CreatedDate
                    }).ToList <SalesOrderEntity>();

                    return(lstSOs);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #7
0
        /// <summary>
        /// This method is used to get all purchase invoices
        /// </summary>
        /// <returns></returns>
        public List <SalesInvoiceEntity> GetAllSalesInvoices()
        {
            // List<SalesInvoiceModel> lstSIF = new List<SalesInvoiceForm>();
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var lstSIs = (from pq in entities.SalesInvoices
                                  where (pq.IsDeleted == false || pq.IsDeleted == null)

                                  select new SalesInvoiceEntity
                    {
                        CustomerID = pq.Cus_Id,
                        InvoiceNo = pq.SI_No,
                        InvoiceDate = pq.SI_Date,
                        // PaymentDueDate = pq.SI_Pmt_Due_Date,
                        OurSONo = pq.Cus_PO_No,
                        CreditDays = pq.SI_Credit_Days,
                        SalesmanID = pq.Salesman,
                        TotalBeforeTax = pq.SI_Tot_bef_Tax,
                        TotalTax = pq.SI_GST_Amt,
                        TotalAfterTax = pq.SI_Tot_aft_Tax,
                        TermsAndConditions = pq.SI_TandC,
                        CreatedBy = pq.CreatedBy,
                        CreatedDate = pq.CreatedDate
                    }).ToList <SalesInvoiceEntity>();

                    return(lstSIs);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #8
0
        public bool IsChequeNoPresent(string cashChequeNo)
        {
            string str = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundToCustomer));

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var po = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == cashChequeNo &&
                                                                    e.Type == str).ToList();
                    if (po.Count > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #9
0
        public string GetCountOfCNCustomers(out List <CustomerEntity> lstCustomers)
        {
            string DNCount    = string.Empty;
            byte   status     = Convert.ToByte(DN_Status.UnAdjusted);
            byte   unrefunded = Convert.ToByte(DN_Status.Refunded);

            lstCustomers = new List <CustomerEntity>();
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var po = (from e in entities.CreditNotes
                              join p in entities.Customers
                              on e.Cus_Id equals p.ID
                              where e.IsDeleted != true &&
                              (e.CN_Status == status || e.CN_Status != unrefunded)
                              select new CustomerEntity
                    {
                        CustomerID = e.Cus_Id,
                        Name = p.Cus_Name
                    }
                              ).Distinct().ToList();
                    if (po != null)
                    {
                        lstCustomers = new List <CustomerEntity>(po.ToList());
                        DNCount      = Convert.ToString(po.Count);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(DNCount);
        }
        public void UpdateCreditNote(CreditNoteForm CreditNote)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    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.Cus_DN_No     = CreditNote.CreditNote.CustomerDebitNoteNo;
                        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;
            }
        }
        /// <summary>
        /// This method is used to get all purchase quotations
        /// </summary>
        /// <returns></returns>
        public List <SalesQuotationEntity> GetAllSalesQuotations()
        {
            // List<SalesQuotationModel> lstSQF = new List<SalesQuotationForm>();
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var lstSQs = (from pq in entities.SalesQuotations
                                  where (pq.IsDeleted == false || pq.IsDeleted == null)

                                  select new SalesQuotationEntity
                    {
                        CustomerID = pq.Cus_Id,
                        QuotationNo = pq.SQ_No,
                        QuotationDate = pq.SQ_Date,
                        ValidForDays = pq.SQ_Valid_for,
                        TotalBeforeTax = pq.SQ_Tot_bef_Tax,
                        TotalTax = pq.SQ_GST_Amt,
                        TotalAfterTax = pq.SQ_Tot_aft_Tax,
                        TermsAndConditions = pq.SQ_TandC,
                        CreatedBy = pq.CreatedBy,
                        CreatedDate = pq.CreatedDate
                    }).ToList <SalesQuotationEntity>();

                    return(lstSQs);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public List <ContentModel> GetAllSalesman(string catType)
        {
            List <ContentModel> lstsalesman = new List <ContentModel>();

            using (SDNSalesDBEntities objProdEntities = new SDNSalesDBEntities())
            {
                try
                {
                    lstsalesman = (from content in objProdEntities.Categories
                                   join catContent in objProdEntities.CategoriesContents
                                   on content.ID equals catContent.Cat_Id
                                   where content.Cat_Code == catType && catContent.IsDeleted == false
                                   select new ContentModel
                    {
                        ContentName = catContent.Cat_Contents,
                        ContentID = catContent.ID
                    }).ToList <ContentModel>();

                    return(lstsalesman);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #13
0
        private int GetLastCreditNoteNo()
        {
            int qno = 0;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pq = (from pqs in entities.CreditNotes
                              orderby pqs.ID descending
                              select new
                    {
                        pqs.ID,
                        pqs.CreatedDate
                    }

                              );
                    if (pq != null)
                    {
                        qno = pq.Take(1).SingleOrDefault().ID;
                    }
                    else
                    {
                        qno = 0;
                    }
                }
                return(qno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #14
0
 public List <CatagoryType> GetCustomerType()
 {
     using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
     {
         return(this.GetCategoryType("CT"));
     }
 }
Example #15
0
        public string GetLastInvoiceNo()
        {
            string qno = string.Empty;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pq = (from pqs in entities.SalesInvoices
                              orderby pqs.ID descending
                              select new
                    {
                        pqs.ID,
                        pqs.SI_No,
                        pqs.CreatedDate
                    }

                              );
                    if (pq != null)
                    {
                        qno = pq.Take(1).SingleOrDefault().SI_No;
                        if (qno != null)
                        {
                            string[] str = qno.Split('-');
                            if (str != null)
                            {
                                qno = str[1];
                            }
                        }
                        else
                        {
                            qno = Convert.ToString(pq.Take(1).SingleOrDefault().ID);
                        }
                    }
                    else
                    {
                        var op = (from pqs in entities.Options
                                  select new
                        {
                            pqs.Starting_Sales_Inv_No
                        }

                                  );
                        if (op != null)
                        {
                            if (op.SingleOrDefault().Starting_Sales_Inv_No != null)
                            {
                                qno = op.SingleOrDefault().Starting_Sales_Inv_No;
                            }
                        }
                    }
                }
                return(qno);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public int SaveAdjustCreditNote(AdjustCreditNoteForm psForm)
        {
            int autoId = 0;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    foreach (var item in psForm.AdjustCreditNoteDetails)
                    {
                        CashAndBankTransaction obj = new CashAndBankTransaction();
                        obj.Cus_Sup_Id = psForm.AdjustCreditNote.CustomerID;
                        obj.Acc_Id     = psForm.AdjustCreditNote.AccountId;
                        obj.Amount     = psForm.AdjustCreditNote.Amount;
                        //obj.Cash_Cheque_No = psForm.AdjustCreditNote.CashChequeNo;
                        obj.Cash_Cheque_Date = psForm.AdjustCreditNote.Date;
                        obj.Remarks          = psForm.AdjustCreditNote.Remarks;
                        obj.Type             = "S";
                        //obj.Is_Cheque = psForm.AdjustCreditNote.IsCheque;

                        //saving details entity
                        obj.SO_CN_PO_DN_No   = item.SalesNo;
                        obj.SO_CN_PO_DN_Date = item.SalesDate;
                        obj.SO_CN_PO_DN_Amt  = item.SalesAmount;
                        obj.Amt_Due          = item.AmountDue;
                        obj.Amt_Refunded     = item.AmountAdjusted;
                        obj.Discount         = item.Discount;

                        obj.UpdatedBy   = 0;
                        obj.UpdatedDate = DateTime.Now.Date;

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

                        if (item.AmountDue == 0 && item.AmountAdjusted == item.SalesAmount)
                        {
                            SalesInvoice invoice = entities.SalesInvoices.Where(e => e.SI_No == item.SalesNo).SingleOrDefault();
                            SalesOrder   order   = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).SingleOrDefault();
                            if (invoice != null)
                            {
                                invoice.SI_Status = Convert.ToByte(SI_Status.Paid);
                                entities.SaveChanges();
                            }
                            else if (order != null)
                            {
                            }
                        }

                        //}
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(autoId);
        }
Example #17
0
        public int UpdateRefundToCustomer(RefundToCustomerForm psForm)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    foreach (var item in psForm.RefundToCustomerDetails)
                    {
                        CashAndBankTransaction obj = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == psForm.RefundToCustomer.CashChequeNo &&
                                                                                            e.SO_CN_PO_DN_No == item.SalesNo).SingleOrDefault();
                        if (obj != null)
                        {
                            obj.Acc_Id           = psForm.RefundToCustomer.AccountId;
                            obj.Amount           = psForm.RefundToCustomer.Amount;
                            obj.Cash_Cheque_No   = psForm.RefundToCustomer.CashChequeNo;
                            obj.Cash_Cheque_Date = psForm.RefundToCustomer.Date;
                            obj.Remarks          = psForm.RefundToCustomer.Remarks;

                            obj.Is_Cheque = psForm.RefundToCustomer.IsCheque;

                            //saving details entity
                            obj.SO_CN_PO_DN_No   = item.SalesNo;
                            obj.SO_CN_PO_DN_Date = item.SalesDate;
                            obj.SO_CN_PO_DN_Amt  = item.SalesAmount;
                            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.AmountDue == 0 && item.AmountAdjusted == item.SalesAmount)
                            {
                                CreditNote dn    = entities.CreditNotes.Where(e => e.CN_No == item.SalesNo).SingleOrDefault();
                                SalesOrder order = entities.SalesOrders.Where(e => e.SO_No == item.SalesNo).SingleOrDefault();
                                if (dn != null)
                                {
                                    dn.CN_Status = Convert.ToByte(DN_Status.Refunded);
                                    entities.SaveChanges();
                                }
                                else if (order != null)
                                {
                                    order.SO_Status = Convert.ToByte(PO_Status.Refunded);
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(psForm.RefundToCustomer.ID);
        }
Example #18
0
        public RefundToCustomerForm GetRefundToCustomerDetails(string cashChequeNo)
        {
            string str = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundToCustomer));
            RefundToCustomerForm pqf = new RefundToCustomerForm();

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pq = (from pqs in entities.CashAndBankTransactions
                              where pqs.Cash_Cheque_No == cashChequeNo &&
                              pqs.Type == str
                              select new RefundToCustomerEntity
                    {
                        ID = pqs.ID,
                        CustomerID = pqs.Cus_Sup_Id,
                        Amount = pqs.Amount,
                        AccountId = pqs.Acc_Id,
                        Remarks = pqs.Remarks,
                        Date = pqs.Cash_Cheque_Date,
                        IsCheque = pqs.Is_Cheque,
                        CashChequeNo = pqs.Cash_Cheque_No,
                    }).FirstOrDefault();

                    if (pq != null)
                    {
                        pq.AmountStr         = Convert.ToString(pq.Amount);
                        pqf.RefundToCustomer = pq;
                    }


                    var pqd = (from pqs in entities.CashAndBankTransactions
                               where pqs.Cash_Cheque_No == cashChequeNo &&
                               pqs.Type == str
                               select new RefundToCustomerDetailsEntity
                    {
                        SalesNo = pqs.SO_CN_PO_DN_No,
                        SalesDate = pqs.SO_CN_PO_DN_Date,
                        SalesAmount = pqs.SO_CN_PO_DN_Amt,
                        AmountDue = pqs.Amt_Due,
                        Discount = pqs.Discount,
                        AmountAdjusted = pqs.Amt_Refunded
                    }).ToList <RefundToCustomerDetailsEntity>();

                    if (pqd != null)
                    {
                        pqf.RefundToCustomerDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public bool DeleteQuotatoin(int pqID)
        {
            bool result = false;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    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);
        }
Example #20
0
 public int CreateCustomer(Customer entity, List <ShippingAddress> shippingAddress)
 {
     using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
     {
         entities.Customers.Add(entity);
         foreach (var address in shippingAddress)
         {
             entities.ShippingAddresses.Add(address);
         }
         return(entities.SaveChanges());
     }
 }
        public bool CanDeleteQuotation(int pqID)
        {
            bool allowDelete = true;

            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                var SO_SI = entities.SalesQuotations.Where(x => (x.SQ_Conv_to_SO == true || x.SQ_Conv_to_SI == true) && x.ID == pqID).FirstOrDefault();

                if (SO_SI != null)
                {
                    allowDelete = false;
                }
            }
            return(allowDelete);
        }
Example #22
0
        private void CreateCreditNote(SalesInvoiceForm invoiceData)
        {
            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    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.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 bool CanDeleteOrder(int pqID)
        {
            byte deposited   = Convert.ToByte(PO_Status.Collected);
            byte refunded    = Convert.ToByte(PO_Status.Refunded);
            bool allowDelete = true;

            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                var SO_SI = entities.SalesOrders.Where(x => (x.SO_Conv_to_SI == true) && x.ID == pqID).FirstOrDefault();
                var SO    = entities.SalesOrders.Where(x => (x.SO_Status == deposited || x.SO_Status == refunded) && x.ID == pqID).FirstOrDefault();
                if (SO_SI != null || SO != null)
                {
                    allowDelete = false;
                }
            }
            return(allowDelete);
        }
Example #24
0
        public string GetLastCashNo()
        {
            string st  = Convert.ToString(Convert.ToByte(CashBankTransactionType.RefundToCustomer));
            string cNo = string.Empty;

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pq = (from pqs in entities.CashAndBankTransactions
                              where pqs.Is_Cheque == false && pqs.Type == st
                              orderby pqs.UpdatedDate descending
                              select new
                    {
                        pqs.UpdatedDate,
                        pqs.Cash_Cheque_No,
                        pqs.ID,
                        pqs.Is_Cheque,
                        pqs.Type
                    }

                              ).ToList();
                    if (pq.Count > 0)
                    {
                        cNo = pq.Take(1).SingleOrDefault().Cash_Cheque_No;
                        if (cNo != null)
                        {
                            string[] str = cNo.Split('-');
                            if (str != null)
                            {
                                cNo = Convert.ToString(Convert.ToInt64(str[1]) + 1);
                            }
                        }
                    }
                    else
                    {
                        cNo = Convert.ToString(1);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(cNo);
        }
Example #25
0
        /// <summary>
        /// Gets all customer.
        /// </summary>
        /// <returns>Get All Customer</returns>
        public List <Customer> GetAllCustomer()
        {
            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                //returns entities from conceptual model
                //ObjectQuery<Customer> customers = entities.Customers;

                ////objects are maintained in a detached state and are not tracked in the ObjectStateManager;
                //customers.MergeOption = MergeOption.NoTracking;

                ////queries against a specific data source where in the type of the data is known
                //IQueryable<Customer> query = from cust in customers select cust;

                //Materialized result
                List <Customer> customerList = entities.Customers.ToList(); //query.ToList();
                return(customerList);
            }
        }
Example #26
0
        public List <CatagoryType> GetCategoryType(string cat_Code)
        {
            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                var customerType = entities.CategoriesContents.Join(entities.Categories,
                                                                    cc => cc.Cat_Id,
                                                                    c => c.ID,
                                                                    ((cc, c) => new { CategoriesContent = cc, Category = c }))
                                   .Where(x => x.CategoriesContent.IsDeleted == false && x.Category.Cat_Code == cat_Code)
                                   .Select((x) => new CatagoryType()
                {
                    ID = x.CategoriesContent.ID, Cat_Contents = x.CategoriesContent.Cat_Contents
                })
                                   .ToList();

                //query.ToList();

                return(customerType);
            }
        }
        public List <CustomerEntity> GetAllCustomer()
        {
            using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
            {
                //List<CustomerEntity> suppliersource = entities.Customers.Where(x => x.IsDeleted != true).Select(x => new CustomerEntity
                //{
                //    ID = x.ID,
                //    CustomerName = x.Sup_Name,
                //    Createddate = x.CreatedDate,
                //}).ToList();
                List <CustomerEntity> suppliersource = (from s in entities.Customers
                                                        join d in entities.CreditNotes on s.ID equals d.Cus_Id
                                                        where d.IsDeleted != true
                                                        select new CustomerEntity
                {
                    CustomerID = s.ID,
                    Name = s.Cus_Name
                }).Distinct().ToList();

                return(suppliersource);
            }
        }
 public bool IsChequeNoPresent(string cashChequeNo)
 {
     try
     {
         using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
         {
             var po = entities.CashAndBankTransactions.Where(e => e.Cash_Cheque_No == cashChequeNo).ToList();
             if (po.Count > 0)
             {
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #29
0
        public RefundToCustomerForm GetNewPS(int?CustomerID)
        {
            RefundToCustomerForm pqf = new RefundToCustomerForm();

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pqd = entities.Database.SqlQuery <RefundToCustomerDetailsEntity>("SRC_GetSalesDataForRefundToCustomers @CustomerID={0}", CustomerID).ToList();

                    if (pqd != null)
                    {
                        pqf.RefundToCustomerDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public AdjustCreditNoteForm GetNewPS(int?CustomerID)
        {
            AdjustCreditNoteForm pqf = new AdjustCreditNoteForm();

            try
            {
                using (SDNSalesDBEntities entities = new SDNSalesDBEntities())
                {
                    var pqd = entities.Database.SqlQuery <AdjustCreditNoteDetailsEntity>("PRC_GetSalesDataForAdjustCreditNotes @CustomerID={0}", CustomerID).ToList();

                    if (pqd != null)
                    {
                        pqf.AdjustCreditNoteDetails = pqd;
                    }

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }