Example #1
0
 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);
     }
 }
Example #2
0
        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");
            }
        }
        /// <summary>
        /// Busca as notas das avaliações da secretaria para o boletim do aluno.
        /// Todas as notas em todas as turmas que ele passou naquele ano letivo (buscando pelo mtu_id informado).
        /// </summary>
        /// <param name="alu_id">ID do aluno</param>
        /// <param name="mtu_id">ID da matrícula que será buscadas as notas do ano letivo</param>
        /// <returns></returns>
        public DataTable SelecionaAvaliacoesLiberadasView(long alu_id, int mtu_id)
        {
            QuerySelect qs = new QuerySelect("SELECT * FROM VW_AvaliacoesLiberadas_Por_TurmaAluno WHERE alu_id = @alu_id AND mtu_id = @mtu_id", _Banco);

            #region Parâmetros

            Param               = qs.NewParameter();
            Param.DbType        = DbType.Int64;
            Param.ParameterName = "@alu_id";
            Param.Size          = 8;
            Param.Value         = alu_id;
            qs.Parameters.Add(Param);

            Param               = qs.NewParameter();
            Param.DbType        = DbType.Int32;
            Param.ParameterName = "@mtu_id";
            Param.Size          = 4;
            Param.Value         = mtu_id;
            qs.Parameters.Add(Param);

            #endregion Parâmetros

            qs.Execute();

            return(qs.Return);
        }
Example #4
0
        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);
        }
Example #5
0
        private List <DataObject> ExecuteOneQuery(JObject jsonQuery)
        {
            QueryBase queryBase;
            string    command = ((string)jsonQuery.GetProperty("cmd").Value).Trim();

            if (command == "select")
            {
                queryBase = new QuerySelect(this, jsonQuery);
            }
            else if (command == "insert")
            {
                queryBase = new QueryInsert(this, jsonQuery);
            }
            else if (command == "update")
            {
                queryBase = new QueryUpdate(this, jsonQuery);
            }
            else if (command == "delete")
            {
                queryBase = new QueryDelete(this, jsonQuery);
            }
            else
            {
                throw new AegisException(RoseResult.UnknownCommand);
            }


            var ret = queryBase.Execute();

            return(ret);
        }
        public override void Run()
        {
            int count = 1;

            foreach (PDATable table in tables)
            {
                // select data
                QuerySelect query = QuerySelect.Create(BaseType.PDA);
                query.Select("select * from " + table.Name);
                List <DataRows> rows = query.GetRows();
                foreach (DataRows row in rows)
                {
                    // create insert script
                    writer.WriteLine("INSERT INTO " + table.Name + " ");
                    writer.WriteLine("( ");
                    string Fields = "  ";
                    foreach (PDAField field in table.fields)
                    {
                        Fields += (field.Name + ", ");
                    }
                    Fields = Fields.Remove(Fields.Length - 2, 2);
                    writer.WriteLine(Fields);
                    writer.WriteLine(") ");
                    writer.WriteLine("VALUES ");
                    writer.WriteLine("( ");
                    string Values = "  ";
                    foreach (PDAField field in table.fields)
                    {
                        string val = "'" + row.FieldByName(field.Name).Replace("'", "''") + "'";
                        if (val == "''")
                        {
                            if ((field.DataType == "numeric") || (field.DataType == "datetime"))
                            {
                                val = "NULL";
                            }
                        }
                        if ((field.DataType == "numeric"))
                        {
                            val = val.Replace(',', '.');
                        }

                        Values += (val + ", ");
                    }
                    Values = Values.Remove(Values.Length - 2, 2);
                    writer.WriteLine(Values);
                    writer.WriteLine(") ");
                    writer.WriteLine("GO");
                }
                Loging.Loging.WriteLog("TABLE: " + table.Name + " exported " + rows.Count + " rows", false, true);
                Coordinator.ExecuteDelegateArgs args = new Coordinator.ExecuteDelegateArgs();
                args.Maximum       = tables.Count;//передавать в args кол-во таблиц и номер текущей (для прогресс бара)
                args.Pos           = count;
                args.runningAction = this;
                args.Name          = Name();
                OnExecute(this, args);
                count++;
            }
        }
