예제 #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);
     }
 }
예제 #2
0
파일: QDEdit.cs 프로젝트: Cross985/XXGJ2.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");
            }
        }
예제 #3
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);
            }
        }
예제 #4
0
파일: QDAdd.cs 프로젝트: Cross985/XXGJ2.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");
            }
        }