int ISalesQuotationRepository.AddUpdateQuotation(SalesQuotationForm quotationData) { ISalesQuotationBL pqBL = new SalesQuotationBL(); int i = pqBL.AddUpdateQuotation(quotationData); return(i); }
public int ConvertToSalesInvoice(SalesQuotationForm quotationData) { ISalesQuotationDAL PQDAL = new SalesQuotationDAL(); return(PQDAL.ConvertToSalesInvoice(quotationData)); }
public int ConvertToSalesOrder(SalesQuotationForm pqForm) { ISalesQuotationDAL PQDAL = new SalesQuotationDAL(); return(PQDAL.ConvertToSalesOrder(pqForm)); }
public int UpdationQuotation(SalesQuotationForm quotationData) { ISalesQuotationDAL PQDAL = new SalesQuotationDAL(); return(PQDAL.UpdationQuotation(quotationData)); }
public int ConvertToSalesInvoice(SalesQuotationForm quotationData) { ISalesQuotationBL pqBL = new SalesQuotationBL(); return(pqBL.ConvertToSalesInvoice(quotationData)); }
public int ConvertToSalesOrder(SalesQuotationForm pqForm) { ISalesQuotationBL pqBL = new SalesQuotationBL(); return(pqBL.ConvertToSalesOrder(pqForm)); }
public int UpdationQuotation(SalesQuotationForm quotationData) { ISalesQuotationBL pqBL = new SalesQuotationBL(); return(pqBL.UpdationQuotation(quotationData)); }
public SalesQuotationForm GetPrintSalesQuotation(string pqno) { SalesQuotationForm pqf = new SalesQuotationForm(); try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { var pq = (from pqs in entities.SalesQuotations join Cus in entities.Customers on pqs.Cus_Id equals Cus.ID where pqs.SQ_No == pqno && (pqs.IsDeleted == false || pqs.IsDeleted == null) select new SalesQuotationEntity { ID = pqs.ID, CustomerID = pqs.Cus_Id, CustomerName = Cus.Cus_Name, CustomerBillAddress1 = Cus.Cus_Bill_to_line1, CustomerBillAddress2 = Cus.Cus_Bill_to_line2, CustomerBillAddressCity = Cus.Cus_Bill_to_city, CustomerBillAddressState = Cus.Cus_Bill_to_state, CustomerBillAddressCountary = Cus.Cus_Bill_to_country, CustomerBillPostCode = Cus.Cus_Bill_to_post_code, CustomerShipAddress1 = Cus.Cus_Ship_to_line1, CustomerShipAddress2 = Cus.Cus_Ship_to_line2, CustomerShipAddressCity = Cus.Cus_Ship_to_city, CustomerShipAddressState = Cus.Cus_Ship_to_state, CustomerShipAddressCountary = Cus.Cus_Ship_to_country, CustomerShipPostCode = Cus.Cus_Ship_to_post_code, CustomerTelephone = Cus.Cus_Telephone, QuotationNo = pqs.SQ_No, QuotationDate = pqs.SQ_Date, ValidForDays = pqs.SQ_Valid_for, TermsAndConditions = pqs.SQ_TandC, TotalBeforeTax = pqs.SQ_Tot_bef_Tax, TotalTax = pqs.SQ_GST_Amt, TotalAfterTax = pqs.SQ_Tot_aft_Tax, ExcIncGST = pqs.Exc_Inc_GST, SQ_Conv_to_SI = pqs.SQ_Conv_to_SI, SQ_Conv_to_SO = pqs.SQ_Conv_to_SO, SalesmanID = pqs.Salesman }).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 SalesQuotationEntity { 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, 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.CompanyEmail = company.CompanyEmail; pqf.Quotation.CompanyFax = company.CompanyFax; //end for comapany details //option details var optiondata = (from option in entities.Options select new SalesQuotationEntity { CurrencyCode = option.Currency_Code }).SingleOrDefault(); pqf.Quotation.CurrencyCode = optiondata.CurrencyCode; //end options details var pqd = (from pqds in entities.SalesQuotationDetails where pqds.SQ_ID == pq.ID select new SalesQuotationDetailEntity { ID = pqds.ID, SQID = pqds.SQ_ID, SQNo = pqds.SQ_No, PandSCode = pqds.PandS_Code, PandSName = pqds.PandS_Name, SQQty = pqds.SQ_Qty, Price = pqds.SQ_Price, SQDiscount = pqds.SQ_Discount, SQAmount = pqds.SQ_Amount, GSTRate = pqds.GST_Rate }).ToList <SalesQuotationDetailEntity>(); if (pqd != null) { pqf.QuotationDetails = pqd; } return(pqf); } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method is used to get Sales Quotation details /// </summary> /// <param name="pqId"></param> /// <returns></returns> public SalesQuotationForm GetSalesQuotation(string pqno) { SalesQuotationForm pqf = new SalesQuotationForm(); try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { var pq = (from pqs in entities.SalesQuotations where pqs.SQ_No == pqno && (pqs.IsDeleted == false || pqs.IsDeleted == null) select new SalesQuotationEntity { ID = pqs.ID, CustomerID = pqs.Cus_Id, QuotationNo = pqs.SQ_No, QuotationDate = pqs.SQ_Date, ValidForDays = pqs.SQ_Valid_for, TermsAndConditions = pqs.SQ_TandC, TotalBeforeTax = pqs.SQ_Tot_bef_Tax, TotalTax = pqs.SQ_GST_Amt, TotalAfterTax = pqs.SQ_Tot_aft_Tax, ExcIncGST = pqs.Exc_Inc_GST, SQ_Conv_to_SI = pqs.SQ_Conv_to_SI, SQ_Conv_to_SO = pqs.SQ_Conv_to_SO, SalesmanID = pqs.Salesman }).SingleOrDefault(); if (pq != null) { pqf.Quotation = pq; } var pqd = (from pqds in entities.SalesQuotationDetails where pqds.SQ_ID == pq.ID select new SalesQuotationDetailEntity { ID = pqds.ID, SQID = pqds.SQ_ID, SQNo = pqds.SQ_No, PandSCode = pqds.PandS_Code, PandSName = pqds.PandS_Name, SQQty = pqds.SQ_Qty, Price = pqds.SQ_Price, SQDiscount = pqds.SQ_Discount, SQAmount = pqds.SQ_Amount, GSTRate = pqds.GST_Rate }).ToList <SalesQuotationDetailEntity>(); if (pqd != null) { pqf.QuotationDetails = pqd; } return(pqf); } } catch (Exception ex) { throw ex; } }
/// <summary> /// This method is used to convert the Sales quotation to order /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int ConvertToSalesOrder(SalesQuotationForm quotationData) { int autoId = 0; //Add purchase quotation SalesOrder obj = new SalesOrder(); //obj.ID = quotationData.Quotation.ID; obj.Cus_Id = quotationData.Quotation.CustomerID; obj.SO_Date = quotationData.Quotation.QuotationDate; obj.SO_Del_Date = DateTime.Now; obj.SO_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.SO_No = "SO-" + (GetLastOrderNo() + 1); obj.SO_TandC = quotationData.Quotation.TermsAndConditions; obj.SO_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.SO_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.Salesman = quotationData.Quotation.SalesmanID; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { if (entities.SalesOrders.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.SQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.SalesOrders.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.SQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { SalesOrderDetail SQDetails; if (quotationData.QuotationDetails != null) { foreach (SalesQuotationDetailEntity SQDetailEntity in quotationData.QuotationDetails) { SQDetails = new SalesOrderDetail(); SQDetails.SO_ID = autoId; SQDetails.SO_No = SQDetailEntity.SQNo; SQDetails.PandS_Code = SQDetailEntity.PandSCode; SQDetails.PandS_Name = SQDetailEntity.PandSName; SQDetails.SO_Amount = SQDetailEntity.SQAmount; SQDetails.SO_Discount = SQDetailEntity.SQDiscount; SQDetails.SO_No = SQDetailEntity.SQNo; SQDetails.SO_Price = Convert.ToDecimal(SQDetailEntity.SQPrice); SQDetails.SO_Qty = SQDetailEntity.SQQty; SQDetails.GST_Code = SQDetailEntity.GSTCode; SQDetails.GST_Rate = SQDetailEntity.GSTRate; if (entities.SalesOrderDetails.AsNoTracking().FirstOrDefault(x => x.ID == SQDetailEntity.ID) == null) { entities.SalesOrderDetails.Add(SQDetails); entities.SaveChanges(); } else { entities.Entry(SQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } SalesQuotation objQ = entities.SalesQuotations.Where(e => e.SQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (objQ != null) { objQ.SQ_Conv_to_SO = true; objQ.Conv_to_No = obj.SO_No; objQ.ModifiedDate = DateTime.Now; entities.SaveChanges(); } } } return(autoId); } catch (Exception ex) { throw ex; } }
public int UpdationQuotation(SalesQuotationForm quotationData) { try { using (SASEntitiesEDM entities = new SASEntitiesEDM()) { SalesQuotation obj = entities.SalesQuotations.Where(e => e.SQ_No == quotationData.Quotation.QuotationNo ).SingleOrDefault(); if (obj != null) { //obj.ID = quotationData.Quotation.ID; obj.Cus_Id = quotationData.Quotation.CustomerID; // obj.SQ_Conv_to_SO = quotationData.Quotation.SQ_Conv_to_SO; // obj.SQ_Conv_to_SI = quotationData.Quotation.SQ_Conv_to_SI; obj.SQ_Date = Convert.ToDateTime(quotationData.Quotation.QuotationDateStr); obj.SQ_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.SQ_No = quotationData.Quotation.QuotationNo; obj.SQ_TandC = quotationData.Quotation.TermsAndConditions; obj.Salesman = quotationData.Quotation.SalesmanID; obj.SQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.SQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.SQ_Valid_for = quotationData.Quotation.ValidForDays; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.ModifiedDate = DateTime.Now; entities.SaveChanges(); } var objSales = entities.SalesQuotationDetails.Where (e => e.SQ_ID == obj.ID).ToList(); if (objSales != null) { foreach (var item in objSales) { entities.SalesQuotationDetails.Remove(item); entities.SaveChanges(); } } SalesQuotationDetail SQDetails; if (quotationData.QuotationDetails != null) { foreach (SalesQuotationDetailEntity SQDetailEntity in quotationData.QuotationDetails) { SQDetails = new SalesQuotationDetail(); SQDetails.SQ_ID = obj.ID; SQDetails.SQ_No = SQDetailEntity.SQNo; SQDetails.PandS_Code = SQDetailEntity.PandSCode; SQDetails.PandS_Name = SQDetailEntity.PandSName; SQDetails.SQ_Amount = SQDetailEntity.SQAmount; SQDetails.SQ_Discount = SQDetailEntity.SQDiscount; SQDetails.SQ_No = SQDetailEntity.SQNo; SQDetails.SQ_Price = Convert.ToDecimal(SQDetailEntity.SQPrice); SQDetails.SQ_Qty = SQDetailEntity.SQQty; SQDetails.GST_Code = SQDetailEntity.GSTCode; SQDetails.GST_Rate = SQDetailEntity.GSTRate; entities.SalesQuotationDetails.Add(SQDetails); entities.SaveChanges(); } } return(obj.ID); } } catch (Exception ex) { throw ex; } }
private void UserControl_LoadedSalesQuotation(object sender, RoutedEventArgs e) { //var a = _viewModel.PrintSalesQuotation(); SalesQuotationForm sqf = _viewModelSales.PrintSalesQuotation(); //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.SQQty; dr["Price"] = item.Price.ToString(); dr["Discount"] = item.SQDiscount; dr["Amount"] = item.SQAmount.ToString(); dr["Rate"] = item.GSTRate.ToString(); dt.Rows.Add(dr); } ReportDataSource reportDataSource = new ReportDataSource(); reportDataSource.Name = "SalesQuotationDetailsDataSet"; // 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("QuotationNo", typeof(string))); dt4.Columns.Add(new DataColumn("QuotationDate", 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["QuotationNo"] = sqf.Quotation.QuotationNo; dr4["QuotationDate"] = sqf.Quotation.QuotationDate.Date.ToString("dd/M/yyyy"); dr4["ValidForDays"] = sqf.Quotation.ValidForDays; dt4.Rows.Add(dr4); ReportDataSource reportDataSource4 = new ReportDataSource(); reportDataSource4.Name = "SalesQuotationUniqueRecordDataSet"; // 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))); /*****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; dt1.Rows.Add(dr1); /*****data part*******/ ReportDataSource reportDataSource1 = new ReportDataSource(); reportDataSource1.Name = "CompanyDetailDataSet"; // 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("CustomerName", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddress1", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddress2", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressCity", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressState", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillAddressCountary", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerBillPostCode", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddress1", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddress2", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressCity", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressState", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipAddressCountary", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerShipPostCode", typeof(string))); dt2.Columns.Add(new DataColumn("CustomerTelephone", typeof(string))); /****end column defn**/ /**data****/ DataRow dr2 = dt2.NewRow(); dr2["CustomerName"] = sqf.Quotation.CustomerName; dr2["CustomerBillAddress1"] = sqf.Quotation.CustomerBillAddress1; dr2["CustomerBillAddress2"] = sqf.Quotation.CustomerBillAddress2; dr2["CustomerBillAddressCity"] = sqf.Quotation.CustomerBillAddressCity; dr2["CustomerBillAddressState"] = sqf.Quotation.CustomerBillAddressState; dr2["CustomerBillAddressCountary"] = sqf.Quotation.CustomerBillAddressCountary; dr2["CustomerBillPostCode"] = sqf.Quotation.CustomerBillPostCode; dr2["CustomerShipAddress1"] = sqf.Quotation.CustomerShipAddress1; dr2["CustomerShipAddress2"] = sqf.Quotation.CustomerShipAddress2; dr2["CustomerShipAddressCity"] = sqf.Quotation.CustomerShipAddressCity; dr2["CustomerShipAddressState"] = sqf.Quotation.CustomerShipAddressState; dr2["CustomerShipAddressCountary"] = sqf.Quotation.CustomerShipAddressCountary; dr2["CustomerShipPostCode"] = sqf.Quotation.CustomerShipPostCode; dr2["CustomerTelephone"] = sqf.Quotation.CustomerTelephone; /**end data****/ dt2.Rows.Add(dr2); ReportDataSource reportDataSource2 = new ReportDataSource(); reportDataSource2.Name = "CustomerDetailsDataSet"; // 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 = "OptionDetailsDataSet"; // 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, @"SalesQuotation.rdlc"); reportViewer1.LocalReport.ReportPath = reportPath; // Path of the rdlc file reportViewer1.LocalReport.DataSources.Clear(); reportViewer1.LocalReport.DataSources.Add(reportDataSource); reportViewer1.LocalReport.DataSources.Add(reportDataSource1); reportViewer1.LocalReport.DataSources.Add(reportDataSource2); reportViewer1.LocalReport.DataSources.Add(reportDataSource3); reportViewer1.LocalReport.DataSources.Add(reportDataSource4); reportViewer1.RefreshReport(); // this.reportViewer1.Width = 75; }
/// <summary> /// This method is used to add or edit purchase quotation /// </summary> /// <param name="quotationData"></param> /// <returns></returns> public int AddUpdateQuotation(SalesQuotationForm quotationData) { int autoId = 0; //Add purchase quotation SalesQuotation obj = new SalesQuotation(); obj.ID = quotationData.Quotation.ID; obj.Cus_Id = quotationData.Quotation.CustomerID; obj.Salesman = quotationData.Quotation.SalesmanID; obj.SQ_Conv_to_SO = quotationData.Quotation.SQ_Conv_to_SO; obj.SQ_Conv_to_SI = quotationData.Quotation.SQ_Conv_to_SI; obj.SQ_Date = quotationData.Quotation.QuotationDate; obj.SQ_GST_Amt = Convert.ToDecimal(quotationData.Quotation.TotalTax); obj.SQ_No = quotationData.Quotation.QuotationNo; obj.SQ_TandC = quotationData.Quotation.TermsAndConditions; obj.SQ_Tot_aft_Tax = Convert.ToDecimal(quotationData.Quotation.TotalAfterTax); obj.SQ_Tot_bef_Tax = Convert.ToDecimal(quotationData.Quotation.TotalBeforeTax); obj.SQ_Valid_for = quotationData.Quotation.ValidForDays; obj.Exc_Inc_GST = quotationData.Quotation.ExcIncGST; obj.IsDeleted = false; try { using (SDNSalesDBEntities entities = new SDNSalesDBEntities()) { if (entities.SalesQuotations.AsNoTracking().FirstOrDefault(x => x.ID == quotationData.Quotation.ID) == null) { //obj.CreatedBy = quotationData.SQModel.CreatedBy; obj.CreatedDate = DateTime.Now; entities.SalesQuotations.Add(obj); entities.SaveChanges(); autoId = obj.ID; } else { // obj.ModifiedBy = quotationData.SQModel.ModifiedBy; obj.ModifiedDate = DateTime.Now; entities.Entry(obj).State = EntityState.Modified; autoId = entities.SaveChanges(); } if (autoId > 0) { SalesQuotationDetail SQDetails; if (quotationData.QuotationDetails != null) { foreach (SalesQuotationDetailEntity SQDetailEntity in quotationData.QuotationDetails) { SQDetails = new SalesQuotationDetail(); SQDetails.SQ_ID = autoId; SQDetails.SQ_No = SQDetailEntity.SQNo; SQDetails.PandS_Code = SQDetailEntity.PandSCode; SQDetails.PandS_Name = SQDetailEntity.PandSName; SQDetails.SQ_Amount = SQDetailEntity.SQAmount; SQDetails.SQ_Discount = SQDetailEntity.SQDiscount; SQDetails.SQ_No = SQDetailEntity.SQNo; SQDetails.SQ_Price = Convert.ToDecimal(SQDetailEntity.SQPrice); SQDetails.SQ_Qty = SQDetailEntity.SQQty; SQDetails.GST_Code = SQDetailEntity.GSTCode; SQDetails.GST_Rate = SQDetailEntity.GSTRate; if (entities.SalesQuotationDetails.AsNoTracking().FirstOrDefault(x => x.ID == SQDetailEntity.ID) == null) { entities.SalesQuotationDetails.Add(SQDetails); entities.SaveChanges(); } else { entities.Entry(SQDetails).State = EntityState.Modified; entities.SaveChanges(); } } } } } return(autoId); } catch (Exception ex) { throw ex; } }