Example #7
0
        //    public QuotationDetailDataPageDelete()
        //        : base("Follow", "foll_FollowID", "FollowNewEntry")
        //    {
        //        this.CancelButton = false;
        //        this.DeleteButton = false;
        //    }

        public override void BuildContents()
        {
            try
            {
                AddContent(HTML.Form());
                string qutaid = Dispatch.EitherField("quta_Quotationid");
                if (string.IsNullOrEmpty(qutaid))
                {
                    qutaid = Dispatch.EitherField("key37");
                }
                string     QuotationDetailid = Dispatch.EitherField("qtdt_QuotationDetailID");
                Record     rec = FindRecord("QuotationDetail", "qtdt_QuotationDetailID=" + QuotationDetailid);
                EntryGroup QuotationDetailentry = new EntryGroup("QuotationDetailNewEntry");
                QuotationDetailentry.Fill(rec);
                AddTabHead("QuotationDetail");
                //GetTabs("QuotationDetail", "QuotationDetail");
                string hMode = Dispatch.EitherField("HiddenMode");
                if (hMode == "Save")
                {
                    Record qutarec = FindRecord("Quotation", "quta_Quotationid=" + qutaid);
                    string oppoid  = qutarec.GetFieldAsString("quta_opportunityid");
                    //Record rec =  base.FindCurrentRecord("QuotationDetail");

                    double      thislocal = rec.GetFieldAsDouble("qtdt_localeamount");
                    QuerySelect qs        = this.GetQuery();
                    qs.SQLCommand = "Update Opportunity set oppo_qutaprice = case when (ISNULL(oppo_qutaprice," + thislocal + ")-" + thislocal + ") < 0 then 0 else (ISNULL(oppo_qutaprice," + thislocal + ")-" + thislocal + ") end  where Oppo_OpportunityId =" + oppoid;
                    qs.ExecuteNonQuery();

                    rec.DeleteRecord = true;
                    string code = rec.GetFieldAsString("qtdt_code");
                    rec.SaveChanges();

                    //
                    qs.SQLCommand = "Update QuotationDetail set qtdt_code=qtdt_code-1 where qtdt_code >'" + code + "' and qtdt_deleted is null and qtdt_qutaid =" + qutaid;
                    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, "RunDataPage") + "&quta_Quotationid=" + qutaid);
                }


                /* Add your code here */

                AddContent(HTML.InputHidden("HiddenMode", ""));
                QuotationDetailentry.GetHtmlInViewMode(rec);
                AddContent(QuotationDetailentry);
                AddSubmitButton("确认删除", "delete.gif", "javascript:document.EntryForm.HiddenMode.value='Save';");
                AddUrlButton("Cancel", "Cancel.gif", UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid);
            }
            catch (Exception error)
            {
                this.AddError(error.Message);
            }
        }
