public static string GetUniqueDatabaseId() { string str = "Select AccP_Database From AccPacConfig where AccP_Deleted is NULL"; QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str; querySelect.ExecuteReader(); string str1 = ""; int num = 0; while (!querySelect.Eof()) { num++; str1 = querySelect.FieldValue("AccP_database"); if (num > 1) { break; } querySelect.Next(); } if (num != 1) { return(""); } return(str1); }
public override void AfterSave(EntryGroup screen) { //Record FollRec = base.FindCurrentRecord("Follow"); //screen.Fill(FollRec); //FollRec.SaveChanges(); Record foll = screen.getRecord; string id = foll.RecordId.ToString(); string compid = foll.GetFieldAsString("foll_companyid"); string date = foll.GetFieldAsDateTime("foll_followdate").ToString("yyyy-MM-dd"); QuerySelect qs = this.GetQuery(); qs.SQLCommand = "select comp_shortname from Company where comp_companyid = " + compid; qs.ExecuteReader(); string code = qs.FieldValue("comp_shortname"); string name = code + "/" + date; qs.SQLCommand = "update Follow set foll_Name = '" + name + "' where foll_followid =" + id; qs.ExecuteNonQuery(); string foll_createoppo = foll.GetFieldAsString("foll_createoppo"); if (foll_createoppo.ToLower() == "y") { Dispatch.Redirect(Url("1190")); } else { Dispatch.Redirect(UrlDotNet("Company", "RunFollowList") + "&123&comp_companyid=" + compid + "&J=Follow&T=Company"); } }
public override void BuildContents() { try { /*查找当前数据库中该产品最新价格 *必须在该条记录保存前查询 */ QuerySelect qs = this.GetQuery(); string productinfoid = Dispatch.ContentField("qtdt_productinfoid"); double thislocalaount = Convert.ToDouble(Dispatch.ContentField("qtdt_localeamount")); double thisforeignamount = Convert.ToDouble(Dispatch.ContentField("qtdt_foreignamount")); string select = @"select qtdt_localeamount,qtdt_foreignamount,quta_opportunityid from QuotationDetail where qtdt_UpdatedDate = (select MAX( qtdt_UpdatedDate) from QuotationDetail left join Quotation on quta_QuotationID = qtdt_qutaid left join Opportunity on Oppo_OpportunityId = quta_opportunityid where qtdt_productinfoid = " + productinfoid + @" and quta_opportunityid = 12 and Oppo_Deleted is null and quta_Deleted is null and qtdt_Deleted is null) "; qs.SQLCommand = select; qs.ExecuteReader(); double qtdt_localeamount = 0, qtdt_foreignamount = 0; string quta_opportunityid = string.Empty; if (!qs.Eof()) { qtdt_localeamount = Convert.ToDouble(qs.FieldValue("qtdt_localeamount")); qtdt_foreignamount = Convert.ToDouble(qs.FieldValue("qtdt_foreignamount")); quta_opportunityid = qs.FieldValue("quta_opportunityid"); } double resultlocal = thislocalaount - qtdt_localeamount; double resultforeign = thisforeignamount = qtdt_foreignamount; string updatesql = @"update Opportunity set oppo_qutaprice = ISNULL(oppo_qutaprice,0) + " + resultlocal + " where Oppo_OpportunityId =" + quta_opportunityid; qs.SQLCommand = updatesql; qs.ExecuteNonQuery(); } catch (Exception ex) { AddError(ex.Message); } }
public static string GetConfigField(string field, string companyDatabase) { string str = string.Format("SELECT * \n FROM AccpacConfig \n WHERE accp_deleted IS NULL \n AND accp_database='{0}'", companyDatabase); QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str; QuerySelect querySelect1 = querySelect; querySelect1.ExecuteReader(); if (querySelect1.Eof()) { return(string.Empty); } return(querySelect1.FieldValue(field)); }
public static string NewOpportunity(string companyId, int userId, string personId) { if (string.IsNullOrEmpty(personId)) { personId = "0"; } Record record = new Record("Opportunity"); record.SetField("Oppo_Stage", "Lead"); record.SetField("Oppo_Status", "In Progress"); record.SetField("Oppo_PrimaryCompanyId", companyId); record.SetField("Oppo_PrimaryPersonId", personId); record.SetField("Oppo_AssignedUserId", userId); record.SetField("Oppo_Source", "Telephone"); record.SetField("Oppo_Certainty", 0); int num = 1; string str = "SELECT * FROM Custom_SysParams WHERE Parm_Name='BaseCurrency' AND Parm_Deleted IS NULL"; QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str; QuerySelect querySelect1 = querySelect; querySelect1.ExecuteReader(); if (!querySelect1.Eof()) { num = Convert.ToInt32(querySelect1.FieldValue("Parm_Value")); } record.SetField("oppo_forecast_CID", num); record.SetField("oppo_forecast", 0); record.SetField("oppo_total_CID", num); record.SetField("oppo_total", 0); record.SetField("oppo_QuotePending_CID", num); record.SetField("oppo_QuotePending", 0); record.SetField("oppo_totalorders_CID", num); record.SetField("oppo_totalorders", 0); record.SetField("oppo_totalshipments_CID", num); record.SetField("oppo_totalshipments", 0); record.SetField("oppo_totalinvoices_CID", num); record.SetField("oppo_totalinvoices", 0); record.SetField("Oppo_Opened", DateTime.Now); record.SetField("oppo_targetclose", DateTime.Now.AddDays(30)); record.SaveChanges(); record.SetWorkflowInfo("Opportunity Workflow", "Lead"); record.SetField("Oppo_Description", record.RecordId); record.SetField("oppo_note", record.RecordId); record.SaveChanges(); return(string.Format("{0},{1},{2},{3}", new object[] { record.RecordId, record.RecordId, companyId, personId })); }
public override void AfterSave(Sage.CRM.Controls.EntryGroup screen) { Record Rec = screen.getRecord; screen.Fill(Rec); Rec.SaveChanges(); string startdate = Rec.GetFieldAsDateTime("mopl_startdate").ToString("yyyy-MM-dd"); string userid = Rec.GetFieldAsString("mopl_userid"); QuerySelect qs = this.GetQuery(); qs.SQLCommand = "select user_LastName from Users where user_userid=" + userid; qs.ExecuteReader(); string username = qs.FieldValue("user_LastName"); string name = username + "/" + startdate; qs.SQLCommand = "Update MonthPlan set mopl_Name ='" + name + "' where mopl_MonthPlanid =" + Rec.RecordId.ToString(); qs.ExecuteNonQuery(); base.AfterSave(screen); }
public static string BuildDatabaseDropDwon(bool bSynchronized) { string str = "<SELECT CLASS=EDIT SIZE=1 ID='dropdownDatabaseId' NAME='database' style='width:200px; height:25px'>"; string str1 = " Select * From AccPacConfig where AccP_Deleted is NULL order by AccP_database"; QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str1; querySelect.ExecuteReader(); while (!querySelect.Eof()) { string str2 = (querySelect.FieldValue("accp_default") == "Y" ? " SELECTED" : ""); string str3 = querySelect.FieldValue("accp_description"); string str4 = querySelect.FieldValue("AccP_database"); string str5 = "<OPTION VALUE='{0}'{1}>{2}</OPTION>"; str = string.Concat(str, string.Format(str5, str4, str2, str3)); querySelect.Next(); } str = string.Concat(str, "</SELECT></br>"); return(str); }
public override void AfterSave(Sage.CRM.Controls.EntryGroup screen) { Record order = screen.getRecord; QuerySelect s = new QuerySelect(); string prefix = "M" + DateTime.Now.ToString("yyyyMMdd"); s.SQLCommand = "select count(*) as count from MarketInfo where maif_name like '" + prefix + "%'"; s.ExecuteReader(); int cnt = 0; if (!s.Eof()) { cnt = Convert.ToInt32(s.FieldValue("count")); } string code = string.Empty; code = prefix + (cnt + 1).ToString().PadLeft(2, '0'); order.SetField("maif_name", code); order.SaveChanges(); base.AfterSave(screen); }
public static string GetOpportunityTabInfo(string logonUser, string companyDb, string compId, string emailSubject) { string configField = CommonPage.GetConfigField("AccP_CompEmail", companyDb); CommonPage.GetConfigField("AccP_ServerName", companyDb); string str = ""; string str1 = string.Concat("Select emai_emailaddress as email from Email e inner join EmailLink el on e.Emai_EmailId = el.ELink_EmailId where el.ELink_EntityId = 5 and el.ELink_RecordID = ", Convert.ToInt32(compId)); QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str1; querySelect.ExecuteReader(); if (!querySelect.Eof()) { str = querySelect.FieldValue("email"); } string str2 = string.Concat("Select Oppo_OpportunityId, Oppo_Description, Oppo_PrimaryCompanyId, Oppo_PrimaryPersonId From Opportunity where Oppo_Status = 'In Progress' and Oppo_PrimaryCompanyId = ", Convert.ToInt32(compId)); string str3 = string.Format("{0}|{1}|{2}|{3}&", new object[] { logonUser, str, configField, emailSubject }); QuerySelect querySelect1 = new QuerySelect(); querySelect1.SQLCommand = str2; querySelect1.ExecuteReader(); while (!querySelect1.Eof()) { string str4 = querySelect1.FieldValue("Oppo_OpportunityId"); string str5 = querySelect1.FieldValue("Oppo_Description"); string str6 = querySelect1.FieldValue("Oppo_PrimaryCompanyId"); string str7 = querySelect1.FieldValue("Oppo_PrimaryPersonId"); if (string.IsNullOrEmpty(str7)) { str7 = "0"; } string str8 = string.Format("{0},{1},{2},{3}", new object[] { str4, str5, str6, str7 }); str3 = string.Concat(str3, str8, "|"); querySelect1.Next(); } str3 = str3.Substring(0, str3.Length - 1); return(string.Format("<input id='txtOpportunityID' name='txtOpportunityID' type='hidden' value='{0}'>", str3)); }
public override void AfterSave(Sage.CRM.Controls.EntryGroup screen) { //维修单编码规则 R+年月日+2码流水 Record order = screen.getRecord; QuerySelect s = new QuerySelect(); string username = CurrentUser.UserName; string prefix = "R" + DateTime.Now.ToString("yyyyMMDD"); s.SQLCommand = "select count(*) as count from Maintenance where mate_name like '" + prefix + "%'"; s.ExecuteReader(); int cnt = 0; if (!s.Eof()) { cnt = Convert.ToInt32(s.FieldValue("count")); } string code = string.Empty; code = prefix + (cnt + 1).ToString().PadLeft(2, '0'); order.SetField("mate_name", code); order.SaveChanges(); base.AfterSave(screen); }
public override void BuildContents() { try { AddContent(HTML.Form()); EntryGroup qutacompEntry = new EntryGroup("QuotationCompanyEntry"); qutacompEntry.Title = "商机客户"; EntryGroup qutaEntry = new EntryGroup("QuotationNewEntry"); qutaEntry.Title = "报价信息"; string oppoid = Dispatch.EitherField("oppo_OpportunityId"); if (string.IsNullOrEmpty(oppoid)) { oppoid = Dispatch.EitherField("key7"); } AddTabHead("Quotation"); int errflag = 0; string errmsg = string.Empty; string hMode = Dispatch.EitherField("HiddenMode"); if (hMode == "Save") { Record QutaRec = new Record("Quotation"); qutacompEntry.Fill(QutaRec); int days = Convert.ToInt32(Dispatch.ContentField("quta_days")); if (days < 3) { //AddError(days.ToString()); errflag = 1; errmsg = "交货天数不可小于3天!"; } string quta_oppoid = Dispatch.ContentField("quta_opportunityid"); string quta_qutatype = Dispatch.ContentField("quta_qutatype"); if (string.IsNullOrEmpty(quta_oppoid) && quta_qutatype != "1" && quta_qutatype != "2") { errflag = 1; errmsg = "请选择商机!"; } qutaEntry.Fill(QutaRec); if (qutaEntry.Validate() == true && qutacompEntry.Validate() && errflag == 0) { string code = "C"; DateTime now = DateTime.Now; string year = now.Year.ToString(); string month = now.Month.ToString(); string day = now.Day.ToString(); code += year + month + day; QuerySelect qs = this.GetQuery(); qs.SQLCommand = "Select Count(*)+1 as cnt from Quotation where quta_code like '" + code + "%'"; qs.ExecuteReader(); int cnt = 0; if (!qs.Eof()) { cnt = Convert.ToInt32(qs.FieldValue("cnt")); } code += "9" + cnt.ToString().PadLeft(4, '0'); QutaRec.SetField("quta_code", code); //QutaRec.SetField("quta_OpportunityId",oppoid); QutaRec.SaveChanges(); //QuerySelect qs = this.GetQuery(); if ((quta_qutatype == "1" || quta_qutatype == "2") && string.IsNullOrEmpty(quta_oppoid)) { //create opportunity string opponame = "报价单" + code + "自动生成商机"; string oppo_type = "3";//订货 string oppo_countryin = Dispatch.ContentField("quta_type"); switch (oppo_countryin) { case "2101": oppo_countryin = "in"; break; case "2102": oppo_countryin = "out"; break; default: oppo_countryin = "in"; break; } string oppo_assigneduserid = Dispatch.ContentField("quta_userid"); string oppo_stage = "payment"; string oppo_status = "In Progress"; string oppo_certainty = "100"; string oppo_primarycompanyid = Dispatch.ContentField("quta_companyid"); Record OppoRec = new Record("Opportunity"); OppoRec.SetField("oppo_type", oppo_type); OppoRec.SetField("oppo_description", opponame); OppoRec.SetField("oppo_countryin", oppo_countryin); OppoRec.SetField("oppo_assigneduserid", oppo_assigneduserid); OppoRec.SetField("oppo_stage", oppo_stage); OppoRec.SetField("oppo_status", oppo_status); OppoRec.SetField("oppo_certainty", oppo_certainty); OppoRec.SetField("oppo_primarycompanyid", oppo_primarycompanyid); OppoRec.SetField("oppo_createdate", DateTime.Now); OppoRec.SaveChanges(); quta_oppoid = OppoRec.RecordId.ToString(); QutaRec.SetField("quta_OpportunityId", quta_oppoid); QutaRec.SaveChanges(); } string quta_opportunityid = QutaRec.GetFieldAsString("quta_opportunityid"); qs.SQLCommand = "Update Opportunity set oppo_qutaprice= (select sum(quta_localeamount) from Quotation where quta_deleted is null and quta_updateoppo = 'Y' and quta_opportunityid = " + quta_opportunityid + " ) where oppo_Opportunityid =" + quta_opportunityid; qs.ExecuteNonQuery(); Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + QutaRec.RecordId.ToString()); } } if (errflag != -1) { if (errflag == 1) { AddError(errmsg); } AddContent(HTML.InputHidden("HiddenMode", "")); qutacompEntry.GetHtmlInEditMode(); qutaEntry.GetHtmlInEditMode(); VerticalPanel vp = new VerticalPanel(); vp.AddAttribute("width", "100%"); vp.Add(qutacompEntry); vp.Add(qutaEntry); AddContent(vp); AddSubmitButton("Save", "Save.gif", "javascript:document.EntryForm.HiddenMode.value='Save';"); string url = string.Empty; if (string.IsNullOrEmpty(oppoid)) { url = UrlDotNet("SalesMenu", "RunQuotation") + "&J=Quotation&T=SalesManagement"; } else { url = UrlDotNet(ThisDotNetDll, "RunListPage") + "&J=OppoTrack&T=Opportunity"; } AddUrlButton("Cancel", "Cancel.gif", url); } } catch (Exception error) { this.AddError(error.Message); } }
public override void BuildContents() { LogMessage("ConradDebug", "In Build", 1); string upper = (base.Dispatch.EitherField("Option") ?? "Customer").ToUpper(); string str = base.Dispatch.EitherField("HiddenMode"); this._comp_companyid = base.GetContextInfo("Company", "comp_companyid"); this._comp_name = base.GetContextInfo("Company", "Comp_Name"); this.userId = base.GetContextInfo("User", "User_AccpacID"); this.encryptedUserkey = base.GetContextInfo("User", "User_AccpacPSWD"); this.userKey = CRMCheckFormat.CheckFormat(this.encryptedUserkey); base.AddContent("<div id='sage300Loading' style='width:100%; text-align:center'><img src='../Themes/img/ergonomic/sage300loading.gif'></div>"); if (upper == "FINALIZELINK") { Record record = base.FindRecord("Company", string.Format("Comp_CompanyId = {0}", this._comp_companyid)); bool flag = false; string fieldAsString = record.GetFieldAsString("comp_idcust"); string fieldAsString1 = record.GetFieldAsString("comp_idvend"); string str1 = ""; if (string.IsNullOrEmpty(fieldAsString) || !string.IsNullOrEmpty(fieldAsString1)) { str1 = fieldAsString1; } else { flag = true; str1 = fieldAsString; } record.GetFieldAsString("Comp_Name"); this._database = record.GetFieldAsString("comp_database"); this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database); PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler() { Credentials = new NetworkCredential(this.userId, this.userKey) }; if (this.CheckExist(str1, (flag ? "ARCustomers" : "APVendors"))) { record.SetField("Comp_Database", ""); record.SetField("Comp_IdCust", ""); record.SetField("Comp_IdVend", ""); record.SaveChanges(); string str2 = this.Url("200"); base.Dispatch.Redirect(str2); return; } record.SetField("Comp_IdGrp", base.Dispatch.ContentField("GroupCode")); record.SetField("Comp_CodeTaxGrp", base.Dispatch.ContentField("TaxGroup")); record.SetField("Comp_CodeTerm", base.Dispatch.ContentField("TermsCode")); record.SetField("Comp_Status", base.Dispatch.ContentField("Status")); record.SetField("Comp_AmtCrLimt", base.Dispatch.ContentField("CreditLimit")); record.SaveChanges(); string str3 = this.Url("200"); base.Dispatch.Redirect(str3); return; } if (upper.ToUpper() == "PROMOTE" && string.IsNullOrEmpty(str)) { this.DisplayPromoteForm(upper); } this.GetTabs(); if (str == "PromoteCustomer" || str == "PromoteVendor") { this._database = base.Dispatch.ContentField("database"); bool flag1 = str == "PromoteCustomer"; string str4 = base.Dispatch.ContentField("txtId"); this._comp_type = (flag1 ? "Customer" : "Vendor"); this._Sage300Field = (flag1 ? "comp_idcust" : "comp_idvend"); string contextInfo = base.GetContextInfo("Company", "Comp_CompanyId"); Record record1 = base.FindRecord("Company", string.Concat("Comp_CompanyId=", contextInfo)); if (string.IsNullOrEmpty(record1.GetFieldAsString("Comp_database"))) { record1.SetField("Comp_database", this._database); record1.SaveChanges(); } string str5 = CommonPage.PostRequestUrl(this._database, this.userId, this.encryptedUserkey); base.AddContent(base.HTML.InputHidden("postRequestUrl", str5)); this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database); PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler() { Credentials = new NetworkCredential(this.userId, this.userKey) }; if (string.IsNullOrEmpty(str4)) { base.Dispatch.Redirect(base.UrlDotNet("PromoteCompany", "GetPromotePage&Option=PROMOTE&T=Company&ErrCode=1")); return; } if (!this.CheckExist(str4, (flag1 ? "ARCustomers" : "APVendors"))) { base.Dispatch.Redirect(base.UrlDotNet("PromoteCompany", string.Format("GetPromotePage&Option=PROMOTE&T=Company&ErrCode=2&id={0}", str4))); return; } string str6 = string.Concat("Select ainq_url From AccpacInquiry where ainq_module = '", (flag1 ? "AR1399" : "AP1299"), "'"); QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str6; QuerySelect querySelect1 = querySelect; querySelect1.ExecuteReader(); string str7 = ""; if (!querySelect1.Eof()) { str7 = querySelect1.FieldValue("ainq_url"); } base.AddContent("<iframe id='Sage300PageFrame' sandbox='allow-forms allow-popups allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation' width='100%' height='700' frameBorder='0'></iframe>"); string str8 = string.Concat(str7, str4); string requestUrl = CommonPage.GetRequestUrl(this._database, this.userId, str8); base.AddContent(string.Format("<a id='Sage300PageLinkId' href={0}></a>", requestUrl)); string str9 = base.UrlDotNet("PromoteCompany", "GetPromotePage&Option=FinalizeLink"); base.AddContent(string.Concat("<a href=", str9, " target='_blank' id='linkFinalizeLink' style='display: none;'><a>")); string str10 = string.Format("<input id='txtHostNameID' name='txtHostNameID' type='hidden' value='{0}'>", string.Concat("http://", base.Dispatch.Host, "|", this.sage300HostName)); base.AddContent(str10); string customerOrVendor = this.GetCustomerOrVendor(this._comp_companyid, flag1, this._database, str4); base.AddContent(customerOrVendor); string str11 = this.Url("200"); base.AddContent(base.HTML.InputHidden("SummaryPageUrl", str11)); } else if (str == "UnlinkCustomer" || str == "UnlinkVendor") { this._database = base.GetContextInfo("Company", "comp_database"); bool flag2 = str == "UnlinkCustomer"; this._comp_type = base.GetContextInfo("Company", "comp_type"); this._Sage300Field = (flag2 ? "comp_idcust" : "comp_idvend"); if (!flag2) { base.Metadata.GetTranslation("ainq_selection", "apVendor"); } else { base.Metadata.GetTranslation("ainq_selection", "arCustomer"); } this.sage300HostName = CommonPage.GetConfigField("AccP_ServerName", this._database); PromoteCompany.Sage300HttpClientHandler = new HttpClientHandler() { Credentials = new NetworkCredential(this.userId, this.userKey) }; if (this.CheckExist(this._comp_companyid, "OEOrders")) { this.UnlinkCompany(Convert.ToInt32(this._comp_companyid)); string str12 = string.Format(base.Metadata.GetTranslation("Company_Promote", "ConfirmMessage"), this._comp_companyid); base.AddContent(string.Format("<h3>{0}</h3>", str12)); string str13 = this.Url("200"); base.Dispatch.Redirect(str13); } else { this.DisplayCustomerOrVendorExist(); } } string str14 = string.Format("{0}/WebScreenProxy/Home/CreateSage300Cookies?userId={1}&companyId={2}", this.sage300HostName, this.userId, this._database); base.AddContent(string.Format("<iframe id='Sage300ProxyCookieFrame' src='{0}' height='0' frameBorder='0'></iframe>", str14)); base.AddContent("<script type='text/javascript' src='../CustomPages/Sage300Integration/PromoteCompany.js'></script>"); }
private string GetCustomerOrVendor(string compId, bool isCustomer, string database, string id) { string str = (isCustomer ? "AR" : "AP"); string str1 = (isCustomer ? "Customer" : "Vendor"); string contextInfo = base.GetContextInfo("Company", "Comp_Name"); string str2 = contextInfo.Substring(0, Math.Min(10, contextInfo.Length)); string contextInfo1 = base.GetContextInfo("Company", "Comp_EmailAddress"); string contextInfo2 = base.GetContextInfo("Company", "Comp_PhoneAreaCode"); string contextInfo3 = base.GetContextInfo("Company", "Comp_PhoneNumber"); contextInfo3 = string.Concat(contextInfo2, contextInfo3); contextInfo3 = new string(contextInfo3.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); string str3 = base.GetContextInfo("Company", "Comp_FaxCountryCode"); string contextInfo4 = base.GetContextInfo("Company", "Comp_FaxAreaCode"); string str4 = base.GetContextInfo("Company", "Comp_FaxNumber"); str4 = string.Concat(str3, contextInfo4, str4); str4 = new string(str4.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); string contextInfo5 = base.GetContextInfo("Company", "Comp_WebSite"); string str5 = ""; string str6 = ""; string str7 = ""; string str8 = ""; string str9 = ""; string str10 = ""; string str11 = ""; string str12 = ""; string str13 = ""; string str14 = ""; string str15 = ""; string str16 = ""; string str17 = string.Format("SELECT * FROM vListPerson WHERE Pers_CompanyId = {0} AND PeLi_Type='{1}Contact'", compId, str); QuerySelect querySelect = new QuerySelect(); querySelect.SQLCommand = str17; QuerySelect querySelect1 = querySelect; querySelect1.ExecuteReader(); if (!querySelect1.Eof()) { str5 = querySelect1.FieldValue("Pers_FullName"); str6 = querySelect1.FieldValue("Pers_EmailAddress"); str7 = string.Concat(querySelect1.FieldValue("Pers_PhoneAreaCode"), querySelect1.FieldValue("Pers_PhoneNumber")); str7 = new string(str7.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); str8 = string.Concat(querySelect1.FieldValue("Pers_FaxAreaCode"), querySelect1.FieldValue("Pers_FaxNumber")); str8 = new string(str8.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); } else { string contextInfo6 = base.GetContextInfo("Company", "Comp_PrimaryPersonId"); string str18 = string.Format("SELECT * FROM vListPerson WHERE Pers_PersonId = {0}", contextInfo6); QuerySelect querySelect2 = new QuerySelect(); querySelect2.SQLCommand = str18; QuerySelect querySelect3 = querySelect2; querySelect3.ExecuteReader(); if (!querySelect3.Eof()) { str5 = querySelect3.FieldValue("Pers_FullName"); str6 = querySelect3.FieldValue("Pers_EmailAddress"); str7 = string.Concat(querySelect3.FieldValue("Pers_PhoneAreaCode"), querySelect3.FieldValue("Pers_PhoneNumber")); str7 = new string(str7.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); str8 = string.Concat(querySelect3.FieldValue("Pers_FaxAreaCode"), querySelect3.FieldValue("Pers_FaxNumber")); str8 = new string(str8.Where <char>(new Func <char, bool>(char.IsDigit)).ToArray <char>()); Record record = new Record("Person_Link"); record.SetField("PeLi_CompanyID", compId); record.SetField("PeLi_PersonId", contextInfo6); record.SetField("PeLi_Type", string.Format("{0}Contact", str)); record.SaveChanges(); } } string str19 = string.Format("SELECT * FROM vListAddress WHERE AdLi_CompanyId = {0} AND AdLi_Type='{1}Address'", compId, str); QuerySelect querySelect4 = new QuerySelect(); querySelect4.SQLCommand = str19; QuerySelect querySelect5 = querySelect4; querySelect5.ExecuteReader(); if (!querySelect5.Eof()) { str9 = querySelect5.FieldValue("Addr_Address1"); str10 = querySelect5.FieldValue("Addr_Address2"); str11 = querySelect5.FieldValue("Addr_Address3"); str12 = querySelect5.FieldValue("Addr_Address4"); str13 = querySelect5.FieldValue("Addr_City"); str16 = querySelect5.FieldValue("Addr_State"); str15 = querySelect5.FieldValue("Addr_PostCode"); str14 = querySelect5.FieldValue("Addr_Country"); } else { string contextInfo7 = base.GetContextInfo("Company", "Comp_PrimaryAddressId"); string str20 = string.Format("SELECT * FROM vListAddress WHERE Addr_AddressId = {0}", contextInfo7); QuerySelect querySelect6 = new QuerySelect(); //querySelect6.set_SQLCommand(str20); querySelect6.SQLCommand = str20; QuerySelect querySelect7 = querySelect6; querySelect7.ExecuteReader(); if (!querySelect7.Eof()) { str9 = querySelect7.FieldValue("Addr_Address1"); str10 = querySelect7.FieldValue("Addr_Address2"); str11 = querySelect7.FieldValue("Addr_Address3"); str12 = querySelect7.FieldValue("Addr_Address4"); str13 = querySelect7.FieldValue("Addr_City"); str16 = querySelect7.FieldValue("Addr_State"); str15 = querySelect7.FieldValue("Addr_PostCode"); str14 = querySelect7.FieldValue("Addr_Country"); Record record1 = new Record("Address_Link"); record1.SetField("AdLi_CompanyID", compId); record1.SetField("AdLi_AddressId", contextInfo7); record1.SetField("AdLi_Type", string.Format("{0}Address", str)); record1.SaveChanges(); } } Record record2 = base.FindRecord("Company", string.Format("Comp_CompanyId = {0}", compId)); record2.SetField("Comp_Type", str1); record2.SetField("comp_database", database); record2.SetField((isCustomer ? "Comp_IdCust" : "Comp_IdVend"), id); record2.SaveChanges(); string str21 = string.Concat(string.Format("{0}|{1}|{2}|{3}|{4}|{5}|", new object[] { contextInfo, str2, contextInfo1, contextInfo3, str4, contextInfo5 }), string.Format("{0}|{1}|{2}|{3}|", new object[] { str5, str6, str7, str8 }), string.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}", new object[] { str9, str10, str11, str12, str13, str16, str15, str14, compId })); return(string.Format("<input id='txtPromoteRecord' name='txtPromoteRecord' type='hidden' value='{0}'>", str21)); }
public override void BuildContents() { try { AddContent(HTML.Form()); string qutaid = Dispatch.EitherField("quta_Quotationid"); Record QutaRec = FindRecord("Quotation", "quta_Quotationid=" + qutaid); string exchange = QutaRec.GetFieldAsString("quta_exchange"); if (string.IsNullOrEmpty(exchange) || exchange == "0") { exchange = "1"; } string currency = QutaRec.GetFieldAsString("quta_currencysid"); if (!string.IsNullOrEmpty(currency)) { Record currRec = FindRecord("Currencys", "curr_CurrencysId=" + currency); string currname = currRec.GetFieldAsString("curr_des"); AddContent(HTML.InputHidden("currency", currname)); } //报价单别 国内、国外 string inout = QutaRec.GetFieldAsString("quta_type"); AddContent(HTML.InputHidden("exchange", exchange)); string hMode = Dispatch.EitherField("HiddenMode"); EntryGroup QDEntry = new EntryGroup("QuotationDetailNewEntry"); QDEntry.Title = "报价明细"; int errflag = 0; AddTabHead("QuotationDetail"); string productinfoid = Dispatch.ContentField("qtdt_productinfoid"); double discount = 100; if (!string.IsNullOrEmpty(productinfoid) && productinfoid != "0") { Record prodRec = FindRecord("ProductInfo", "pdin_ProductInfoId=" + productinfoid); string Name = string.Empty; if (inout == "2101") { Name = prodRec.GetFieldAsString("pdin_Name"); } else { Name = prodRec.GetFieldAsString("pdin_Englishname"); } string Standard = prodRec.GetFieldAsString("pdin_standard"); string pdin_marketprice = prodRec.GetFieldAsString("pdin_marketprice"); //国内小类 string pdin_prodtypeid = prodRec.GetFieldAsString("pdin_prodtypeid"); if (string.IsNullOrEmpty(pdin_prodtypeid)) { pdin_prodtypeid = "0"; } //国外小类 string pdin_prodtype2 = prodRec.GetFieldAsString("pdin_prodtype2"); if (string.IsNullOrEmpty(pdin_prodtype2)) { pdin_prodtype2 = "0"; } //MOQ string MOQ = prodRec.GetFieldAsString("pdin_moq"); if (string.IsNullOrEmpty(MOQ)) { MOQ = "0"; } //客户折扣 根据报价产品所属产品小类,确认客户该小类折扣 string compid = QutaRec.GetFieldAsString("quta_companyid"); QuerySelect qs = this.GetQuery(); qs.SQLCommand = "select prpi_discount from ProductPrice where prpi_Deleted is null and prpi_Status = 'InProgress' and prpi_companyid = " + compid + " and (prpi_prodcategoryid = " + pdin_prodtypeid + " or prpi_prodcategoryid = " + pdin_prodtype2 + ")"; qs.ExecuteReader(); if (qs.Eof()) { discount = 100; } else { discount = Convert.ToDouble(qs.FieldValue("prpi_discount")); } //AddInfo(Name + "---" + Standard); for (int i = 0; i < QDEntry.Count; i++) { string field = QDEntry[i].Name; if (field == "qtdt_productname") { QDEntry[i].DefaultValue = Name; } else if (field == "qtdt_prodtype") { QDEntry[i].DefaultValue = Standard; } else if (field == "qtdt_discount") { QDEntry[i].DefaultValue = discount.ToString(); } else if (field == "qtdt_price") { QDEntry[i].DefaultValue = pdin_marketprice; } else if (field == "qtdt_moq") { QDEntry[i].DefaultValue = MOQ; } else { QDEntry[i].DefaultValue = Dispatch.ContentField(QDEntry[i].Name); } } } //int errflag = 0; string errmsg = ""; if (hMode == "Save") { Record QDRec = new Record("QuotationDetail"); QDEntry.Fill(QDRec); double dc = Convert.ToDouble(Dispatch.ContentField("qtdt_discount")); if (dc < discount && discount != 100) { errflag = 1; errmsg += "折扣率不可低于客户最低折扣!"; } if (QDEntry.Validate() == true && errflag == 0) { QDRec.SetField("qtdt_qutaid", qutaid); /*查找当前数据库中该产品最新价格 *必须在该条记录保存前查询 */ QuerySelect qs = this.GetQuery(); //string productinfoid = Dispatch.ContentField("qtdt_productinfoid"); double thislocalaount = Convert.ToDouble(Dispatch.ContentField("qtdt_localeamount")); //double thisforeignamount = Convert.ToDouble(Dispatch.ContentField("qtdt_foreignamount")); // string select = @"select qtdt_localeamount,qtdt_foreignamount,quta_opportunityid from QuotationDetail where qtdt_UpdatedDate = // (select MAX( qtdt_UpdatedDate) from QuotationDetail // left join Quotation on quta_QuotationID = qtdt_qutaid // left join Opportunity on Oppo_OpportunityId = quta_opportunityid // where qtdt_productinfoid = " + productinfoid+@" and quta_opportunityid = 12 and Oppo_Deleted is null and quta_Deleted is null and qtdt_Deleted is null) "; // qs.SQLCommand = select; // qs.ExecuteReader(); // double qtdt_localeamount=0, qtdt_foreignamount=0; // string quta_opportunityid = string.Empty; // if (!qs.Eof()) // { // qtdt_localeamount = Convert.ToDouble(qs.FieldValue("qtdt_localeamount")); // qtdt_foreignamount = Convert.ToDouble(qs.FieldValue("qtdt_foreignamount")); // quta_opportunityid = qs.FieldValue("quta_opportunityid"); // } // double resultlocal = thislocalaount - qtdt_localeamount; // double resultforeign = thisforeignamount = qtdt_foreignamount; // string updatesql = @"update Opportunity set oppo_qutaprice = ISNULL(oppo_qutaprice,0) + "+resultlocal+" where Oppo_OpportunityId =" + quta_opportunityid; // qs.SQLCommand = updatesql; // qs.ExecuteNonQuery(); QDRec.SaveChanges(); string qtdtid = QDRec.RecordId.ToString(); qs.SQLCommand = "exec crm_UpdateOpportunityQutaPrice @quotationid=" + qutaid; qs.ExecuteNonQuery(); //更新报价明细序号 qs.SQLCommand = "Update QuotationDetail set qtdt_code=(select count(*) from QuotationDetail where qtdt_deleted is null and qtdt_qutaid=" + qutaid + ") where qtdt_QuotationDetailId = " + qtdtid; qs.ExecuteNonQuery(); //更新报价单上汇总价格 qs.SQLCommand = @"Update Quotation set quta_localeamount = (select sum(qtdt_localeamount) from QuotationDetail where qtdt_deleted is null and qtdt_qutaid= " + qutaid + @") ,quta_foreignamount = (select sum(qtdt_foreignamount) from QuotationDetail where qtdt_deleted is null and qtdt_qutaid= " + qutaid + @") where quta_Quotationid=" + qutaid; qs.ExecuteNonQuery(); Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunQDAdd") + "&quta_Quotationid=" + qutaid); } } if (errflag != -1) { if (errflag == 1) { AddError(errmsg); } List UseList = new List("QuotationDetailGrid"); UseList.Filter = "qtdt_deleted is null and qtdt_qutaid =" + qutaid; UseList.PadBottom = false; UseList.RowsPerScreen = 50; AddContent(HTML.InputHidden("HiddenMode", "")); QDEntry.GetHtmlInEditMode(); VerticalPanel vp = new VerticalPanel(); vp.AddAttribute("width", "100%"); vp.Add(QDEntry); vp.Add(UseList); AddContent(vp); string url = "javascript:document.EntryForm.HiddenMode.value='Save';"; AddSubmitButton("Save", "Save.gif", url); AddUrlButton("Cancel", "cancel.gif", UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid); } } catch (Exception ex) { AddError(ex.Message + "USAddPage"); } }
public override void BuildContents() { try { AddContent(HTML.Form()); //string compid = Dispatch.EitherField("comp_companyid"); EntryGroup CompEntry = new EntryGroup("CompanyBoxLong"); CompEntry.Title = "基础信息"; EntryGroup DealEntry = new EntryGroup("CompanyDealEntry"); DealEntry.Title = "交易信息"; EntryGroup StatusEntry = new EntryGroup("CompanyStatusEntry"); StatusEntry.Title = "状态信息"; EntryGroup AddrEntry = new EntryGroup("CompanyAddressEntry"); AddrEntry.Title = "地址信息"; AddTabHead("Company"); int errflag = 0; string errmsg = string.Empty; string hMode = Dispatch.EitherField("HiddenMode"); if (hMode == "Save") { Record CompRec = new Record("Company"); CompEntry.Fill(CompRec); DealEntry.Fill(CompRec); string comp_fullname = CompRec.GetFieldAsString("comp_fullname"); string comp_shortname = CompRec.GetFieldAsString("comp_shortname"); QuerySelect qs = this.GetQuery(); qs.SQLCommand = "select count(*) as cnt from Company where comp_deleted is null and (comp_shortname = '" + comp_shortname + "' or comp_name = '" + comp_fullname + "')"; qs.ExecuteReader(); int cnt = -1; if (!qs.Eof()) { cnt = Convert.ToInt32(qs.FieldValue("cnt")); } if (cnt > 0) { errflag = 1; errmsg = "存在重复客户!"; } if (CompEntry.Validate() == true && DealEntry.Validate() && DealEntry.Validate() == true && StatusEntry.Validate() && errflag == 0) { string code = "CRM"; DateTime dt = DateTime.Now; string year = dt.Year.ToString().Substring(2, 2); string month = dt.Month.ToString(); code += year + month; //QuerySelect qs = this.GetQuery(); qs.SQLCommand = "select count(*) as cnt from Company where comp_deleted is null and comp_code like '" + code + "%'"; qs.ExecuteReader(); string count = qs.FieldValue("cnt").PadLeft(5, '0'); code += count; CompRec.SetField("comp_code", code); CompRec.SaveChanges(); Record AddrRec = new Record("Address"); AddrEntry.Fill(AddrRec); if (AddrEntry.Validate()) { AddrRec.SaveChanges(); } Dispatch.Redirect(Url("200") + "&key0=1&key1=" + CompRec.RecordId.ToString() + "&J=Summary&T=Company&comp_companyid=" + CompRec.RecordId.ToString()); } } if (errflag != -1) { if (errflag != 0) { AddError(errmsg); } AddContent(HTML.InputHidden("HiddenMode", "")); CompEntry.GetHtmlInEditMode(); DealEntry.GetHtmlInEditMode(); //StatusEntry.GetHtmlInEditMode(); VerticalPanel vp = new VerticalPanel(); vp.AddAttribute("width", "100%"); vp.Add(CompEntry); vp.Add(DealEntry); //vp.Add(StatusEntry); AddContent(vp); AddSubmitButton("Save", "Save.gif", "javascript:document.EntryForm.HiddenMode.value='Save';"); AddUrlButton("Cancel", "Cancel.gif", UrlDotNet(ThisDotNetDll, "RunListPage") + "&T=CompanyList"); } } catch (Exception error) { this.AddError(error.Message); } }