protected void bt_AddApply_Click(object sender, EventArgs e)
    {
        bt_OK_Click(null, null);
        if (CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString()).Count == 0)
        {
            MessageBox.Show(this, "对不起,请至少提供一名客户联系人!");
            return;
        }
        CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]);

        NameValueCollection dataobjects = new NameValueCollection();

        dataobjects.Add("ID", bll.Model.ID.ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("ClientName", bll.Model.FullName);
        dataobjects.Add("Channel", bll.Model["RTChannel"]);
        dataobjects.Add("StoreAnalysis", bll.Model["Store_Analysis"]);
        dataobjects.Add("IsACClient", bll.Model["IsACClient"]);

        int TaskID = EWF_TaskBLL.NewTask("Add_Retailer", (int)Session["UserID"], "终端门店名称:" + bll.Model.FullName, "~/SubModule/CM/RT/RetailerDetail.aspx?ClientID=" + ViewState["ClientID"].ToString(), dataobjects);

        if (TaskID > 0)
        {
            bll.Model["TaskID"] = TaskID.ToString();
            bll.Model["State"]  = "2";
            bll.Update();
            //new EWF_TaskBLL(TaskID).Start();        //直接启动流程
        }

        Response.Redirect("~/SubModule/EWF/Apply.aspx?TaskID=" + TaskID.ToString());
    }
Beispiel #2
0
 protected void select_RelateClient_SelectChange(object sender, SelectChangeEventArgs e)
 {
     if (!string.IsNullOrEmpty(select_RelateClient.SelectValue))
     {
         try
         {
             ddl_RelateLinkMan.DataSource = CM_LinkManBLL.GetModelList("ClientID=" + select_RelateClient.SelectValue +
                                                                       " AND MCS_SYS.dbo.UF_Spilt2('MCS_CM.dbo.CM_LinkMan',ExtPropertys,'Dimission')!='2'");
             ddl_RelateLinkMan.DataBind();
             ddl_RelateLinkMan.Enabled = true;
             ddl_RelateLinkMan.Items.Insert(0, new ListItem("请选择", "0"));
         }
         catch { }
     }
 }