Example #8
0
        public override void BuildContents()
        {
            AddContent(HTML.Form());
            try {
                string     hMode              = Dispatch.EitherField("HiddenMode");
                string     id                 = Dispatch.EitherField("optr_OppoTrackId");
                int        errorflag          = 0;
                string     errormessage       = string.Empty;
                Record     OppoTrack          = FindRecord("OppoTrack", "optr_OppoTrackId=" + id);
                string     optr_opportunityid = OppoTrack.GetFieldAsString("optr_opportunityid");
                string     oppoid             = Dispatch.EitherField("key7");
                EntryGroup OppoTrackNewEntry  = new EntryGroup("OppoTrackNewEntry");
                OppoTrackNewEntry.Fill(OppoTrack);

                AddTabHead("Delete OppoTrack");
                if (hMode == "Delete")
                {
                    OppoTrack.DeleteRecord = true;
                    OppoTrack.SaveChanges();

                    QuerySelect qs = this.GetQuery();
                    qs.SQLCommand = @"Update Opportunity set oppo_nexttrackdate = (select MAX(optr_nexttrackdate) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @")
                        ,oppo_trackdate = (select MAX(optr_date) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @" )
                        ,oppo_targetclose = (select optr_targetclose  from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @" )
                        ,oppo_forecast = (select optr_forecast from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @") 
                        ,oppo_certainty = (select optr_certainty  from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @") where oppo_opportunityid=" + optr_opportunityid;
                    qs.ExecuteNonQuery();

                    string url = string.Empty;
                    if (string.IsNullOrEmpty(oppoid))
                    {
                        url = UrlDotNet("SalesMenu", "RunOppoTrack") + "&J=OppoTrack&T=SalesManagement";
                    }
                    else
                    {
                        url = UrlDotNet(ThisDotNetDll, "RunListPage") + "&J=OppoTrack&T=Opportunity";
                    }
                    Dispatch.Redirect(url);
                }
                if (errorflag != -1)
                {
                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    VerticalPanel vpMainPanel = new VerticalPanel();
                    vpMainPanel.AddAttribute("width", "100%");
                    string sUrl = "javascript:document.EntryForm.HiddenMode.value='Delete';";
                    OppoTrackNewEntry.GetHtmlInViewMode(OppoTrack);
                    vpMainPanel.Add(OppoTrackNewEntry);
                    AddContent(vpMainPanel);
                    AddSubmitButton("ConfirmDelete", "Delete.gif", sUrl);
                    string url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&optr_OppoTrackId=" + id + "&J=Summary";
                    AddUrlButton("Cancel", "cancel.gif", url);
                }
            } catch (Exception e) {
                AddError(e.Message);
            }
        }
Example #9
0
 public override void BuildContents()
 {
     try
     {
         AddContent(HTML.Form());
         string     qutaid        = Dispatch.EitherField("quta_Quotationid");
         EntryGroup qutacompEntry = new EntryGroup("QuotationCompanyEntry");
         qutacompEntry.Title = "商机客户";
         EntryGroup qutaEntry = new EntryGroup("QuotationNewEntry");
         qutaEntry.Title = "报价信息";
         Record qutaRec = FindRecord("Quotation", "quta_Quotationid=" + qutaid);
         qutacompEntry.Fill(qutaRec);
         qutaEntry.Fill(qutaRec);
         AddTabHead("Quotation");
         int    errflag = 0;
         string hMode   = Dispatch.EitherField("HiddenMode");
         if (hMode == "Save")
         {
             if (qutaEntry.Validate() == true && qutacompEntry.Validate())
             {
                 qutaEntry.Fill(qutaRec);
                 qutacompEntry.Fill(qutaRec);
                 string quta_opportunityid = qutaRec.GetFieldAsString("quta_opportunityid");
                 string quta_updateoppo    = qutaRec.GetFieldAsString("quta_updateoppo");
                 if (quta_updateoppo.ToLower() == "y")
                 {
                     QuerySelect qs = this.GetQuery();
                     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();
                 }
                 qutaRec.SaveChanges();
                 Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid);
             }
         }
         if (errflag != -1)
         {
             AddContent(HTML.InputHidden("HiddenMode", ""));
             qutacompEntry.GetHtmlInEditMode(qutaRec);
             qutaEntry.GetHtmlInEditMode(qutaRec);
             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';");
             AddUrlButton("Delete", "Delete.gif", UrlDotNet(ThisDotNetDll, "RunDataPageDelete") + "&quta_Quotationid=" + qutaid);
             AddUrlButton("Cancel", "Cancel.gif", UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid);
         }
     }
     catch (Exception error)
     {
         this.AddError(error.Message);
     }
 }
Example #10
0
        public void QuerySelectTest()
        {
            // prepare
            var query = new QuerySelect(new []
            {
                "id", "result"
            });

            // assert
            Assert.AreEqual(2, query.Value.Length);
            Assert.AreEqual("select", query.GetQueryParam());
            Assert.AreEqual("id,result", query.GetQueryValueString());
        }
Example #11
0
        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));
        }
Example #12
0
        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 }));
        }
Example #13
0
        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);
        }
Example #14
0
        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);
        }
Example #15
0
        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);
        }
Example #16
0
        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));
        }
Example #17
0
        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);
        }
Example #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BridgesReader"/> class.
 /// </summary>
 public BridgesReader()
 {
     query = QuerySelect.Create(BaseType.Oracle);
 }
Example #19
0
 // перегрузка чтобы создавать запрос для ПДА
 public BridgesReader(bool Dummy)
 {
     query = QuerySelect.Create(BaseType.PDA);
 }
Example #20
0
        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>");
        }
