示例#1
0
        int IPurchaseQuotationRepository.AddUpdateQuotation(PurchaseQuotationForm quotationData)
        {
            IPurchaseQuotationBL pqBL = new PurchaseQuotationBL();
            int i = pqBL.AddUpdateQuotation(quotationData);

            return(i);
        }
示例#2
0
        public PurchaseQuotationForm GetDataIntoModel()
        {
            PurchaseQuotationForm PQForm = new PurchaseQuotationForm();

            PQForm.QuotationDetails = new List <PurchaseQuotationDetailEntity>();
            PurchaseQuotationEntity model = new PurchaseQuotationEntity();

            model.QuotationNo    = this.QuotationNo;
            model.QuotationDate  = this.QuotationDate;
            model.TotalBeforeTax = this.TotalBeforeTax;
            model.TotalTax       = this.TotalTax;
            model.TotalAfterTax  = this.TotalAfterTax;
            model.ValidForDays   = this.ValidForDays;
            model.SupplierID     = this.SelectedSupplierID;

            model.TermsAndConditions = this.TermsAndConditions;
            if (ExcludingTax == true)
            {
                model.ExcIncGST = false;
            }
            else
            {
                model.ExcIncGST = true;
            }

            PQForm.Quotation = model;

            foreach (var item in PQDetailsEntity)
            {
                PurchaseQuotationDetailEntity pqEntity = new PurchaseQuotationDetailEntity();
                pqEntity.PQNo       = Convert.ToString(item.SelectedPSID);
                pqEntity.PandSCode  = item.PandSCode;
                pqEntity.PandSName  = item.PandSName;
                pqEntity.PQQty      = item.PQQty;
                pqEntity.PQPrice    = item.PQPrice;
                pqEntity.PQDiscount = item.PQDiscount;
                pqEntity.GSTRate    = item.GSTRate;
                pqEntity.GSTRateStr = Convert.ToString(item.GSTRate) + "%";
                pqEntity.PQAmount   = item.PQAmount;
                if (item.SelectedPSID != null && Convert.ToInt32(item.SelectedPSID) > 0)
                {
                    PQForm.QuotationDetails.Add(pqEntity);
                }
            }
            return(PQForm);
        }
示例#3
0
 public void ConvertToPurchaseInvoice(object param)
 {
     Mouse.OverrideCursor = Cursors.Wait;
     if (this.PQ_Conv_to_PI == false || this.PQ_Conv_to_PI == null)
     {
         PurchaseQuotationForm PQForm = GetDataIntoModel();
         int i = pqRepository.ConvertToPurchaseInvoice(PQForm);
         if (i > 0)
         {
             this.PQ_Conv_to_PI = true;
             AllFieldsReadonly  = true;
             AllFieldsEnabled   = false;
             SupplierEnabled    = false;
         }
     }
     else
     {
         PQErrors = "Already converted to Purchase Invoice";
     }
     Mouse.OverrideCursor = null;
 }
示例#4
0
        /// <summary>
        /// This method is used to save and edit pq
        /// </summary>
        /// <param name="param"></param>
        public void SavePurchaseQuotation(object param)
        {
            MessageBoxResult result = System.Windows.MessageBox.Show("Do you want to save changes?", "Save Confirmation", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.Yes)
            {
                Mouse.OverrideCursor = Cursors.Wait;
                string msg = ValidatePurchaseQuotation();
                if (msg != string.Empty)
                {
                    PQErrors             = msg;
                    Mouse.OverrideCursor = null;
                    return;
                }

                PQErrors = string.Empty;
                PurchaseQuotationForm PQForm = GetDataIntoModel();

                int i = 0;
                if (IsNew == true)
                {
                    i = pqRepository.AddUpdateQuotation(PQForm);
                }
                else
                {
                    i = pqRepository.UpdationQuotation(PQForm);
                }
                if (i > 0)
                {
                    //  GetNewPQ();
                    IsNew           = false;
                    SupplierEnabled = false;
                }
                Mouse.OverrideCursor = null;
            }
        }
示例#5
0
        public int ConvertToPurchaseOrder(PurchaseQuotationForm pqForm)
        {
            IPurchaseQuotationDAL PQDAL = new PurchaseQuotationDAL();

            return(PQDAL.ConvertToPurchaseOrder(pqForm));
        }