Beispiel #3
0
    protected void select_Client_SelectChange(object sender, MCSControls.MCSWebControls.SelectChangeEventArgs e)
    {
        ddl_LinkMan.Items.Clear();

        int client = 0;

        if (int.TryParse(select_Client.SelectValue, out client) && client > 0)
        {
            IList <CM_LinkMan> lists = CM_LinkManBLL.GetModelList("ClientID = " + client.ToString());
            foreach (CM_LinkMan item in lists)
            {
                ddl_LinkMan.Items.Add(new ListItem(item.Name, item.ID.ToString()));
            }

            CM_ClientBLL clientbll = new CM_ClientBLL(client);
            decimal      forcast   = clientbll.GetSalesForcast((int)ViewState["AccountMonth"]);
            tbx_SalesForcast.Text     = forcast.ToString("0.##");
            tbx_SalesForcast.ReadOnly = forcast > 0;

            lb_PreSalesVolume.Text = clientbll.GetSalesVolume(AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString("0.##元");
            lb_AvgSalesVolume.Text = clientbll.GetSalesVolumeAvg().ToString("0.##元");
        }
        ddl_LinkMan.Items.Insert(0, new ListItem("请选择", "0"));
    }
    private void BindData()
    {
        CM_Client m = new CM_ClientBLL((int)ViewState["ClientID"]).Model;

        switch (m.ClientType)
        {
        case 1:
            Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 2:
            break;

        case 3:
            Response.Redirect("../RT/RetailerDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        default:
            MessageBox.ShowAndRedirect(this, "请先在‘经销商列表’中选择要查看的经销商!", "DistributorList.aspx?URL=" + Request.Url.PathAndQuery);
            break;
        }
        pl_detail.BindData(m);



        MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager");

        select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + m.OrganizeCity;

        if (m.ApproveFlag == 1)
        {
            //已审核
            TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime");
            if (tbx_OpenTime != null && tbx_OpenTime.Text != "")
            {
                tbx_OpenTime.Enabled = false;
            }

            if (m.ActiveFlag == 1)
            {
                bt_AddApply.Visible = false;
                bt_DIUP.Visible     = false;
            }
            else
            {
                TextBox tbx_CloseTime = (TextBox)pl_detail.FindControl("CM_Client_CloseTime");
                if (tbx_CloseTime != null && tbx_CloseTime.Text != "")
                {
                    tbx_CloseTime.Enabled = false;
                }
                bt_RevocationApply.Visible = false;
            }
            bt_Approve.Visible = false;
        }

        if (m.ActiveFlag == 1)
        {
            Header.Attributes["WebPageSubCode"] = "Modify";
            bt_AddApply.Visible = false;
            bt_Approve.Visible  = false;
        }
        else
        {
            bt_RevocationApply.Visible = false;
        }

        if (string.IsNullOrEmpty(m["TaskID"]))
        {
            bt_Record.Visible = false;
        }
        else
        {
            if (m["State"] == "2")
            {
                //审批中,不可修改数据
                bt_AddApply.Visible        = false;
                bt_RevocationApply.Visible = false;
                bt_OK.Visible = false;
                bt_RevocationApply.Visible = false;
                bt_DIACUpgrade.Visible     = false;
                bt_DIUP.Visible            = false;
            }
        }

        #region 绑定该客户的首要联系人
        DropDownList ddl_ChiefLinkMan = (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan");
        try
        {
            ddl_ChiefLinkMan.DataTextField  = "Name";
            ddl_ChiefLinkMan.DataValueField = "ID";
            ddl_ChiefLinkMan.DataSource     = CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString());
            ddl_ChiefLinkMan.DataBind();
        }
        catch { }

        ddl_ChiefLinkMan.Items.Insert(0, new ListItem("请选择", "0"));
        ddl_ChiefLinkMan.SelectedValue = m.ChiefLinkMan.ToString();

        #endregion

        BindGrid();
        bt_Add.Enabled = true;

        if (m.ClientType != 2 || m["DIClassify"] != "3")
        {
            bt_DIACUpgrade.Visible = false;
        }
        if (m.ClientType != 2 || m["DIClassify"] == "2")
        {
            bt_DIUP.Visible = false;
        }

        bt_ReplaceSupplier.OnClientClick      = "javascript:PopReplaceSupplier(" + m.ID.ToString() + ")";
        bt_ReplaceSupplier2.OnClientClick     = "javascript:PopReplaceSupplier2(" + m.ID.ToString() + ")";
        bt_ReplaceClientManager.OnClientClick = "javascript:PopReplaceClientManager(" + m.ClientManager.ToString() + "," + m.ClientType.ToString() + ")";
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        CM_ClientBLL _bll = null;

        if (ViewState["ClientID"] == null)
        {
            _bll = new CM_ClientBLL();
        }
        else
        {
            _bll = new CM_ClientBLL((int)ViewState["ClientID"]);
            if (CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString()).Count == 0)
            {
                MessageBox.Show(this, "对不起,请至少提供一名客户联系人!");
                return;
            }
        }

        string IsRMSClient = _bll.Model["IsRMSClient"];

        pl_detail.GetData(_bll.Model);


        #region 判断必填项
        if (_bll.Model.OrganizeCity == 0)
        {
            MessageBox.Show(this, "所属的管理片区必填!");
            return;
        }
        if (_bll.Model.OfficalCity == 0)
        {
            MessageBox.Show(this, "所属的行政城市必填!");
            return;
        }
        if (_bll.Model.Supplier == 0)
        {
            MessageBox.Show(this, "供货商信息必填!");
            return;
        }
        if (_bll.Model["Supplier2"] == "")
        {
            MessageBox.Show(this, "赠品供货商信息必填!");
            return;
        }
        if (_bll.Model["OperateProperty"] == "0")
        {
            MessageBox.Show(this, "归属办事处类型必填!");
            return;
        }
        if (new Addr_OfficialCityBLL(_bll.Model.OfficalCity).Model.Level < 3)
        {
            MessageBox.Show(this, "门店所在行政城市必须到区或县城!");
            return;
        }
        if (_bll.Model["RTChannel"] == "0")
        {
            MessageBox.Show(this, "门店渠道必填!");
            return;
        }
        if ((_bll.Model["RTChannel"] == "1" || _bll.Model["RTChannel"] == "2") && _bll.Model["VestKA"] == "0")
        {
            MessageBox.Show(this, "当门店渠道为LKA,或NKA时,KA系统必填!");
            return;
        }
        if (_bll.Model["Classification"] == "" || _bll.Model["Classification"] == "0")
        {
            MessageBox.Show(this, "“门店归类”必填!");
            return;
        }
        if ((_bll.Model["MarketType"] == "" || _bll.Model["MarketType"] == "0"))
        {
            MessageBox.Show(this, "“市场类型”必填!");
            return;
        }
        #endregion

        if (_bll.Model["IsRMSClient"] == "2" && IsRMSClient != "2")
        {
            _bll.Model["RMSCloseDate"] = DateTime.Now.ToString("yyyy-MM-dd");
        }

        string[] RTChannelLimit1    = ConfigHelper.GetConfigString("RTChannelLimit1").Split(',');
        string[] RTChannelLimit2    = ConfigHelper.GetConfigString("RTChannelLimit2").Split(',');
        string[] RT_Classification1 = ConfigHelper.GetConfigString("Classification1").Split(',');
        string[] RT_Classification2 = ConfigHelper.GetConfigString("Classification2").Split(',');
        if (RTChannelLimit1.Contains(_bll.Model["RTChannel"]) && !RT_Classification1.Contains(_bll.Model["Classification"]) ||
            RTChannelLimit2.Contains(_bll.Model["RTChannel"]) && !RT_Classification2.Contains(_bll.Model["Classification"]))
        {
            MessageBox.Show(this, "“门店渠道”与“门店归类”匹配不规范,请重新选填!");
            return;
        }


        #region 判断活跃标志
        if (_bll.Model.ActiveFlag == 1 && _bll.Model.CloseTime != new DateTime(1900, 1, 1))
        {
            _bll.Model.CloseTime = new DateTime(1900, 1, 1);
        }

        if (_bll.Model.ActiveFlag == 2 && _bll.Model.CloseTime == new DateTime(1900, 1, 1))
        {
            _bll.Model.CloseTime = DateTime.Now;
        }
        #endregion

        #region 自动设定“是否促销店”字段
        switch (_bll.Model["RTClassify"])
        {
        case "2":          //返利店
            _bll.Model["IsPromote"] = "2";
            _bll.Model["IsRebate"]  = "1";
            break;

        case "3":          //导购店
            _bll.Model["IsPromote"] = "1";
            _bll.Model["IsRebate"]  = "2";
            break;

        case "4":          //导购返利店
            _bll.Model["IsPromote"] = "1";
            _bll.Model["IsRebate"]  = "1";
            break;

        case "1":          //流通店
        default:
            _bll.Model["IsPromote"] = "2";
            _bll.Model["IsRebate"]  = "2";
            break;
        }
        #endregion

        Addr_OfficialCity city = new Addr_OfficialCityBLL(_bll.Model.OfficalCity).Model;
        if (city != null)
        {
            if (_bll.Model.PostCode == "")
            {
                _bll.Model.PostCode = city.PostCode;
            }
            if (_bll.Model["Township"] == "" && city.Level == 4)
            {
                _bll.Model["Township"] = city.Name;
            }
        }

        if (ViewState["ClientID"] == null)
        {
            _bll.Model.ClientType  = 3;
            _bll.Model.ApproveFlag = 2;
            _bll.Model.InsertStaff = (int)Session["UserID"];
            ViewState["ClientID"]  = _bll.Add();
        }
        else
        {
            _bll.Model.UpdateStaff = (int)Session["UserID"];
            _bll.Update();
        }
        if (sender != null)
        {
            MessageBox.ShowAndRedirect(this, "保存终端门店资料成功!", "RetailerDetail.aspx?ClientID=" + ViewState["ClientID"].ToString());
        }
    }
    private void BindData()
    {
        CM_ClientBLL _bll = new CM_ClientBLL((int)ViewState["ClientID"]);
        CM_Client    m    = _bll.Model;

        switch (m.ClientType)
        {
        case 1:
            Response.Redirect("../Store/StoreDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 2:
            Response.Redirect("../DI/DistributorDetail.aspx?ClientID=" + m.ID.ToString());
            break;

        case 3:
            break;

        default:
            MessageBox.ShowAndRedirect(this, "请先在‘零售商列表’中选择要查看的零售商!", "RetailerList.aspx?URL=" + Request.Url.PathAndQuery);
            break;
        }

        pl_detail.BindData(m);


        //lbl_preSales.Text = _bll.GetSalesVolume(AC_AccountMonthBLL.GetCurrentMonth() - 1).ToString();
        //lbl_AvageSales.Text = _bll.GetSalesVolumeAvg().ToString();

        MCSSelectControl select_ClientManager = (MCSSelectControl)pl_detail.FindControl("CM_Client_ClientManager");

        if (select_ClientManager != null)
        {
            select_ClientManager.PageUrl = "~/SubModule/StaffManage/Pop_Search_Staff.aspx?OrganizeCity=" + m.OrganizeCity + "&IncludeSuperManager=Y";
        }

        MCSSelectControl select_Supplier = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier");

        if (select_Supplier != null)
        {
            select_Supplier.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\"";
        }

        MCSSelectControl select_Supplier2 = (MCSSelectControl)pl_detail.FindControl("CM_Client_Supplier2");

        if (select_Supplier2 != null)
        {
            select_Supplier2.PageUrl = "~/SubModule/CM/PopSearch/Search_SelectClient.aspx?ClientType=2&OrganizeCityEnabled=Y&OrganizeCity=" + m.OrganizeCity + "&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7) IN (1,2)\"";
        }

        if (m.ApproveFlag == 1)
        {
            //已审核
            TextBox tbx_OpenTime = (TextBox)pl_detail.FindControl("CM_Client_OpenTime");

            if (m.ActiveFlag == 1)
            {
                if (tbx_OpenTime != null && tbx_OpenTime.Text != "")
                {
                    tbx_OpenTime.Enabled = false;
                }
                bt_AddApply.Visible = false;
            }
            else
            {
                TextBox tbx_CloseTime = (TextBox)pl_detail.FindControl("CM_Client_CloseTime");
                if (tbx_CloseTime != null && tbx_CloseTime.Text != "")
                {
                    tbx_CloseTime.Enabled = false;
                }
                bt_RevocationApply.Visible = false;
            }

            Header.Attributes["WebPageSubCode"] = "Modify";
            bt_Approve.Visible = false;
        }
        else
        {
            bt_RevocationApply.Visible = false;
        }

        if (string.IsNullOrEmpty(m["TaskID"]))
        {
            bt_Record.Visible = false;
        }
        else
        {
            if (m["State"] == "2")
            {
                //审批中,不可修改数据
                bt_AddApply.Visible        = false;
                bt_RevocationApply.Visible = false;
                bt_OK.Visible = false;
                bt_RevocationApply.Visible = false;
            }
        }


        #region 绑定该客户的首要联系人
        DropDownList ddl_ChiefLinkMan = pl_detail.FindControl("CM_Client_ChiefLinkMan") != null ? (DropDownList)pl_detail.FindControl("CM_Client_ChiefLinkMan") : null;
        try
        {
            ddl_ChiefLinkMan.DataTextField  = "Name";
            ddl_ChiefLinkMan.DataValueField = "ID";
            ddl_ChiefLinkMan.DataSource     = CM_LinkManBLL.GetModelList("ClientID=" + ViewState["ClientID"].ToString());
            ddl_ChiefLinkMan.DataBind();

            ddl_ChiefLinkMan.Items.Insert(0, new ListItem("请选择", "0"));
            ddl_ChiefLinkMan.SelectedValue = m.ChiefLinkMan.ToString();
        }
        catch { }

        #endregion

        BindGrid();
        //MessageBox.Show(this, Session["UserID"].ToString());
        bt_ReplaceClientManager.OnClientClick = "javascript:PopReplaceClientManager(" + m.ClientManager.ToString() + "," + m.ClientType.ToString() + ")";

        //管理员登录状况下  雅慧电商的流通店  数据有误发出警报
        if (Session["UserID"].ToString() == "1" && m["RTChannel"] != "20" && m["RTClassify"] == "1" &&
            (m["IsRMSClient"] != "2" || m["RMSAccountEnabled"] != "2"))
        {
            MessageBox.Show(this, "非雅慧电商的流通店积分店状态(" + m["IsRMSClient"] + ")或积分账户启用否(" + m["RMSAccountEnabled"] + ")数据有误");
        }
    }