Example #21
0
        //public ContractDataPageDelete()
        //    : base("Contract", "cont_ContractId", "ContractNewEntry")
        //{
        //    this.EntryGroups[0].Title = "Contract";
        //    this.CancelMethod = "RunDataPage";
        //}
        public override void BuildContents()
        {
            AddContent(HTML.Form());
            try
            {
                string     hMode            = Dispatch.EitherField("HiddenMode");
                string     cont_ContractId  = Dispatch.EitherField("cont_ContractId");
                int        errorflag        = 0;
                string     errormessage     = string.Empty;
                Record     Contract         = FindRecord("Contract", "cont_ContractId=" + cont_ContractId);
                string     type             = Contract.GetFieldAsString("cont_type");
                EntryGroup ContractNewEntry = new EntryGroup("ContractNewEntry");
                ContractNewEntry.Fill(Contract);

                AddTabHead("Delete Contract");
                if (hMode == "Delete")
                {
                    Contract.DeleteRecord = true;
                    Contract.SaveChanges();
                    QuerySelect check = new QuerySelect();
                    check.SQLCommand = "delete contractdetail where code_contractid=" + cont_ContractId;
                    check.ExecuteNonQuery();

                    string url = UrlDotNet(ThisDotNetDll, "RunListPage");
                    Dispatch.Redirect(url);
                }
                if (errorflag != -1)
                {
                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    VerticalPanel vpMainPanel = new VerticalPanel();
                    vpMainPanel.AddAttribute("width", "100%");

                    string sUrl = "javascript:document.EntryForm.HiddenMode.value='Delete';";
                    ContractNewEntry.GetHtmlInViewMode(Contract);
                    vpMainPanel.Add(ContractNewEntry);
                    if (type.ToLower() != "product")
                    {
                        List ContractDetailGrid = new List("ContractDetailGrid");
                        ContractDetailGrid.Filter                = "code_deleted is null and code_contractid=" + cont_ContractId + " and  code_isproduct='1'";
                        ContractDetailGrid.RowsPerScreen         = 500;
                        ContractDetailGrid.ShowNavigationButtons = true;
                        ContractDetailGrid.PadBottom             = false;
                        vpMainPanel.Add(ContractDetailGrid);
                    }
                    else
                    {
                        List ContractDetailProduct = new List("ContractDetailProduct");
                        ContractDetailProduct.Filter                = "code_deleted is null and code_contractid=" + cont_ContractId + " and code_isproduct='2'";
                        ContractDetailProduct.RowsPerScreen         = 500;
                        ContractDetailProduct.ShowNavigationButtons = true;
                        ContractDetailProduct.PadBottom             = false;
                        vpMainPanel.Add(ContractDetailProduct);
                    }
                    AddContent(vpMainPanel);
                    AddSubmitButton("ConfirmDelete", "Delete.gif", sUrl);
                    string url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&cont_ContractId=" + cont_ContractId + "&J=Summary";
                    url = url.Replace("Key37", "ContractDetailid");
                    url = url + "&Key37=" + cont_ContractId;
                    AddUrlButton("Cancel", "cancel.gif", url);
                }
            }
            catch (Exception e)
            {
                AddError(e.Message);
            }
        }
Example #22
0
 public override Node VisitQuerySelect( QuerySelect select ) {
   base.VisitQuerySelect(select);
   return this.Compose(select, this.GetComposer(select.Source));
 }
Example #23
0
 public override Node VisitQuerySelect(QuerySelect qs) {
   if (qs == null) return null;
   qs.Source = this.VisitExpression(qs.Source);
   if (qs.Type == null || qs.Source == null || qs.Source.Type == null) return null;
   return qs;
 }