示例#6
0
        public int UpdationQuotation(PurchaseQuotationForm quotationData)
        {
            IPurchaseQuotationDAL PQDAL = new PurchaseQuotationDAL();

            return(PQDAL.UpdationQuotation(quotationData));
        }
        public PurchaseQuotationForm GetPrintPurchaseQuotation(string pqno)
        {
            PurchaseQuotationForm pqf = new PurchaseQuotationForm();

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var pq = (from pqs in entities.PurchaseQuotations
                              join Sup in entities.Suppliers on pqs.Sup_Id equals Sup.ID
                              where pqs.PQ_No == pqno && (pqs.IsDeleted == false || pqs.IsDeleted == null)
                              select new PurchaseQuotationEntity
                    {
                        ID = pqs.ID,
                        SupplierID = pqs.Sup_Id,
                        SupplierName = Sup.Sup_Name,
                        SupplierBillAddress1 = Sup.Sup_Bill_to_line1,
                        SupplierBillAddress2 = Sup.Sup_Bill_to_line2,
                        SupplierBillAddressCity = Sup.Sup_Bill_to_city,
                        SupplierBillAddressState = Sup.Sup_Bill_to_state,
                        SupplierBillAddressCountary = Sup.Sup_Bill_to_country,
                        SupplierBillPostCode = Sup.Sup_Bill_to_post_code,
                        SupplierTelephone = Sup.Sup_Telephone,
                        QuotationNo = pqs.PQ_No,
                        QuotationDate = pqs.PQ_Date,
                        ValidForDays = pqs.PQ_Valid_for,
                        TermsAndConditions = pqs.PQ_TandC,
                        TotalBeforeTax = pqs.PQ_Tot_bef_Tax,
                        TotalTax = pqs.PQ_GST_Amt,
                        TotalAfterTax = pqs.PQ_Tot_aft_Tax
                    }).SingleOrDefault();

                    if (pq != null)
                    {
                        pqf.Quotation = pq;
                    }
                    //for comapany details

                    var company = (from com in entities.CompanyDetails
                                   where (com.IsDeleted == false || com.IsDeleted == null)
                                   select new PurchaseQuotationEntity
                    {
                        CompanyName = com.Comp_Name,
                        CompanyRegNumber = com.Comp_Reg_No,
                        CompanyLogo = com.Comp_Logo,
                        CompanyGstNumber = com.Comp_GST_Reg_No,
                        CompanyBillToAddressLine1 = com.Comp_Bill_to_line1,
                        CompanyBillToAddressLine2 = com.Comp_Bill_to_line2,
                        CompanyBillToCity = com.Comp_Bill_to_city,
                        CompanyBillToState = com.Comp_Bill_to_state,
                        CompanyBillToCountary = com.Comp_Bill_to_country,
                        CompanyBillToPostCode = com.Comp_Bill_to_post_code,
                        CompanyShipToAddressLine1 = com.Comp_Ship_to_line1,
                        CompanyShipToAddressLine2 = com.Comp_Ship_to_line2,
                        CompanyShipToCity = com.Comp_Ship_to_city,
                        CompanyShipToState = com.Comp_Ship_to_state,
                        CompanyShipToCountary = com.Comp_Ship_to_country,
                        CompanyShipToPostCode = com.Comp_Ship_to_post_code,
                        CompanyEmail = com.Comp_Email,
                        CompanyFax = com.Comp_Fax
                    }).SingleOrDefault();

                    pqf.Quotation.CompanyName               = company.CompanyName;
                    pqf.Quotation.CompanyLogo               = company.CompanyLogo;
                    pqf.Quotation.CompanyRegNumber          = company.CompanyRegNumber;
                    pqf.Quotation.CompanyGstNumber          = company.CompanyGstNumber;
                    pqf.Quotation.CompanyBillToAddressLine1 = company.CompanyBillToAddressLine1;
                    pqf.Quotation.CompanyBillToAddressLine2 = company.CompanyBillToAddressLine2;
                    pqf.Quotation.CompanyBillToCity         = company.CompanyBillToCity;
                    pqf.Quotation.CompanyBillToState        = company.CompanyBillToState;
                    pqf.Quotation.CompanyBillToCountary     = company.CompanyBillToCountary;
                    pqf.Quotation.CompanyBillToPostCode     = company.CompanyBillToPostCode;
                    pqf.Quotation.CompanyShipToAddressLine1 = company.CompanyShipToAddressLine1;
                    pqf.Quotation.CompanyShipToAddressLine2 = company.CompanyShipToAddressLine2;
                    pqf.Quotation.CompanyShipToCity         = company.CompanyShipToCity;
                    pqf.Quotation.CompanyShipToState        = company.CompanyShipToState;
                    pqf.Quotation.CompanyShipToCountary     = company.CompanyShipToCountary;
                    pqf.Quotation.CompanyShipToPostCode     = company.CompanyShipToPostCode;
                    pqf.Quotation.CompanyEmail              = company.CompanyEmail;
                    pqf.Quotation.CompanyFax = company.CompanyFax;
                    //end for comapany details

                    //option details
                    var optiondata = (from option in entities.Options
                                      select new PurchaseQuotationEntity
                    {
                        CurrencyCode = option.Currency_Code
                    }).SingleOrDefault();
                    pqf.Quotation.CurrencyCode = optiondata.CurrencyCode;
                    //end options details

                    var pqd = (from pqds in entities.PurchaseQuotationDetails
                               where pqds.PQ_ID == pq.ID
                               select new PurchaseQuotationDetailEntity
                    {
                        ID = pqds.ID,
                        PQID = pqds.PQ_ID,
                        PQNo = pqds.PQ_No,
                        PandSCode = pqds.PandS_Code,
                        PandSName = pqds.PandS_Name,
                        PQQty = pqds.PQ_Qty,
                        Price = pqds.PQ_Price,
                        PQDiscount = pqds.PQ_Discount,
                        PQAmount = pqds.PQ_Amount,
                        GSTRate = pqds.GST_Rate
                    }).ToList <PurchaseQuotationDetailEntity>();

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

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// This method is used to get Purchase Quotation details
        /// </summary>
        /// <param name="pqId"></param>
        /// <returns></returns>
        public PurchaseQuotationForm GetPurchaseQuotation(string pqno)
        {
            PurchaseQuotationForm pqf = new PurchaseQuotationForm();

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    var pq = (from pqs in entities.PurchaseQuotations
                              where pqs.PQ_No == pqno && (pqs.IsDeleted == false || pqs.IsDeleted == null)
                              select new PurchaseQuotationEntity
                    {
                        ID = pqs.ID,
                        SupplierID = pqs.Sup_Id,
                        QuotationNo = pqs.PQ_No,
                        QuotationDate = pqs.PQ_Date,
                        ValidForDays = pqs.PQ_Valid_for,
                        TermsAndConditions = pqs.PQ_TandC,
                        TotalBeforeTax = pqs.PQ_Tot_bef_Tax,
                        TotalTax = pqs.PQ_GST_Amt,
                        TotalAfterTax = pqs.PQ_Tot_aft_Tax,
                        ExcIncGST = pqs.Exc_Inc_GST,
                        PQ_Conv_to_PI = pqs.PQ_Conv_to_PI,
                        PQ_Conv_to_PO = pqs.PQ_Conv_to_PO
                    }).FirstOrDefault();

                    if (pq != null)
                    {
                        pqf.Quotation = pq;
                    }


                    var pqd = (from pqds in entities.PurchaseQuotationDetails
                               where pqds.PQ_ID == pq.ID
                               select new PurchaseQuotationDetailEntity
                    {
                        ID = pqds.ID,
                        PQID = pqds.PQ_ID,
                        PQNo = pqds.PQ_No,
                        PandSCode = pqds.PandS_Code,
                        PandSName = pqds.PandS_Name,
                        PQQty = pqds.PQ_Qty,
                        Price = pqds.PQ_Price,
                        PQDiscount = pqds.PQ_Discount,
                        PQAmount = pqds.PQ_Amount,
                        GSTRate = pqds.GST_Rate
                    }).ToList <PurchaseQuotationDetailEntity>();

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

                    return(pqf);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// This method is used to convert the Purchase quotation to order
        /// </summary>
        /// <param name="quotationData"></param>
        /// <returns></returns>
        public int ConvertToPurchaseOrder(PurchaseQuotationForm quotationData)
        {
            int autoId = 0;

            PurchaseOrder obj = new PurchaseOrder();

            //obj.ID = quotationData.Quotation.ID;
            obj.Sup_Id         = quotationData.Quotation.SupplierID;
            obj.PO_Date        = quotationData.Quotation.QuotationDate;
            obj.PO_Del_Date    = DateTime.Now;
            obj.PO_GST_Amt     = Convert.ToDecimal(quotationData.Quotation.TotalTax);
            obj.PO_No          = "PO-" + (GetLastOrderNo() + 1);
            obj.PO_TandC       = quotationData.Quotation.TermsAndConditions;
            obj.PO_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax);
            obj.PO_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax);
            obj.PO_Status      = Convert.ToByte(PO_Status.unDeposited);
            obj.Exc_Inc_GST    = quotationData.Quotation.ExcIncGST;
            obj.IsDeleted      = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    if (entities.PurchaseOrders.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null)
                    {
                        //obj.CreatedBy = quotationData.PQModel.CreatedBy;
                        obj.CreatedDate = DateTime.Now;
                        entities.PurchaseOrders.Add(obj);
                        entities.SaveChanges();
                        autoId = obj.ID;
                    }
                    else
                    {
                        // obj.ModifiedBy = quotationData.PQModel.ModifiedBy;
                        obj.ModifiedDate          = DateTime.Now;
                        entities.Entry(obj).State = EntityState.Modified;
                        autoId = entities.SaveChanges();
                    }
                    if (autoId > 0)
                    {
                        PurchaseOrderDetail PQDetails;
                        if (quotationData.QuotationDetails != null)
                        {
                            foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails)
                            {
                                PQDetails             = new PurchaseOrderDetail();
                                PQDetails.PO_ID       = autoId;
                                PQDetails.PO_No       = PQDetailEntity.PQNo;
                                PQDetails.PandS_Code  = PQDetailEntity.PandSCode;
                                PQDetails.PandS_Name  = PQDetailEntity.PandSName;
                                PQDetails.PO_Amount   = PQDetailEntity.PQAmount;
                                PQDetails.PO_Discount = PQDetailEntity.PQDiscount;
                                PQDetails.PO_No       = PQDetailEntity.PQNo;
                                PQDetails.PO_Price    = Convert.ToDecimal(PQDetailEntity.PQPrice);
                                PQDetails.PO_Qty      = PQDetailEntity.PQQty;
                                PQDetails.GST_Code    = PQDetailEntity.GSTCode;
                                PQDetails.GST_Rate    = PQDetailEntity.GSTRate;

                                if (entities.PurchaseOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == PQDetailEntity.ID) == null)
                                {
                                    entities.PurchaseOrderDetails.Add(PQDetails);
                                    entities.SaveChanges();
                                }
                                else
                                {
                                    entities.Entry(PQDetails).State = EntityState.Modified;
                                    entities.SaveChanges();
                                }
                            }
                        }

                        PurchaseQuotation objQ = entities.PurchaseQuotations.Where(e => e.PQ_No == quotationData.Quotation.QuotationNo
                                                                                   ).SingleOrDefault();
                        if (objQ != null)
                        {
                            objQ.PQ_Conv_to_PO = true;
                            objQ.Conv_to_No    = obj.PO_No;
                            objQ.ModifiedDate  = DateTime.Now;
                            entities.SaveChanges();
                        }
                    }
                }
                return(autoId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        /// <summary>
        /// This method is used to add or edit purchase quotation
        /// </summary>
        /// <param name="quotationData"></param>
        /// <returns></returns>
        public int AddUpdateQuotation(PurchaseQuotationForm quotationData)
        {
            int autoId = 0;
            //Add purchase quotation
            PurchaseQuotation obj = new PurchaseQuotation();

            obj.ID            = quotationData.Quotation.ID;
            obj.Sup_Id        = quotationData.Quotation.SupplierID;
            obj.PQ_Conv_to_PO = quotationData.Quotation.PQ_Conv_to_PO;
            obj.PQ_Conv_to_PI = quotationData.Quotation.PQ_Conv_to_PI;
            //obj.PQ_Date = quotationData.Quotation.QuotationDate;
            obj.PQ_Date        = quotationData.Quotation.QuotationDate;
            obj.PQ_GST_Amt     = Convert.ToDecimal(quotationData.Quotation.TotalTax);
            obj.PQ_No          = quotationData.Quotation.QuotationNo;
            obj.PQ_TandC       = quotationData.Quotation.TermsAndConditions;
            obj.PQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax);
            obj.PQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax);
            obj.PQ_Valid_for   = quotationData.Quotation.ValidForDays;
            obj.Exc_Inc_GST    = quotationData.Quotation.ExcIncGST;
            obj.IsDeleted      = false;

            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    if (entities.PurchaseQuotations.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null)
                    {
                        //obj.CreatedBy = quotationData.PQModel.CreatedBy;
                        obj.CreatedDate = DateTime.Now;
                        entities.PurchaseQuotations.Add(obj);
                        entities.SaveChanges();
                        autoId = obj.ID;
                    }
                    else
                    {
                        // obj.ModifiedBy = quotationData.PQModel.ModifiedBy;
                        obj.ModifiedDate          = DateTime.Now;
                        entities.Entry(obj).State = EntityState.Modified;
                        autoId = entities.SaveChanges();
                    }
                    if (autoId > 0)
                    {
                        PurchaseQuotationDetail PQDetails;
                        if (quotationData.QuotationDetails != null)
                        {
                            foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails)
                            {
                                PQDetails             = new PurchaseQuotationDetail();
                                PQDetails.PQ_ID       = autoId;
                                PQDetails.PQ_No       = PQDetailEntity.PQNo;
                                PQDetails.PandS_Code  = PQDetailEntity.PandSCode;
                                PQDetails.PandS_Name  = PQDetailEntity.PandSName;
                                PQDetails.PQ_Amount   = PQDetailEntity.PQAmount;
                                PQDetails.PQ_Discount = PQDetailEntity.PQDiscount;
                                PQDetails.PQ_No       = PQDetailEntity.PQNo;
                                PQDetails.PQ_Price    = Convert.ToDecimal(PQDetailEntity.PQPrice);
                                PQDetails.PQ_Qty      = PQDetailEntity.PQQty;
                                PQDetails.GST_Code    = PQDetailEntity.GSTCode;
                                PQDetails.GST_Rate    = PQDetailEntity.GSTRate;

                                if (entities.PurchaseQuotationDetails.AsNoTracking().FirstOrDefault(x => x.ID == PQDetailEntity.ID) == null)
                                {
                                    entities.PurchaseQuotationDetails.Add(PQDetails);
                                    entities.SaveChanges();
                                }
                                else
                                {
                                    entities.Entry(PQDetails).State = EntityState.Modified;
                                    entities.SaveChanges();
                                }
                            }
                        }
                    }
                }
                return(autoId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#11
0
        public int ConvertToPurchaseInvoice(PurchaseQuotationForm quotationData)
        {
            IPurchaseQuotationBL pqBL = new PurchaseQuotationBL();

            return(pqBL.ConvertToPurchaseInvoice(quotationData));
        }
示例#12
0
        public int ConvertToPurchaseOrder(PurchaseQuotationForm pqForm)
        {
            IPurchaseQuotationBL pqBL = new PurchaseQuotationBL();

            return(pqBL.ConvertToPurchaseOrder(pqForm));
        }
示例#13
0
        public int UpdationQuotation(PurchaseQuotationForm quotationData)
        {
            IPurchaseQuotationBL pqBL = new PurchaseQuotationBL();

            return(pqBL.UpdationQuotation(quotationData));
        }
示例#14
0
        public int ConvertToPurchaseInvoice(PurchaseQuotationForm quotationData)
        {
            IPurchaseQuotationDAL PQDAL = new PurchaseQuotationDAL();

            return(PQDAL.ConvertToPurchaseInvoice(quotationData));
        }
        public int UpdationQuotation(PurchaseQuotationForm quotationData)
        {
            try
            {
                using (SASEntitiesEDM entities = new SASEntitiesEDM())
                {
                    PurchaseQuotation obj = entities.PurchaseQuotations.Where(e => e.PQ_No == quotationData.Quotation.QuotationNo
                                                                              ).SingleOrDefault();
                    if (obj != null)
                    {
                        //obj.ID = quotationData.Quotation.ID;
                        obj.Sup_Id = quotationData.Quotation.SupplierID;
                        // obj.PQ_Conv_to_PO = quotationData.Quotation.PQ_Conv_to_PO;
                        // obj.PQ_Conv_to_PI = quotationData.Quotation.PQ_Conv_to_PI;
                        obj.PQ_Date        = Convert.ToDateTime(quotationData.Quotation.QuotationDateStr);
                        obj.PQ_GST_Amt     = Convert.ToDecimal(quotationData.Quotation.TotalTax);
                        obj.PQ_No          = quotationData.Quotation.QuotationNo;
                        obj.PQ_TandC       = quotationData.Quotation.TermsAndConditions;
                        obj.PQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax);
                        obj.PQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax);
                        obj.PQ_Valid_for   = quotationData.Quotation.ValidForDays;
                        obj.Exc_Inc_GST    = quotationData.Quotation.ExcIncGST;
                        obj.ModifiedDate   = DateTime.Now;
                        entities.SaveChanges();
                    }

                    var objPurchase = entities.PurchaseQuotationDetails.Where
                                          (e => e.PQ_ID == obj.ID).ToList();
                    if (objPurchase != null)
                    {
                        foreach (var item in objPurchase)
                        {
                            entities.PurchaseQuotationDetails.Remove(item);
                            entities.SaveChanges();
                        }
                    }
                    PurchaseQuotationDetail PQDetails;
                    if (quotationData.QuotationDetails != null)
                    {
                        foreach (PurchaseQuotationDetailEntity PQDetailEntity in quotationData.QuotationDetails)
                        {
                            PQDetails             = new PurchaseQuotationDetail();
                            PQDetails.PQ_ID       = obj.ID;
                            PQDetails.PQ_No       = PQDetailEntity.PQNo;
                            PQDetails.PandS_Code  = PQDetailEntity.PandSCode;
                            PQDetails.PandS_Name  = PQDetailEntity.PandSName;
                            PQDetails.PQ_Amount   = PQDetailEntity.PQAmount;
                            PQDetails.PQ_Discount = PQDetailEntity.PQDiscount;
                            PQDetails.PQ_No       = PQDetailEntity.PQNo;
                            PQDetails.PQ_Price    = Convert.ToDecimal(PQDetailEntity.PQPrice);
                            PQDetails.PQ_Qty      = PQDetailEntity.PQQty;
                            PQDetails.GST_Code    = PQDetailEntity.GSTCode;
                            PQDetails.GST_Rate    = PQDetailEntity.GSTRate;

                            entities.PurchaseQuotationDetails.Add(PQDetails);
                            entities.SaveChanges();
                        }
                    }
                    return(obj.ID);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#16
0
        private void UserControl_LoadedPurchaseQuotation(object sender, RoutedEventArgs e)
        {
            //var a = _viewModel.PrintSalesQuotation();
            PurchaseQuotationForm sqf = _viewModelSales.PrintPurchaseQuotation();

            //this is for table grid

            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("PandSCode", typeof(string)));
            dt.Columns.Add(new DataColumn("PandSName", typeof(string)));
            dt.Columns.Add(new DataColumn("Qty", typeof(string)));
            dt.Columns.Add(new DataColumn("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("Discount", typeof(string)));
            dt.Columns.Add(new DataColumn("Amount", typeof(string)));
            dt.Columns.Add(new DataColumn("Rate", typeof(string)));

            //ReportingDataset ds = new ReportingDataset();


            foreach (var item in sqf.QuotationDetails)
            {
                DataRow dr = dt.NewRow();
                dr["PandSCode"] = item.PandSCode;
                dr["PandSName"] = item.PandSName;
                dr["Qty"]       = item.PQQty;
                dr["Price"]     = item.Price.ToString();
                dr["Discount"]  = item.PQDiscount;
                dr["Amount"]    = item.PQAmount.ToString();
                dr["Rate"]      = item.GSTRate.ToString();
                dt.Rows.Add(dr);
            }



            ReportDataSource reportDataSource = new ReportDataSource();

            reportDataSource.Name  = "PurchaseQuotationDetailsDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource.Value = dt;
            // end of product grid code
            DataTable dt4 = new DataTable();

            //for other than table
            dt4.Columns.Add(new DataColumn("TAndCondition", typeof(string)));
            dt4.Columns.Add(new DataColumn("TotalBeforeTaxStr", typeof(string)));
            dt4.Columns.Add(new DataColumn("TotalTax", typeof(string)));
            dt4.Columns.Add(new DataColumn("TotalAfterTaxStr", typeof(string)));
            dt4.Columns.Add(new DataColumn("PQNo", typeof(string)));
            dt4.Columns.Add(new DataColumn("PQDate", typeof(string)));
            dt4.Columns.Add(new DataColumn("ValidForDays", typeof(int)));

            DataRow dr4 = dt4.NewRow();

            dr4["TAndCondition"]     = sqf.Quotation.TermsAndConditions;
            dr4["TotalBeforeTaxStr"] = sqf.Quotation.TotalAfterTax;
            dr4["TotalTax"]          = sqf.Quotation.TotalTax.ToString();
            dr4["TotalAfterTaxStr"]  = sqf.Quotation.TotalAfterTax.ToString();
            dr4["PQNo"]         = sqf.Quotation.QuotationNo;
            dr4["PQDate"]       = sqf.Quotation.QuotationDate.Date.ToString("dd/M/yyyy");
            dr4["ValidForDays"] = sqf.Quotation.ValidForDays;
            dt4.Rows.Add(dr4);

            ReportDataSource reportDataSource4 = new ReportDataSource();

            reportDataSource4.Name  = "PurchaseQuotationUniqueRecordDetailsDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource4.Value = dt4;
            // company details
            /*****Define column*****/
            DataTable dt1 = new DataTable();

            dt1.Columns.Add(new DataColumn("CompanyName", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyLogo", typeof(byte[])));
            dt1.Columns.Add(new DataColumn("CompanyRegNumber", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyGstNumber", typeof(string)));
            dt1.Columns.Add(new DataColumn("Telephone", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyFax", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyEmail", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine1", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToAddressLine2", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToCity", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToState", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToCountary", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyBillToPostCode", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToPostCode", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToLine1", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToLine2", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToCity", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToState", typeof(string)));
            dt1.Columns.Add(new DataColumn("CompanyShipToCountary", typeof(string)));
            /*****End  column*****/
            /*****data part*******/

            DataRow dr1 = dt1.NewRow();

            dr1["CompanyName"]               = sqf.Quotation.CompanyName;
            dr1["CompanyLogo"]               = sqf.Quotation.CompanyLogo;
            dr1["CompanyRegNumber"]          = sqf.Quotation.CompanyRegNumber;
            dr1["CompanyGstNumber"]          = sqf.Quotation.CompanyGstNumber;
            dr1["Telephone"]                 = sqf.Quotation.Telephone;
            dr1["CompanyFax"]                = sqf.Quotation.CompanyFax;
            dr1["CompanyEmail"]              = sqf.Quotation.CompanyEmail;
            dr1["CompanyBillToAddressLine1"] = sqf.Quotation.CompanyBillToAddressLine1;
            dr1["CompanyBillToAddressLine2"] = sqf.Quotation.CompanyBillToAddressLine2;
            dr1["CompanyBillToCity"]         = sqf.Quotation.CompanyBillToCity;
            dr1["CompanyBillToState"]        = sqf.Quotation.CompanyBillToState;
            dr1["CompanyBillToCountary"]     = sqf.Quotation.CompanyBillToCountary;
            dr1["CompanyBillToPostCode"]     = sqf.Quotation.CompanyBillToPostCode;
            dr1["CompanyShipToLine1"]        = sqf.Quotation.CompanyShipToAddressLine1;
            dr1["CompanyShipToLine2"]        = sqf.Quotation.CompanyShipToAddressLine2;
            dr1["CompanyShipToCity"]         = sqf.Quotation.CompanyShipToCity;
            dr1["CompanyShipToState"]        = sqf.Quotation.CompanyShipToState;
            dr1["CompanyShipToCountary"]     = sqf.Quotation.CompanyShipToCountary;
            dr1["CompanyShipToPostCode"]     = sqf.Quotation.CompanyShipToPostCode;

            dt1.Rows.Add(dr1);
            /*****data part*******/
            ReportDataSource reportDataSource1 = new ReportDataSource();

            reportDataSource1.Name  = "CompanyDetailsDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource1.Value = dt1;
            // end of company details

            //Customer Details
            /****column defn**/
            DataTable dt2 = new DataTable();

            dt2.Columns.Add(new DataColumn("SupplierName", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToLine1", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToLine2", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToCity", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToState", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToCountary", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierBillToPostCode", typeof(string)));
            dt2.Columns.Add(new DataColumn("SupplierTelephone", typeof(string)));
            /****end column defn**/
            /**data****/
            DataRow dr2 = dt2.NewRow();

            dr2["SupplierName"]           = sqf.Quotation.SupplierName;
            dr2["SupplierBillToLine1"]    = sqf.Quotation.SupplierBillAddress1;
            dr2["SupplierBillToLine2"]    = sqf.Quotation.SupplierBillAddress2;
            dr2["SupplierBillToCity"]     = sqf.Quotation.SupplierBillAddressCity;
            dr2["SupplierBillToState"]    = sqf.Quotation.SupplierBillAddressState;
            dr2["SupplierBillToCountary"] = sqf.Quotation.SupplierBillAddressCountary;
            dr2["SupplierBillToPostCode"] = sqf.Quotation.SupplierBillPostCode;
            dr2["SupplierTelephone"]      = sqf.Quotation.SupplierTelephone;

            /**end data****/
            dt2.Rows.Add(dr2);
            ReportDataSource reportDataSource2 = new ReportDataSource();

            reportDataSource2.Name  = "SupplierDetailsDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource2.Value = dt2;
            //End Customer Details

            //option
            DataTable dt3 = new DataTable();

            dt3.Columns.Add(new DataColumn("CurrencyCode", typeof(string)));
            DataRow dr3 = dt3.NewRow();

            dr3["CurrencyCode"] = sqf.Quotation.CurrencyCode;
            dt3.Rows.Add(dr3);

            ReportDataSource reportDataSource3 = new ReportDataSource();

            reportDataSource3.Name  = "OptionsDetailsDataSet"; // Name of the DataSet we set in .rdlc
            reportDataSource3.Value = dt3;
            //end options
            string exefolder  = System.Windows.Forms.Application.StartupPath;
            string reportPath = System.IO.Path.Combine(exefolder, @"PurchaseQuotation.rdlc");

            reportViewer9.LocalReport.ReportPath = reportPath;
            //D:\DayUser\src\SAS - NEW\Client\SASClient\Reports\ReportsRdlc
            reportViewer9.LocalReport.DataSources.Clear();
            reportViewer9.LocalReport.DataSources.Add(reportDataSource);
            reportViewer9.LocalReport.DataSources.Add(reportDataSource1);
            reportViewer9.LocalReport.DataSources.Add(reportDataSource2);
            reportViewer9.LocalReport.DataSources.Add(reportDataSource3);
            reportViewer9.LocalReport.DataSources.Add(reportDataSource4);
            reportViewer9.RefreshReport();
            // this.reportViewer1.Width = 75;
        }
示例#17
0
        public void GetPurchaseQuotation(string pqNo)
        {
            // Mouse.OverrideCursor = Cursors.Wait;
            PurchaseQuotationForm pqf = pqRepository.GetPurchaseQuotation(pqNo);

            this.ID                 = pqf.Quotation.ID;
            this.QuotationNo        = pqf.Quotation.QuotationNo;
            this.QuotationDate      = pqf.Quotation.QuotationDate;
            this.ValidForDays       = pqf.Quotation.ValidForDays;
            this.SelectedSupplierID = pqf.Quotation.SupplierID;
            //if (this.SelectedSupplierID > 0)
            //{
            //    GetSupplierDetails();
            //}

            this.TermsAndConditions = pqf.Quotation.TermsAndConditions;

            this.TotalBeforeTax    = pqf.Quotation.TotalBeforeTax;
            this.TotalTax          = pqf.Quotation.TotalTax;
            this.TotalAfterTax     = pqf.Quotation.TotalAfterTax;
            this.TotalBeforeTaxStr = Convert.ToString(this.TotalBeforeTax);
            this.TotalTaxStr       = Convert.ToString(TotalTax);
            this.TotalAfterTaxStr  = Convert.ToString(TotalAfterTax);

            if (pqf.Quotation.ExcIncGST == true)
            {
                ExcludingTax = false;
                IncludingTax = true;
                //  PQDEntity.GSTRate = 0;
            }
            else
            {
                ExcludingTax = true;
                IncludingTax = false;
                // PQDEntity.GSTRate = TaxRate;
            }

            this.PQ_Conv_to_PO = pqf.Quotation.PQ_Conv_to_PO;
            this.PQ_Conv_to_PI = pqf.Quotation.PQ_Conv_to_PI;

            if (PQ_Conv_to_PO == true || PQ_Conv_to_PI == true)
            {
                AllFieldsReadonly = true;
                AllFieldsEnabled  = false;
            }
            else
            {
                AllFieldsReadonly  = false;
                AllFieldsEnabled   = true;
                LstSuppliers       = supplierRepository.GetAllSupplier().Where(s => s.IsInActive != "Y").ToList();
                ProductAndServices = ProductAndServices.OrderBy(x => x.PSName).Where(x => x.IsInActive != "Y").ToObservable();
            }
            SupplierEnabled = false;


            this.PQDetailsEntity = new ObservableCollection <DataGridViewModel>();
            foreach (var item in pqf.QuotationDetails)
            {
                DataGridViewModel pqEntity = new DataGridViewModel(ProductList);
                pqEntity.SelectedPSID = Convert.ToString(item.PQNo);
                pqEntity.PandSCode    = item.PandSCode;
                pqEntity.PandSName    = item.PandSName;
                pqEntity.GSTRate      = Math.Round(Convert.ToDecimal(item.GSTRate), DecimalPlaces);
                pqEntity.GSTRateStr   = Convert.ToString(pqEntity.GSTRate) + "%";
                pqEntity.PQQty        = item.PQQty;
                pqEntity.PQPrice      = Convert.ToString(item.Price);
                pqEntity.PQDiscount   = item.PQDiscount;

                //  PQDEntity.GSTRate = item.GSTRate;
                pqEntity.PQAmount = item.PQAmount;

                PQDetailsEntity.Add(pqEntity);
            }
        }