public async Task <ActionResult> UpdateCompany(Company model) { if (ModelState.IsValid) { var company = await _companyRepository.GetCompanyWithPostsAsync(CurrentCompanyId); if (!CurrentCompany.Equals(model.CompanyName)) { var user = await _adminRepository.GetUserAsync(CurrentUser); user.CompanyName = model.CompanyName; await _adminRepository.UpdateUserAsync(user); company.CompanyName = model.CompanyName; var result = await _employeeRepository.UpdateAllEmployeesCompanyAsync(company, CurrentCompanyId); } company.CompanyAddress = model.CompanyAddress; company.CompanyPhone = model.CompanyPhone; await _companyRepository.UpdateCompanyAsync(company); return(RedirectToAction("Index", "AdminDetails", new { message = "Company details updated successfully." })); } return(RedirectToAction("Index", "AdminDetails", new { message = "Something went wrong!" })); }
/// <summary> /// ProcessNotResolved /// </summary> private void ProcessNotResolved() { if (!CompaniesProcessed.Any(s => s.ToUpper() == CurrentCompany.ToUpper())) { if (DataContext.Instance.NotResolved.Any(n => n.Company == CurrentCompany)) { LogCurrent.Add($"Company {CurrentCompany} exists already in database table NotResolved."); return; } DataContext.Instance.NotResolved.Add(new NotResolved { Company = CurrentCompany }); } CompaniesProcessed.Add(CurrentCompany); }
// ReportDocument crystalReport = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); //ReportDocument crystalReport = new ReportDocument(); //DataTable dtgrid = new DataTable(); //DataTable dtsalesreg = new DataTable(); //DataTable dtsalesdetailreg = new DataTable(); //DataTable dt1 = new DataTable(); //DataTable dt2 = new DataTable(); //DataTable dtservicegrid = new DataTable(); //Int64 SIID = 0; protected void Page_Load(object sender, EventArgs e) { id = Request.QueryString[0]; MODE = Request.QueryString[1]; // if (Session["Reportdoc"] != null) // { CrystalReportViewer2.ReportSource = Session["Reportdoc"]; CrystalReportViewer2.DisplayToolbar = true; /* * if (MODE == "inquiry") * { * try * { * SortedList sd1 = new SortedList(); * sd1.Add("@i_CompId", CurrentUser.CompId); * dtgrid = erp.GetDataTableSP("usp_Lead_List", sd1); * * * DataView DVReport; * DVReport = dtgrid.DefaultView; * crystalReport.Load(Server.MapPath("~/Reports/rptLeadRegister.rpt")); * crystalReport.Database.Tables[0].SetDataSource(dtgrid); * CurrentUser.AddReportParameters(crystalReport, dtgrid, true, "Inquiry Register", false, false, false, false, false); * CrystalReportViewer2.ReportSource = crystalReport; * * * } * catch (Exception ex) * { * * } * } * * if (MODE == "quotationreg") * { * try * { * SortedList sd1 = new SortedList(); * sd1.Add("@i_CompId", CurrentUser.CompId); * // dtgrid = erp.GetDataTableSP("usp_Quotation_List", sd1); * * DataView DVReport; * DVReport = dtgrid.DefaultView; * * crystalReport.Load(Server.MapPath("~/Reports/rptQuotationRegister.rpt")); * crystalReport.Database.Tables[0].SetDataSource(dtgrid); * CurrentUser.AddReportParameters(crystalReport, dtgrid, true, "Quotation Register", false, false, false, false, false); * CrystalReportViewer2.ReportSource = crystalReport; * } * catch (Exception ex) * { * * } * } */ #region Quotation if (MODE == "Quotation") { try { DataSet ds = new DataSet(); // LogoBind(dt); mpdfFile = Server.MapPath(@"\pdf\QuotationTAX.pdf"); // DataTable dtReport = new DataTable(); List <ParaList> para1 = new List <ParaList>() { new ParaList { Key = "@i_RecID", Value = id }, new ParaList { Key = "@i_CompId", Value = CurrentUser.CompId.ToString() }, }; ReportDocument crystalReport = new ReportDocument(); ds = crmclient.Select(para1, "rpt_Quotation"); DataSet dsTNC = new DataSet(); //para.Add("@i_RecID", id); //para.Add("@i_TNC_Sub", "Quotation"); //para.Add("@i_CompId", CurrentUser.CompId); List <ParaList> para2 = new List <ParaList>() { new ParaList { Key = "@i_RecID", Value = id }, new ParaList { Key = "@i_TNC_Sub", Value = "Quotation" }, new ParaList { Key = "@i_CompId", Value = CurrentUser.CompId.ToString() }, }; dsTNC = crmclient.Select(para2, "rpt_Quotation_TNC"); // erp.GetDataTableSP("rpt_Quotation_TNC", para); //crystalReport.Database.Tables[0].SetDataSource(ds); //crystalReport.Database.Tables[1].SetDataSource(dsTNC); // crystalReport.Load(Server.MapPath("~/Reports/rptCrystalReport.rpt")); crystalReport.Load(Server.MapPath("~/Reports/rptQuotationTAX.rpt")); crystalReport.Database.Tables[0].SetDataSource(ds.Tables[0]); crystalReport.Database.Tables[1].SetDataSource(dsTNC.Tables[0]); ExportOptions CrExportOptions; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = mpdfFile; CrExportOptions = crystalReport.ExportOptions;//Report document object has to be given here CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; CurrentCompany.AddReportParameters(crystalReport, ds, false, "rptCrystalReport", false, false, false, false, false); // crystalReport.Database.Tables[0].SetDataSource(ds); // CurrentUser.AddReportParameters(crystalReport, ds, true, "", false, true, true, true, true); CrystalReportViewer2.ReportSource = crystalReport; } catch (Exception exc) { throw exc; } } #endregion // ERPStoreProcedure erp = new ERPStoreProcedure(); // id = Request.QueryString[0]; // MODE = Request.QueryString[1]; // // if (Session["Reportdoc"] != null) // // { // CrystalReportViewer2.ReportSource = Session["Reportdoc"]; // CrystalReportViewer2.DisplayToolbar = true; // //ReportDocument crystalReport = new ReportDocument(); // //crystalReport.Load(Server.MapPath("~/Reports/rptAverage.rpt")); // //crystalReport.SetDataSource(Session["Reportdoc"]); // //CrystalReportViewer3.ReportSource = crystalReport; // if (MODE == "Customermailinglbl") // { // // SortedList sf = new SortedList(); // // sf.Add("@mode", "selectqry"); // // DataTable dt = erp.GetDataTableSP("[rpt_Customer_mail]", sf); // // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptCustomerMailingLabel.rpt")); // crystalReport.SetDataSource(Session["Reportdoc"]); // CrystalReportViewer2.ReportSource = crystalReport; // } // //if (MODE == "CustomerRegister1") // //{ // // //SortedList sf = new SortedList(); // // //sf.Add("@mode", "selectqry"); // // //DataTable dt = erp.GetDataTableSP("[usp_Customer_List]", sf); // // //// ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptCustomerRegister.rpt")); // // crystalReport.SetDataSource(Session["Reportdoc"]); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "VendorRegister1") // //{ // // //SortedList sf = new SortedList(); // // //sf.Add("@mode", "selectqry"); // // //DataTable dt = erp.GetDataTableSP("[rpt_Vendor_List]", sf); // // //// ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptVendorRegister.rpt")); // // crystalReport.SetDataSource(Session["Reportdoc"]); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "VendorMailingLable") // //{ // // //SortedList sf = new SortedList(); // // //sf.Add("@mode", "selectqry"); // // //DataTable dt = erp.GetDataTableSP("[rpt_Vendor_List]", sf); // // //// ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptVendorMailingLabel.rpt")); // // crystalReport.SetDataSource(Session["Reportdoc"]); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "CustomerPendingReminders") // //{ // // //SortedList sf = new SortedList(); // // //sf.Add("@mode", "selectqry"); // // //DataTable dt = erp.GetDataTableSP("[rpt_Vendor_List]", sf); // // //// ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptCustpendingReminder.rpt")); // // crystalReport.SetDataSource(Session["Reportdoc"]); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "Bookingslip") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@i_RecID", id); // // DataTable dt = erp.GetDataTableSP("[rpt_Driver_Duty_Voucher]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rpt_Booking_Slip.rpt")); // // TextObject T = (TextObject)crystalReport.ReportDefinition.Sections["Section3"].ReportObjects["txtkm"]; // // if (dt.Rows[0]["RatePerKMs"].ToString() == "1") // // { // // T.Text = "Rate per Km"; // // } // // if (dt.Rows[0]["RatePerKMs"].ToString() == "2") // // { // // T.Text = "Rate per Day"; // // } // // if (dt.Rows[0]["RatePerKMs"].ToString() == "3") // // { // // T.Text = "Fix Rate"; // // } // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "BookingRegister") // //{ // // //SortedList sf = new SortedList(); // // //sf.Add("@mode", "selectqry"); // // //DataTable dt = erp.GetDataTableSP("[usp_Booking_List]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptBookingReg.rpt")); // // crystalReport.SetDataSource(Session["Reportdoc"]); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "SalesVoucher") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@i_SaleID", id); // // DataTable dt = erp.GetDataTableSP("[rpt_Sale_Voucher]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptSalesVoucher.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "PaymentReg") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@mode", "selectqry"); // // DataTable dt = erp.GetDataTableSP("[usp_CustomerReceipt_List]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptDailyPaymentRegister.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "Vendorpayment") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@mode", "selectqry"); // // DataTable dt = erp.GetDataTableSP("[rpt_VendorPayment]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptVendorPaymentRegister.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "VendorRegister") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@mode", "selectqry"); // // DataTable dt = erp.GetDataTableSP("[usp_VendorPayment_List]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptVendorReg.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "AccountLedger") // //{ // // id = Request.QueryString[0]; // // MODE = Request.QueryString[1]; // // frmdt = DateTime.ParseExact(Request.QueryString[2], "yyyy-MM-dd", null); // // todate = DateTime.ParseExact(Request.QueryString[3], "yyyy-MM-dd", null); // // SortedList sd = new SortedList(); // // sd.Add("@i_AccountID", id); // // sd.Add("@i_FromDate", frmdt); // // sd.Add("@i_ToDate", todate); // // DataTable dt = erp.GetDataTableSP("rpt_AccountLedger", sd); // // //ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptLedger.rpt")); // // TextObject frm = (TextObject)crystalReport.ReportDefinition.ReportObjects["txtfrm"]; // // frm.Text = frmdt.ToString("dd/MM/yyyy"); // // TextObject to = (TextObject)crystalReport.ReportDefinition.ReportObjects["txtto"]; // // to.Text = todate.ToString("dd/MM/yyyy"); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "CartypeRegister") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@i_CarTypeID", id); // // DataTable dt = erp.GetDataTableSP("[rpt_Car_SaleList]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptCarTypeWiseRegister.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "LocationRegister") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@i_mode", ""); // // DataTable dt = erp.GetDataTableSP("[rpt_CountryStateCityArea]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptLocationReg.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // //if (MODE == "CustomerReg") // //{ // // SortedList sf = new SortedList(); // // sf.Add("@mode", "selectqry"); // // DataTable dt = erp.GetDataTableSP("[usp_CustomerReceipt_List]", sf); // // // ReportDocument crystalReport = new ReportDocument(); // // crystalReport.Load(Server.MapPath("~/Reports/rptCustomerReg.rpt")); // // crystalReport.SetDataSource(dt); // // CrystalReportViewer2.ReportSource = crystalReport; // //} // if (MODE == "inquiry") // { // try // { // SortedList sd1 = new SortedList(); // sd1.Add("@i_CompId", CurrentUser.CompId); // dtgrid = erp.GetDataTableSP("usp_Lead_List", sd1); // DataView DVReport; // DVReport = dtgrid.DefaultView; // crystalReport.Load(Server.MapPath("~/Reports/rptLeadRegister.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtgrid); // CurrentUser.AddReportParameters(crystalReport, dtgrid, true, "Inquiry Register", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception ex) // { // } // } // if (MODE == "quotationreg") // { // try // { // SortedList sd1 = new SortedList(); // sd1.Add("@i_CompId", CurrentUser.CompId); // dtgrid = erp.GetDataTableSP("usp_Quotation_List", sd1); // DataView DVReport; // DVReport = dtgrid.DefaultView; // crystalReport.Load(Server.MapPath("~/Reports/rptQuotationRegister.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtgrid); // CurrentUser.AddReportParameters(crystalReport, dtgrid,true, "Quotation Register", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception ex) // { // } // } // if (MODE == "salesreg") // { // try // { // SortedList sdreg = new SortedList(); // // sdreg.Add("@i_FYID", CurrentUser.FYID); // sdreg.Add("@i_CompId", CurrentUser.CompId); // // sdreg.Add("@i_UserId", CurrentUser.UserID); // dtsalesreg = erp.GetDataTableSP("rpt_SalesInvoiceRegister", sdreg); // // dtsalesreg = erp.GetDataTableSP("usp_SalesInvoice_List", sdreg); // // DataView DVReport; // //DVReport = dtsalesreg.DefaultView; // crystalReport.Load(Server.MapPath("~/Reports/rptSalesInvoiceRegister-GST.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtsalesreg); // CurrentUser.AddReportParameters(crystalReport, dtsalesreg,true , "SalesInvoice GST Register", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception ex) // { // } // } // if (MODE == "salesregdetail") // { // try // { // SortedList sd1 = new SortedList(); // sd1.Add("@i_SIID", SIID); // dtsalesdetailreg = erp.GetDataTableSP("rpt_SalesInvoiceDetail", sd1); // DataView DVReport; // DVReport = dtsalesdetailreg.DefaultView; // crystalReport.Load(Server.MapPath("~/Reports/rptSalesInvoiceRegisterWithDetail.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtsalesdetailreg); // CurrentUser.AddReportParameters(crystalReport, dtsalesdetailreg,true , "SalesInvoice Detail Register", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception ex) // { // } // } // if (MODE == "Sales") // { // try // { // SortedList sf = new SortedList(); // sf.Add("@i_RecID",id); // sf.Add("@i_CompId", CurrentUser.CompId); // DataTable dt = erp.GetDataTableSP("rpt_SalesInvoice", sf); // //SortedList para2 = new SortedList(); // //para2.Add("@i_CompId", CurrentUser.CompId.ToString()); // //DataTable dtCompany = erp.GetDataTableSP("rpt_Company", para2); // SortedList para = new SortedList(); // para.Add("@i_RecID", id); // para.Add("@i_TNC_Sub", "Sales"); // para.Add("@i_CompId", CurrentUser.CompId); // DataTable dtTNC = erp.GetDataTableSP("rpt_Sales_TNC", para); // //DataTable dtLogo = new DataTable(); // // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptSalesInvoice.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dt); // crystalReport.Subreports[0].Database.Tables[0].SetDataSource(dtTNC); // CurrentUser.AddReportParameters(crystalReport, dt,true, "TAX INVOICE", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception exc) // { // } // } // if (MODE == "Performa") // { // try // { // SortedList sf1 = new SortedList(); // sf1.Add("@i_RecID", id); // sf1.Add("@i_CompId", CurrentUser.CompId); // DataTable dt1 = erp.GetDataTableSP("rpt_SalesInvoice", sf1); // //SortedList para2 = new SortedList(); // //para2.Add("@i_CompId", CurrentUser.CompId.ToString()); // //DataTable dtCompany = erp.GetDataTableSP("rpt_Company", para2); // SortedList para1 = new SortedList(); // para1.Add("@i_RecID", id); // para1.Add("@i_TNC_Sub", "Sales"); // para1.Add("@i_CompId", CurrentUser.CompId); // DataTable dtTNC1 = erp.GetDataTableSP("rpt_Sales_TNC", para1); // //DataTable dtLogo = new DataTable(); // // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptSalesInvoice.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dt1); // crystalReport.Subreports[0].Database.Tables[0].SetDataSource(dtTNC1); // CurrentUser.AddReportParameters(crystalReport, dt1,true , "PERFORMA INVOICE", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception exc) // { // } // } // if (MODE == "Deliverychalan") // { // try // { // SortedList sf2 = new SortedList(); // sf2.Add("@i_RecID", id); // sf2.Add("@i_CompId", CurrentUser.CompId); // DataTable dt2 = erp.GetDataTableSP("rpt_SalesInvoice", sf2); // //SortedList para2 = new SortedList(); // //para2.Add("@i_CompId", CurrentUser.CompId.ToString()); // //DataTable dtCompany = erp.GetDataTableSP("rpt_Company", para2); // SortedList para2 = new SortedList(); // para2.Add("@i_RecID", id); // para2.Add("@i_TNC_Sub", "Sales"); // para2.Add("@i_CompId", CurrentUser.CompId); // DataTable dtTNC2 = erp.GetDataTableSP("rpt_Sales_TNC", para2); // //DataTable dtLogo = new DataTable(); // // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptDeliveryChallan.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dt2); // crystalReport.Subreports[0].Database.Tables[0].SetDataSource(dtTNC2); // CurrentUser.AddReportParameters(crystalReport, dt2,true, "DELIVERY CHALLAN", false, false, false, false, false); // CurrentUser.AddExtraParameter(crystalReport); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception exc) // { // } // } // if (MODE == "servicereg") // { // try // { // SortedList sd1 = new SortedList(); // sd1.Add("@i_CompId", CurrentUser.CompId); // dtservicegrid = erp.GetDataTableSP("usp_ServiceModule_List", sd1); // DataView DVReport; // DVReport = dtservicegrid.DefaultView; // crystalReport.Load(Server.MapPath("~/Reports/rptServiceRegister-GST.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtservicegrid); // CurrentUser.AddReportParameters(crystalReport, dtservicegrid, true, "SalesInvoice Register", false, false, false, false,false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception ex) // { // } // } // if (MODE == "Service") // { // try // { // SortedList sf4 = new SortedList(); // sf4.Add("@i_RecID", id); // sf4.Add("@i_CompId", CurrentUser.CompId); // DataTable dtservice = erp.GetDataTableSP("rpt_ServiceInvoice", sf4); // SortedList para2 = new SortedList(); // para2.Add("@i_CompId", CurrentUser.CompId.ToString()); // DataTable dtCompany = erp.GetDataTableSP("rpt_Company", para2); // SortedList para4 = new SortedList(); // para4.Add("@i_RecID", id); // para4.Add("@i_TNC_Sub", "Service"); // para4.Add("@i_CompId", CurrentUser.CompId); // DataTable dtTNC3 = erp.GetDataTableSP("rpt_Service_TNC", para4); // //DataTable dtLogo = new DataTable(); // // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptServiceInvoice.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtservice); // crystalReport.Subreports[0].Database.Tables[0].SetDataSource(dtTNC3); // CurrentUser.AddReportParameters(crystalReport, dtservice,true , "Service Invoice", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception exc) // { // } // } // if (MODE == "serviceorder") // { // try // { // SortedList sf3 = new SortedList(); // sf3.Add("@i_RecID", id); // DataTable dtservice = erp.GetDataTableSP("rpt_Service_Order", sf3); // //SortedList para2 = new SortedList(); // //para2.Add("@i_CompId", CurrentUser.CompId.ToString()); // //DataTable dtCompany = erp.GetDataTableSP("rpt_Company", para2); // //para3.Add("@i_TNC_Sub", "Service"); // //para3.Add("@i_CompId", CurrentUser.CompId); // //DataTable dtTNC3 = erp.GetDataTableSP("rpt_Service_TNC", para3); // //DataTable dtLogo = new DataTable(); // ReportDocument crystalReport = new ReportDocument(); // crystalReport.Load(Server.MapPath("~/Reports/rptServiceOrder.rpt")); // crystalReport.Database.Tables[0].SetDataSource(dtservice); // //crystalReport.Subreports[0].Database.Tables[0].SetDataSource(dtTNC3); // CurrentUser.AddReportParameters(crystalReport, dtservice,true , "Service Order", false, false, false, false, false); // CrystalReportViewer2.ReportSource = crystalReport; // } // catch (Exception exc) // { // } // } //} }
public bool Connect() { string licenseAddress = ConfigurationManager.AppSettings["LicenseServer"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany licenseAddress is Null"); return(false); } string companyDB = ConfigurationManager.AppSettings["CompanyDB"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany CompanyDB is Null"); return(false); } string dbUser = ConfigurationManager.AppSettings["DbUserName"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany DbUserName is Null"); return(false); } string dbPwd = ConfigurationManager.AppSettings["DbPassword"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany DbPassword is Null"); return(false); } string language = ConfigurationManager.AppSettings["Language"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany Language is Null"); return(false); } string b1User = ConfigurationManager.AppSettings["UserName"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany UserName is Null"); return(false); } string b1Pwd = ConfigurationManager.AppSettings["Password"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany Password is Null"); return(false); } string dbServerType = ConfigurationManager.AppSettings["DbServerType"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany DbServerType is Null"); return(false); } string serverAddress = ConfigurationManager.AppSettings["Server"]; if (string.IsNullOrEmpty(licenseAddress)) { LogHelper.Error("GSCompany Server is Null"); return(false); } CurrentCompany.CompanyDB = companyDB; CurrentCompany.DbServerType = (SAPbobsCOM.BoDataServerTypes) int.Parse(dbServerType); CurrentCompany.LicenseServer = licenseAddress; CurrentCompany.DbUserName = dbUser; CurrentCompany.DbPassword = dbPwd; CurrentCompany.language = (SAPbobsCOM.BoSuppLangs) int.Parse(language); CurrentCompany.UserName = b1User; CurrentCompany.Password = b1Pwd; CurrentCompany.Server = serverAddress; if (CurrentCompany.Connect() == 0) { return(true); } LogHelper.Error(string.Format("Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription())); return(false); }
public void DisConnect() { CurrentCompany.Disconnect(); }
public bool SaveSalesOrderDraft(OM_SalesOrderDataObject salesOrder, OM_B1InfomationDTO b1Informaion) { if (!this.Connect()) { return(false); } SAPbobsCOM.Recordset oRs = CurrentCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); LogHelper.Info(string.Format("GSCompany via script is: select * from ODRF where ObjType='17' and Address2='{0}'", salesOrder.Guid)); oRs.DoQuery(string.Format("select * from ODRF where ObjType='17' and Address2='{0}'", salesOrder.Guid)); if (oRs.RecordCount > 0) { b1Informaion.GSCode = 200; b1Informaion.GSStatus = OMDocStatus.Commit; b1Informaion.JFZMessage = string.Format("This Order-{0}-{1} has commit to SAP", salesOrder.Guid, oRs.Fields.Item("DocEntry").Value); LogHelper.Info(string.Format("JFZCompnay Document has exist, and the DocEntry={0},DocNum={1}", oRs.Fields.Item("DocEntry").Value, oRs.Fields.Item("DocNum").Value)); return(true); } SAPbobsCOM.Documents oSaleOrder = CurrentCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts); try { oSaleOrder.Address2 = salesOrder.Guid; oSaleOrder.CardCode = salesOrder.CardCode; oSaleOrder.CardName = salesOrder.CardName; oSaleOrder.Comments = "营销远程平台对接生成"; if (salesOrder.DocDate == null) { oSaleOrder.DocDate = DateTime.Now; oSaleOrder.DocDueDate = DateTime.Now; } else if (salesOrder.DocDueDate == null) { oSaleOrder.DocDueDate = DateTime.Now; } else { oSaleOrder.DocDate = (DateTime)salesOrder.DocDate; oSaleOrder.DocDueDate = (DateTime)salesOrder.DocDueDate; } oSaleOrder.DocObjectCode = SAPbobsCOM.BoObjectTypes.oOrders; foreach (var item in salesOrder.SalesOrderLine) { oSaleOrder.Lines.ItemCode = item.ItemCode; oSaleOrder.Lines.ItemDescription = item.ItemName; oSaleOrder.Lines.Quantity = Convert.ToDouble(item.Quantity); oSaleOrder.Lines.Price = Convert.ToDouble(item.InnerPrice); oSaleOrder.Lines.Add(); } if (oSaleOrder.Add() == 0) { b1Informaion.GSCode = 200; b1Informaion.GSStatus = OMDocStatus.Commit; b1Informaion.GSMessage = (string.Format("高山药业:{0},订单号:{1}对接成功,update ", salesOrder.CardCode, salesOrder.DocEntry)); LogHelper.Info(string.Format("高山药业:{0},订单号:{1}对接成功,update ", salesOrder.CardCode, salesOrder.DocEntry)); return(true); } b1Informaion.GSCode = -1; b1Informaion.GSStatus = OMDocStatus.Unchange; b1Informaion.GSMessage = string.Format("GSSalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription()); LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription())); return(false); } catch (Exception ex) { b1Informaion.GSCode = -1; b1Informaion.GSStatus = OMDocStatus.Unchange; b1Informaion.GSMessage = string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription()); LogHelper.Error(string.Format("SalseOrderAdd----Error Code:{0}----Error Descride:{1}", _Company.GetLastErrorCode().ToString(), _Company.GetLastErrorDescription())); return(false); } finally { DisConnect(); } }