Example #24
0
        public SqlString ToSqlString(bool isCount = false)
        {
            var dataProvider = SlipstreamEnvironment.RootContainer.Resolve <IDataProvider>();
            var qs           = new QuerySelect(dataProvider.Dialect);

            SqlString columnsFragment = null;

            if (isCount)
            {
                columnsFragment = new SqlString("count(", MainTableAlias + '.' + AbstractModel.IdFieldName, ")");
            }
            else
            {
                columnsFragment = new SqlString(MainTableAlias + '.' + AbstractModel.IdFieldName);
            }
            qs.AddSelectFragmentString(columnsFragment);
            qs.Distinct = false;

            var fromClauseBuilder = new SqlStringBuilder();

            for (int i = 0; i < this.fromJoins.Count; i++)
            {
                if (this.fromJoins.Count > 1 && i > 0)
                {
                    fromClauseBuilder.Add(", ");
                }
                else
                {
                    fromClauseBuilder.Add(" ");
                }
                fromClauseBuilder.Add(this.fromJoins[i]);
                fromClauseBuilder.Add(" ");
            }
            var fromClause = fromClauseBuilder.ToSqlString();

            qs.JoinFragment.AddJoins(fromClause, SqlString.Empty);

            foreach (var innerJoin in this.innerJoins)
            {
                qs.JoinFragment.AddJoin(
                    innerJoin.Table, innerJoin.Alias,
                    new string[] { innerJoin.FkColumn },
                    new string[] { innerJoin.PkColumn }, JoinType.InnerJoin);
            }

            foreach (var outerJoin in this.outerJoins)
            {
                qs.JoinFragment.AddJoin(
                    outerJoin.Table, outerJoin.Alias,
                    new string[] { outerJoin.FkColumn },
                    new string[] { outerJoin.PkColumn }, JoinType.LeftOuterJoin);
            }

            if (this.whereRestrictions.Count > 0)
            {
                var whereTokens = new SqlString[] { this.whereRestrictions.ToSqlString() };
                qs.SetWhereTokens((ICollection)whereTokens);
            }

            if (!isCount)
            {
                foreach (var o in this.orders)
                {
                    var orderBySql = ' ' + MainTableAlias + '.' + o.Field + ' ' + o.Order.ToSql();
                    qs.AddOrderBy(orderBySql);
                }
            }

            return(qs.ToQuerySqlString());
        }
Example #25
0
        public override void BuildContents()
        {
            try
            {
                AddContent(HTML.Form());
                string     qdid    = Dispatch.EitherField("qtdt_QuotationDetailID");
                EntryGroup QDEntry = new EntryGroup("QuotationDetailNewEntry");
                QDEntry.Title = "报价明细";
                Record QDRec  = FindRecord("QuotationDetail", "qtdt_QuotationDetailID=" + qdid);
                string qutaid = Dispatch.EitherField("quta_Quotationid");
                if (string.IsNullOrEmpty(qutaid))
                {
                    qutaid = QDRec.GetFieldAsString("qtdt_qutaID");
                }
                Record QutaRec  = FindRecord("Quotation", "quta_Quotationid=" + qutaid);
                string exchange = QutaRec.GetFieldAsString("quta_exchange");
                if (string.IsNullOrEmpty(exchange) || exchange == "0")
                {
                    exchange = "1";
                }
                AddContent(HTML.InputHidden("exchange", exchange));
                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 hMode = Dispatch.EitherField("HiddenMode");

                int errflag = 0;
                AddTabHead("QuotationDetail");
                //GetTabs("QuotationDetail", "QuotationDetail Summary");
                if (hMode == "Save")
                {
                    QDEntry.Fill(QDRec);
                    if (QDEntry.Validate() == true)
                    {
                        QDRec.SetField("quta_Quotationid", qutaid);

                        QDRec.SaveChanges();
                        QuerySelect qs             = this.GetQuery();
                        string      qtdtid         = QDRec.RecordId.ToString();
                        double      thislocalaount = Convert.ToDouble(Dispatch.ContentField("qtdt_localeamount"));
                        qs.SQLCommand = "exec crm_UpdateOpportunityQutaPrice @quotationid=" + qutaid;
                        qs.ExecuteNonQuery();
//                        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();


                        //QuerySelect qs = this.GetQuery();
                        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, "RunDataPage") + "&quta_Quotationid=" + qutaid);
                    }
                }
                if (errflag != -1)
                {
                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    QDEntry.GetHtmlInEditMode(QDRec);
                    VerticalPanel vp = new VerticalPanel();
                    vp.AddAttribute("width", "100%");
                    vp.Add(QDEntry);
                    AddContent(vp);

                    string url = "javascript:document.EntryForm.HiddenMode.value='Save';";
                    AddSubmitButton("Save", "Save.gif", url);
                    AddUrlButton("Delete", "Delete.gif", UrlDotNet(ThisDotNetDll, "RunQDDelete") + "&quta_Quotationid=" + qutaid + "&qtdt_QuotationDetailID=" + qdid);

                    AddUrlButton("Cancel", "cancel.gif", UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid);
                }
            }
            catch (Exception ex)
            {
                AddError(ex.Message + "USAddPage");
            }
        }
Example #26
0
 public override Node VisitQuerySelect(QuerySelect qs) {
   return this.Visit(qs.Source);
 }
Example #27
0
        public override void BuildContents()
        {
            AddContent(HTML.Form());

            try {
                string     hMode              = Dispatch.EitherField("HiddenMode");
                string     optr_OppoTrackId   = Dispatch.EitherField("optr_OppoTrackId");
                int        errorflag          = 0;
                string     errormessage       = string.Empty;
                Record     OppoTrack          = FindRecord("OppoTrack", "optr_OppoTrackId=" + optr_OppoTrackId);
                string     optr_opportunityid = OppoTrack.GetFieldAsString("optr_opportunityid");
                EntryGroup OppoTrackNewEntry  = new EntryGroup("OppoTrackNewEntry");
                OppoTrackNewEntry.Fill(OppoTrack);
                Entry optr_opportunityidEntry = OppoTrackNewEntry.GetEntry("optr_opportunityid");

                optr_opportunityidEntry.ReadOnly = true;

                //AddTabHead("CpetProduct");
                GetTabs("OppoTrack", "Summary");
                if (hMode == "Save")
                {
                    ////double original =CpetProduct.GetFieldAsDouble("");
                    OppoTrackNewEntry.Fill(OppoTrack);
                    ////double  =CpetProduct.GetFieldAsDouble("");

                    if (OppoTrackNewEntry.Validate())
                    {
                        OppoTrack.SaveChanges();

                        QuerySelect qs = this.GetQuery();
                        qs.SQLCommand = @"Update Opportunity set oppo_nexttrackdate = (select MAX(optr_nexttrackdate) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @")
                        ,oppo_trackdate = (select MAX(optr_date) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @" )
                        ,oppo_targetclose = (select optr_targetclose  from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @" )
                        ,oppo_forecast = (select optr_forecast from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @") 
                        ,oppo_certainty = (select optr_certainty  from OppoTrack where optr_OppoTrackId = " + OppoTrack.RecordId.ToString() + @") where oppo_opportunityid=" + optr_opportunityid;
                        qs.ExecuteNonQuery();

                        string url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&optr_OppoTrackId=" + optr_OppoTrackId + "&J=Summary";
                        Dispatch.Redirect(url);
                        errorflag = -1;
                    }
                    else
                    {
                        errorflag = 1;
                    }
                }
                if (errorflag != -1)
                {
                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    VerticalPanel vpMainPanel = new VerticalPanel();
                    vpMainPanel.AddAttribute("width", "100%");
                    string sUrl = "javascript:document.EntryForm.HiddenMode.value='Save';";
                    OppoTrackNewEntry.GetHtmlInEditMode(OppoTrack);
                    vpMainPanel.Add(OppoTrackNewEntry);
                    AddContent(vpMainPanel);
                    AddSubmitButton("Save", "Save.gif", sUrl);
                    string urldelete = base.UrlDotNet(base.ThisDotNetDll, "RunDataPageDelete") + "&optr_OppoTrackId=" + optr_OppoTrackId;
                    base.AddUrlButton("Delete", "Delete.gif", urldelete);
                    string url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&optr_OppoTrackId=" + optr_OppoTrackId + "&J=Summary";
                    AddUrlButton("Cancel", "cancel.gif", url);
                }
            } catch (Exception e) {
                AddError(e.Message);
            }
        }
Example #28
0
        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");
            }
        }
Example #29
0
 public BridgesReader(bool Dummy) // перегрузка чтобы создавать запрос для ПДА
 {
     query = QuerySelect.Create(BaseType.PDA);
 }
Example #30
0
 public override Node VisitQuerySelect( QuerySelect select ){
   if (select == null) return null;
   select.Source = (Expression) this.Visit(select.Source);
   if (select.Source != null && select.Source.Type != null){
     select.Type = select.Source.Type;
   }
   return select;
 }
Example #31
0
        public override void BuildContents()
        {
            AddContent(HTML.Form());

            try {
                string     hMode = Dispatch.EitherField("HiddenMode");
                string     optr_opportunityid = Dispatch.EitherField("Key7");
                int        errorflag          = 0;
                string     errormessage       = string.Empty;
                EntryGroup OppoTrackNewEntry  = new EntryGroup("OppoTrackNewEntry");
                //CostAdjustmentProductNewEntry.Title = "Add CostAdjustmentProduct";
                Entry optr_opportunityidEntry = OppoTrackNewEntry.GetEntry("optr_opportunityid");
                if (optr_opportunityidEntry != null)
                {
                    optr_opportunityidEntry.DefaultValue = optr_opportunityid;
                    optr_opportunityidEntry.ReadOnly     = true;
                }

                AddTabHead("OppoTrack");
                if (hMode == "Save")
                {
                    Record OppoTrack = new Record("OppoTrack");
                    OppoTrackNewEntry.Fill(OppoTrack);
                    if (OppoTrackNewEntry.Validate())
                    {
                        OppoTrack.SaveChanges();
                        QuerySelect qs = this.GetQuery();
                        qs.SQLCommand = @"Update Opportunity set oppo_nexttrackdate = (select MAX(optr_nexttrackdate) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @")
                        ,oppo_trackdate = (select MAX(optr_date) from OppoTrack where optr_deleted is null and optr_opportunityid=" + optr_opportunityid + @" ) where oppo_opportunityid=" + optr_opportunityid;
                        qs.ExecuteNonQuery();

                        string url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&optr_oppotrackid=" + OppoTrack.GetFieldAsString("optr_oppotrackid") + "&J=Summary";
                        Dispatch.Redirect(url);
                        errorflag = -1;
                    }
                    else
                    {
                        errorflag = 1;
                    }
                }
                if (errorflag != -1)
                {
                    if (errorflag == 2)
                    {
                        AddError(errormessage);
                    }

                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    VerticalPanel vpMainPanel = new VerticalPanel();
                    vpMainPanel.AddAttribute("width", "100%");
                    string sUrl = "javascript:document.EntryForm.HiddenMode.value='Save';";
                    OppoTrackNewEntry.GetHtmlInEditMode();
                    vpMainPanel.Add(OppoTrackNewEntry);
                    AddContent(vpMainPanel);
                    AddSubmitButton("Save", "Save.gif", sUrl);
                    AddUrlButton("Cancel", "cancel.gif", UrlDotNet(ThisDotNetDll, "RunListPage") + "&J=OppoTrack&T=Opportunity");
                }
            } catch (Exception e) {
                AddError(e.Message);
            }
        }
Example #32
0
        public override void BuildContents()
        {
            try
            {
                AddContent(HTML.Form());
                string qutaid = Dispatch.EitherField("quta_Quotationid");
                if (string.IsNullOrEmpty(qutaid))
                {
                    qutaid = Dispatch.EitherField("key58");
                }

                EntryGroup qutacompEntry = new EntryGroup("QuotationCompanyEntry");
                qutacompEntry.Title = "商机客户";
                EntryGroup qutaEntry = new EntryGroup("QuotationNewEntry");
                qutaEntry.Title = "报价信息";
                Record qutaRec = FindRecord("Quotation", "quta_Quotationid=" + qutaid);
                qutacompEntry.Fill(qutaRec);
                qutaEntry.Fill(qutaRec);
                GetTabs("Quotation", "Quotation Summary");
                string hMode = Dispatch.EitherField("HiddenMode");
                string quta_opportunityid = qutaRec.GetFieldAsString("quta_opportunityid");
                if (hMode == "Delete")
                {
                    qutaRec.DeleteRecord = true;
                    qutaRec.SaveChanges();

                    QuerySelect qs = this.GetQuery();
                    if (!string.IsNullOrEmpty(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();
                    }
                    qs.SQLCommand = "Update QuotationDetail set qtdt_deleted = '1' where qtdt_qutaid =" + qutaid;
                    qs.ExecuteNonQuery();
                    Dispatch.Redirect(UrlDotNet(ThisDotNetDll, "RunListPage") + "&J=Quotation&T=Opportunity");
                }



                AddContent(HTML.InputHidden("HiddenMode", ""));
                qutacompEntry.GetHtmlInViewMode(qutaRec);
                qutaEntry.GetHtmlInViewMode(qutaRec);
                VerticalPanel vp = new VerticalPanel();
                vp.AddAttribute("width", "100%");
                vp.Add(qutacompEntry);
                vp.Add(qutaEntry);


                AddContent(vp);

                string url = string.Empty;

                url = UrlDotNet(ThisDotNetDll, "RunDataPage") + "&quta_Quotationid=" + qutaid + "&J=OppoTrack&T=Opportunity";
                AddSubmitButton("ConfirmDelete", "Delete.gif", "javascript:document.EntryForm.HiddenMode.value='Delete';");
                AddUrlButton("Cancel", "Cancel.gif", url);
            }
            catch (Exception error)
            {
                this.AddError(error.Message);
            }
        }
 public EventingVisitor(Action<QuerySelect> visitQuerySelect) { VisitedQuerySelect += visitQuerySelect; } public event Action<QuerySelect> VisitedQuerySelect; public override Node VisitQuerySelect(QuerySelect select) { if (VisitedQuerySelect != null) VisitedQuerySelect(select); return base.VisitQuerySelect(select); }
Example #34
0
 public void SetUp()
 {
     repository = new MockRepository();
     query = repository.CreateMock<QuerySelect>();
 }
Example #35
0
 public override Node VisitQuerySelect( QuerySelect select ){
   Scope savedScope = this.scope;
   Scope scope = this.scope = new QueryScope(savedScope);
   this.AddToAllScopes(this.scope);
   QueryGroupBy saveGroup = this.currentGroup;
   this.currentGroup = null;
   select.Source = (Expression) this.Visit( select.Source );
   this.currentGroup = saveGroup;
   this.scope = savedScope;
   return select;
 }
Example #36
0
 public virtual void VisitQuerySelect(QuerySelect select){
   if (select == null) return;
   this.VisitExpression(select.Source);
 }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BridgesReader"/> class.
 /// </summary>
 public BridgesReader()
 {
     query = QuerySelect.Create(BaseType.Oracle);
 }
Example #38
0
        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);
            }
        }
Example #39
0
        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));
        }
Example #40
0
 public virtual Node VisitQuerySelect(QuerySelect select){
   if (select == null) return null;
   select.Source = this.VisitExpression(select.Source);
   return select;
 }
Example #41
0
        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));
                }


                AddContent(HTML.InputHidden("exchange", exchange));
                string     hMode   = Dispatch.EitherField("HiddenMode");
                EntryGroup QDEntry = new EntryGroup("QuotationDetailNewEntry");
                QDEntry.Title = "报价明细";
                int errflag = 0;
                AddTabHead("QuotationDetail");
                if (hMode == "Save")
                {
                    Record QDRec = new Record("QuotationDetail");
                    QDEntry.Fill(QDRec);
                    if (QDEntry.Validate() == true)
                    {
                        QDRec.SetField("qtdt_qutaid", qutaid);
                        QDRec.SaveChanges();

                        QuerySelect qs = this.GetQuery();
                        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, "RunDataPage") + "&quta_Quotationid=" + qutaid);
                    }
                }
                if (errflag != -1)
                {
                    AddContent(HTML.InputHidden("HiddenMode", ""));
                    QDEntry.GetHtmlInEditMode();
                    VerticalPanel vp = new VerticalPanel();
                    vp.AddAttribute("width", "100%");
                    vp.Add(QDEntry);
                    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 virtual Differences VisitQuerySelect(QuerySelect select1, QuerySelect select2){
      Differences differences = new Differences(select1, select2);
      if (select1 == null || select2 == null){
        if (select1 != select2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++;
        return differences;
      }
      QuerySelect changes = (QuerySelect)select2.Clone();
      QuerySelect deletions = (QuerySelect)select2.Clone();
      QuerySelect insertions = (QuerySelect)select2.Clone();

      //      select1.Access;
      //      select1.Direction;
      //      select1.Source;

      if (differences.NumberOfDifferences == 0){
        differences.Changes = null;
        differences.Deletions = null;
        differences.Insertions = null;
      }else{
        differences.Changes = changes;
        differences.Deletions = deletions;
        differences.Insertions = insertions;
      }
      return differences;
    }
Example #43
0
 public virtual Node VisitQuerySelect(QuerySelect select1, QuerySelect select2){
   if (select1 == null) return null;
   if (select2 == null)
     select1.Source = this.VisitExpression(select1.Source, null);
   else
     select1.Source = this.VisitExpression(select1.Source, select2.Source);
   return select1;
 }
Example #44
0
 public virtual Node VisitQuerySelect(QuerySelect select, QuerySelect changes, QuerySelect deletions, QuerySelect insertions){
   this.UpdateSourceContext(select, changes);
   if (select == null) return changes;
   if (changes != null){
     if (deletions == null || insertions == null)
       Debug.Assert(false);
     else{
     }
   }else if (deletions != null)
     return null;
   return select;
 }
Example #45
0
 public override Node VisitQuerySelect(QuerySelect select){
   if (select == null) return null;
   return base.VisitQuerySelect((QuerySelect)select.Clone());
 }