Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         TextBox1.Text = Addr_OrganizeCityParamBLL.GetValueByType(1, 21);
     }
 }
Exemple #2
0
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        decimal val;

        if (decimal.TryParse(Addr_OrganizeCityParamBLL.GetValueByType(1, 8), out val))
        {
            SVM_OrganizeTargetBLL _bll = new SVM_OrganizeTargetBLL((int)ViewState["TargetID"]);
            decimal oldvalue           = _bll.Model.SalesTarget;
            dv_detail.GetData(_bll.Model);
            decimal changevalue = _bll.Model.SalesTargetAdjust;
            if (oldvalue * val >= Math.Abs(changevalue))
            {
                _bll.Model.SalesTargetAdjust = val;
                _bll.Update();
                BindData();
            }
            else
            {
                MessageBox.Show(this, "系统限定必须在原有目标值基础上浮动调整" + val + "%以内,请重新调整!");
                return;
            }
        }
        else
        {
            MessageBox.Show(this, "系统参数中未维护调整浮动比例,或浮动比例维护有误!");
        }

        if (sender != null)
        {
            MessageBox.Show(this, "修改成功!");
        }
    }
    private void BindGrid()
    {
        int City      = int.Parse(tr_OrganizeCity.SelectValue);
        int paramType = int.Parse(ddl_ParamType.SelectedValue);
        int check     = cb_include.Checked ? 1 : 0;

        div_detail.Visible = false;
        gv_List.DataSource = Addr_OrganizeCityParamBLL.GetByOrganizeCity(City, paramType, check);
        gv_List.DataBind();
    }
 private void bindDetail(int detailID)
 {
     div_detail.Visible = true;
     if (detailID > 0)
     {
         Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL(detailID);
         ddl_ParamType2.SelectedValue = param.Model.ParamType.ToString();
         tbx_ParamValue.Text          = param.Model.ParamValue;
         tbx_Remark.Text = param.Model.Remark;
     }
 }
 protected void bt_Save_Click(object sender, EventArgs e)
 {
     if (gv_List.SelectedIndex >= 0)
     {
         int detail = int.Parse(gv_List.DataKeys[gv_List.SelectedIndex]["ID"].ToString());
         Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL(detail);
         param.Model.ParamType       = int.Parse(ddl_ParamType2.SelectedValue);
         param.Model.ParamValue      = tbx_ParamValue.Text;
         param.Model.Remark          = tbx_Remark.Text;
         param.Model.UpdateStaff     = int.Parse(Session["UserID"].ToString());
         tr_OrganizeCity.SelectValue = param.Model.OrganizeCity.ToString();
         if (Addr_OrganizeCityParamBLL.GetModelList("OrganizeCity="
                                                    + param.Model.OrganizeCity
                                                    + " AND ParamType="
                                                    + int.Parse(ddl_ParamType2.SelectedValue)
                                                    + " AND ID <> " + detail).Count > 0)
         {
             MessageBox.Show(this, "当前片区已存在此标准!");
             return;
         }
         if (param.Update() < 0)
         {
             MessageBox.Show(this, "保存失败!");
         }
     }
     else
     {
         Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL();
         param.Model.ParamType    = int.Parse(ddl_ParamType2.SelectedValue);
         param.Model.ParamValue   = tbx_ParamValue.Text;
         param.Model.Remark       = tbx_Remark.Text;
         param.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
         param.Model.InsertStaff  = int.Parse(Session["UserID"].ToString());
         if (Addr_OrganizeCityParamBLL.GetModelList("OrganizeCity="
                                                    + param.Model.OrganizeCity
                                                    + " AND ParamType="
                                                    + int.Parse(ddl_ParamType2.SelectedValue)).Count > 0)
         {
             MessageBox.Show(this, "当前片区已存在此标准!");
             return;
         }
         if (param.Add() < 0)
         {
             MessageBox.Show(this, "保存失败!");
         }
     }
     ddl_ParamType.SelectedValue = "0";
     cb_include.Checked          = false;
     BindGrid();
 }
    protected void bt_Save_Click(object sender, EventArgs e)
    {
        if (gv_List.SelectedIndex >= 0)
        {
            int detail = int.Parse(gv_List.DataKeys[gv_List.SelectedIndex]["ID"].ToString());
            Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL(detail);
            param.Model.ParamType = int.Parse(ddl_ParamType2.SelectedValue);
            param.Model.ParamValue = tbx_ParamValue.Text;
            param.Model.Remark = tbx_Remark.Text;
            param.Model.UpdateStaff = int.Parse(Session["UserID"].ToString());
            tr_OrganizeCity.SelectValue = param.Model.OrganizeCity.ToString();
            if (Addr_OrganizeCityParamBLL.GetModelList("OrganizeCity="
                + param.Model.OrganizeCity
                + " AND ParamType="
                + int.Parse(ddl_ParamType2.SelectedValue)
                + " AND ID <> " + detail).Count > 0)
            {
                MessageBox.Show(this, "当前片区已存在此标准!");
                return;
            }
            if (param.Update() < 0)
                MessageBox.Show(this, "保存失败!");

        }
        else
        {
            Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL();
            param.Model.ParamType = int.Parse(ddl_ParamType2.SelectedValue);
            param.Model.ParamValue = tbx_ParamValue.Text;
            param.Model.Remark = tbx_Remark.Text;
            param.Model.OrganizeCity = int.Parse(tr_OrganizeCity.SelectValue);
            param.Model.InsertStaff = int.Parse(Session["UserID"].ToString());
            if (Addr_OrganizeCityParamBLL.GetModelList("OrganizeCity="
                + param.Model.OrganizeCity
                + " AND ParamType="
                + int.Parse(ddl_ParamType2.SelectedValue)).Count > 0)
            {
                MessageBox.Show(this, "当前片区已存在此标准!");
                return;
            }
            if (param.Add() < 0)
                MessageBox.Show(this, "保存失败!");

        }
        ddl_ParamType.SelectedValue = "0";
        cb_include.Checked = false;
        BindGrid();
    }
Exemple #7
0
    private void LoadGiftApplyAmount()
    {
        int month  = 0;
        int client = 0;

        int.TryParse(ddl_AccountMonth.SelectedValue, out month);
        int.TryParse(select_Client.SelectValue, out client);

        if (month > 0 && client > 0)
        {
            IList <ORD_GiftApplyAmount> lists = ORD_GiftApplyAmountBLL.GetModelList(string.Format("AccountMonth={0} AND Client={1}", month, client));
            if (lists.Count == 0)
            {
                ORD_GiftApplyAmountBLL.ComputAvailableAmount(month, client);
            }

            int pulishid     = 0;
            int brand        = 0;
            int giftclassify = 0;

            int.TryParse(ddl_Publish.SelectedValue, out pulishid);

            if (pulishid > 0)
            {
                ORD_ApplyPublishBLL publish = new ORD_ApplyPublishBLL(pulishid);
                int.TryParse(publish.Model["ProductBrand"], out brand);
                int.TryParse(publish.Model["GiftClassify"], out giftclassify);

                lists = ORD_GiftApplyAmountBLL.GetModelList(string.Format("AccountMonth={0} AND Client={1} AND Brand={2} AND Classify={3}", month, client, brand, giftclassify));
                if (lists.Count > 0)
                {
                    lb_GiftApplyAmount.Text = string.Format("销量:{0:0.#元},赠品费率:{1:0.###%},赠品总额度:{2:0.#元}, 赠品额度余额:{3:0.#元}", lists[0].SalesVolume, lists[0].FeeRate, lists[0].AvailableAmount + lists[0].PreBalance - lists[0].DeductibleAmount, lists[0].BalanceAmount);
                }
                else
                {
                    string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });

                    lb_GiftApplyAmount.Text = nolimitbrand.Contains(publish.Model["ProductBrand"])?"本品类不限制申请额度":"上月无销量!";
                }
            }
        }
    }
    private void BindData(PM_PromotorSalary m)
    {
        if (m != null)
        {
            ViewState["PromotorID"]       = m.Promotor;
            ViewState["PromotorSalaryID"] = m.ID;
        }

        #region 获取当前导购标准薪资、保底薪资、导购管理费
        if ((int)ViewState["PromotorID"] > 0)
        {
            decimal basepay = 0, minumumwage = 0, rtmanagecost = 0;
            new PM_PromotorBLL((int)ViewState["PromotorID"]).GetStdPay(out basepay, out minumumwage, out rtmanagecost);
            ViewState["BasePay"]      = basepay;
            ViewState["MinumumWage"]  = minumumwage;
            ViewState["RTManageCost"] = rtmanagecost;
        }
        #endregion
        PM_Promotor p = new PM_PromotorBLL((int)ViewState["PromotorID"]).Model;
        if (p == null)
        {
            Response.Redirect("PM_PromotorDetail.aspx");
        }
        if (m == null)
        {
            m              = new PM_PromotorSalary();
            m.Promotor     = (int)ViewState["PromotorID"];
            m.State        = 1;
            m.InsertStaff  = (int)Session["UserID"];
            m.RTManageCost = (decimal)ViewState["RTManageCost"];
            if (p["Classfiy"] == "1" || p["Classfiy"] == "2")
            {
                m.SeniorityPayMode = 1;
            }
        }
        if (p["State"] == "2")
        {
            bt_Add.Visible = false;
        }

        UC_DetailView1.BindData(m);
        chk_arrivetarget.Checked = m["ISArriveTarget"] == "1";
        UC_DetailView1.SetControlsEnable(m.State == 1);
        bt_OK.Enabled = m.State == 1;

        if (m.ID != 0)
        {
            bt_Delete.Enabled  = m.State == 1;
            bt_Submit.Enabled  = m.State == 1;
            bt_Approve.Enabled = m.State == 1;
        }
        else
        {
            bt_Submit.Enabled  = false;
            bt_Approve.Enabled = false;
            bt_Delete.Enabled  = false;
        }
        if (m.BasePayMode != 4 && m.BasePayMode != 5)
        {
            setdisabledfloatingcontorl(false);
        }


        //导购为新入职、或离职状态
        if (p.ApproveFlag == 2)
        {
            bt_Submit.Visible = false;
        }
        //if (p.Dimission == 2) bt_Add.Visible = false;

        if (m.RTManageCost > 0 && (decimal)ViewState["RTManageCost"] == m.RTManageCost)
        {
            TextBox tbx = (TextBox)UC_DetailView1.FindControl("PM_PromotorSalary_RTManageCost");
            if (tbx != null)
            {
                tbx.Enabled = false;
            }
        }
        if (m.State < 2)
        {
            #region 兼职导购的限定
            try
            {
                if (ddl_BasePayMode != null)
                {
                    if (p["Classfiy"] != "1" && p["Classfiy"] != "2")   //非专职、非流导,认为是兼职导购
                    {
                        //兼职
                        //ddl_BasePayMode.Items[0].Enabled = false;
                        //ddl_BasePayMode.Items[1].Enabled = false;
                        //ddl_BasePayMode.Items[2].Enabled = false;
                        SetControlsEnable(false);
                        ddl_BasePayMode.SelectedValue = "3";
                        ddl_BasePayMode.Enabled       = false;
                    }
                    else
                    {
                        Addr_OrganizeCityBLL _bll   = new Addr_OrganizeCityBLL(p.OrganizeCity);
                        string[]             city3s = Addr_OrganizeCityParamBLL.GetValueByType(1, 19).Split(new char[] { ',', ',', ';', ';' });
                        int city3ID = TreeTableBLL.GetSuperIDByLevel("MCS_SYS.dbo.Addr_OrganizeCity", p.OrganizeCity, ConfigHelper.GetConfigInt("OrganizePartCity-CityLevel"));

                        if (city3s.Contains(city3ID.ToString()))
                        {
                            ddl_BasePayMode.Items.Remove(new ListItem("浮动底薪(非华南)", "4"));
                        }
                        else
                        {
                            decimal AvgSales = 0, BaseFeeRate = 0;
                            int     SalaryDelayDays = ConfigHelper.GetConfigInt("SalaryDelayDays");
                            ddl_SalesType.Enabled = false;
                            new PM_PromotorSalaryBLL().GetFloatingInfo(p.ID, AC_AccountMonthBLL.GetMonthByDate(DateTime.Now.AddDays(-SalaryDelayDays)) - 1, out AvgSales, out BaseFeeRate);

                            if (AvgSales == 0 && BaseFeeRate == 0)//首两月不是固定底薪,不能选择浮动底薪
                            {
                                ddl_BasePayMode.Items.Remove(new ListItem("浮动底薪(非华南)", "4"));
                            }
                            else
                            {
                                ViewState["AvgSales"]    = AvgSales;
                                ViewState["BaseFeeRate"] = BaseFeeRate;
                            }

                            ddl_BasePayMode.Items.Remove(new ListItem("浮动底薪(华南)", "5"));
                        }
                        ddl_BasePayMode.Items.Remove(new ListItem("兼职底薪", "3"));
                        //50岁只能选择商保(5)或自购(8)
                        DateTime Birthday;
                        if (DateTime.TryParse(p["Birthday"], out Birthday) && Birthday.AddYears(50) < DateTime.Now)
                        {
                            foreach (ListItem item in ddl_InsuranceMode.Items)
                            {
                                if (item.Value != "5" && item.Value != "8" && item.Value != "0")
                                {
                                    item.Enabled = false;
                                }
                            }
                        }
                        //专职或流导
                        //ddl_BasePayMode.Items[3].Enabled = false;
                    }
                }
            }
            catch { }
            #endregion

            ddl_BasePayMode_SelectedIndexChanged(null, null);
            ddl_BasePaySubsidyMode_SelectedIndexChanged(null, null);
            ddl_InsuranceMode_SelectedIndexChanged(null, null);
            ddl_MinimumWageMode_SelectedIndexChanged(null, null);
        }
        BindGrid();
    }
    protected void bt_AddApply_Click(object sender, EventArgs e)
    {
        if ((int)ViewState["PromotorID"] == 0)
        {
            MessageBox.Show(this, "对不起,请您先保存后在发起申请");
            return;
        }
        bt_OK_Click(null, null);

        PM_PromotorBLL bll = new PM_PromotorBLL((int)ViewState["PromotorID"]);
        DateTime       birthday;

        if (DateTime.TryParse(bll.Model["Birthday"], out birthday))
        {
            if (DateTime.Now < birthday.AddYears(16) || DateTime.Now > birthday.AddYears(50))
            {
                int year = DateTime.Now.Year - birthday.Year;
                if (birthday.AddYears(year) > DateTime.Now)
                {
                    year++;
                }
                MessageBox.Show(this, "对不起,该导购年龄不符合规则(16~49岁),该人员年龄:" + year);
                return;
            }
        }
        if (PM_PromotorNumberLimitBLL.CheckAllowAdd(bll.Model.OrganizeCity, int.Parse(bll.Model["Classfiy"])) < 0)
        {
            MessageBox.Show(this, "对不起当前城市导购员人数满额,要想继续新增请与人事经理联系");
            return;
        }
        if (bll.Model.BeginWorkDate.AddDays(40) < DateTime.Now)
        {
            MessageBox.Show(this, "对不起,入职时间必须在发起日期前40天之内!");
            return;
        }
        if (bll.Model["IDCode"] == "")
        {
            MessageBox.Show(this, "请录入身份证号!");
            return;
        }
        if (bll.Model["InfoSource"] == "" || bll.Model["InfoSource"] == "0")
        {
            MessageBox.Show(this, "请正确选择导购来源!");
            return;
        }
        if (bll.Model["OldClassify"] == "" || bll.Model["OldClassify"] == "0")
        {
            MessageBox.Show(this, "请正确选择原属品牌!");
            return;
        }
        if (bll.Model["BankType"] == "" || bll.Model["BankType"] == "0")
        {
            MessageBox.Show(this, "请正确选择银行信息");
            return;
        }
        string[]        allowday  = Addr_OrganizeCityParamBLL.GetValueByType(1, 3).Split(new char[] { ',', ',', ';', ';' });
        AC_AccountMonth lastmonth = GetMaxSalaryDate((int)ViewState["PromotorID"], AC_AccountMonthBLL.GetCurrentMonth() - 1);

        if (lastmonth != null && allowday.Contains(DateTime.Now.Day.ToString()) && bll.Model.BeginWorkDate > lastmonth.EndDate)
        {
            MessageBox.Show(this, "该导购在" + lastmonth.Name + "生成过工资,入职日期不能大于" + lastmonth.EndDate.ToString("yyyy-MM-dd"));
            return;
        }

        #region 判断是否KA店导购
        bool IsKAChannel = false;         //是否KA店导购

        if (bll.Model["Classify"] != "2") //非流导
        {
            IList <PM_PromotorInRetailer> retailers = PM_PromotorInRetailerBLL.GetModelList(" Promotor=" + ViewState["PromotorID"].ToString());
            if (retailers.Count == 0)
            {
                MessageBox.Show(this, "对不起,请关联该导购所在的工作门店!");
                return;
            }

            //判断导购是否在KA店工作
            foreach (PM_PromotorInRetailer item in retailers)
            {
                CM_Client client = new CM_ClientBLL(item.Client).Model;
                if (client["RTChannel"] == "1" || client["RTChannel"] == "2")
                {
                    IsKAChannel = true;
                }
            }
        }
        #endregion

        #region 判断是否超薪酬超准
        bool bSalaryFlag = false;   //false : 薪酬标准内 true:超标准
        IList <PM_PromotorSalary> salarylists = PM_PromotorSalaryBLL.GetModelList("Promotor=" + bll.Model.ID.ToString() + " AND State IN(1,3) Order BY State");

        if (salarylists.Count == 0 || salarylists.Count > 0 && (bll.Model["Classfiy"] == "6" && salarylists[0].BasePayMode != 3 || bll.Model["Classfiy"] != "6" && salarylists[0].BasePayMode == 3))
        {
            MessageBox.Show(this, "对不起,尚未为该导购设定薪酬信息,请设定完薪酬信息后,再提交入职申请!");
            return;
        }
        else
        {
            PM_PromotorSalary salary = salarylists[0];
            if (salary.BasePaySubsidy > 0)
            {
                bSalaryFlag = true;                              //有底薪补贴
            }
            if (salary.MinimumWageMode == 2)
            {
                bSalaryFlag = true;                              //特殊保底
            }
            if (salary.InsuranceMode == 1 && salary.InsuranceSubsidy > 100)
            {
                bSalaryFlag = true;                                                                 //社保补贴大于100元的
            }
        }
        #endregion

        int budget = PM_PromotorNumberLimitBLL.CheckOverBudget(bll.Model.OrganizeCity, int.Parse(bll.Model["Classfiy"]));

        NameValueCollection dataobjects = new NameValueCollection();
        dataobjects.Add("ID", ViewState["PromotorID"].ToString());
        dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
        dataobjects.Add("SalaryFlag", !bSalaryFlag ? "1" : "2");      //薪酬标志 1:薪酬标准内 2:薪酬标准外
        dataobjects.Add("StaffName", bll.Model.Name.ToString());
        dataobjects.Add("IsKAChannel", IsKAChannel ? "1" : "2");      //是否KA卖场的导购
        dataobjects.Add("IsOverBudget", budget < 0 ? "1" : "2");      //是否超人数预算 1:超 2:未超


        int TaskID = EWF_TaskBLL.NewTask("Add_Promotor", (int)Session["UserID"], "新增导购员流程,姓名:" + bll.Model.Name + "【" + ddl_Classify.SelectedItem.Text.ToString() + "】", "~/SubModule/PM/PM_PromotorDetail.aspx?PromotorID=" + ViewState["PromotorID"].ToString(), dataobjects);
        if (TaskID > 0)
        {
            bll.Submit(TaskID, (int)Session["UserID"]);
        }

        Response.Redirect("~/SubModule/EWF/Apply.aspx?TaskID=" + TaskID.ToString());
    }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        PM_PromotorBLL _promotor = null;

        if ((int)ViewState["PromotorID"] == 0)
        {
            _promotor = new PM_PromotorBLL();
        }
        else
        {
            _promotor = new PM_PromotorBLL((int)ViewState["PromotorID"]);
        }

        int classify = 0, oldClassify = 0;

        int.TryParse(_promotor.Model["Classfiy"], out oldClassify);
        int oldOrganizeCity = _promotor.Model.OrganizeCity;

        UC_DetailView1.GetData(_promotor.Model);

        #region 判断数据有效性
        if (!(_promotor.Model.OrganizeCity > 1))
        {
            MessageBox.Show(this, "请选择导购员所在的管理片区!");
            return;
        }
        int.TryParse(_promotor.Model["Classfiy"], out classify);
        if (classify == 0)
        {
            MessageBox.Show(this, "请正确选择导购员类别!");
            return;
        }
        if (_promotor.Model["InfoSource"] == "" || _promotor.Model["InfoSource"] == "0")
        {
            MessageBox.Show(this, "请正确选择导购来源!");
            return;
        }
        if (_promotor.Model["OldClassify"] == "" || _promotor.Model["OldClassify"] == "0")
        {
            MessageBox.Show(this, "请正确选择原属品牌!");
            return;
        }
        if (_promotor.Model["BankType"] == "" || _promotor.Model["BankType"] == "0")
        {
            MessageBox.Show(this, "请正确选择银行信息");
            return;
        }
        int bankid = int.Parse(ddl_BankType.SelectedValue);
        if (_promotor.Model["BankName"] == "" || bankid <= 2 && _promotor.Model["BankName"] != ddl_BankType.SelectedItem.Text)
        {
            MessageBox.Show(this, "银行备注信息不正确");
            return;
        }
        //Org_Staff _staffM = new Org_StaffBLL((int)Session["UserID"]).Model;
        //if (_staffM.OrganizeCity == _promotor.Model.OrganizeCity)
        //{
        //    MessageBox.Show(this, "对不起,你不能把导购员放在与你同级的管理片区");
        //    return;
        //}

        #endregion


        #region 判断在职及离职状态
        if (_promotor.Model.Dimission == 1)
        {
            _promotor.Model.EndWorkDate = new DateTime(1900, 1, 1);
        }
        else if (_promotor.Model.EndWorkDate == new DateTime(1900, 1, 1))
        {
            _promotor.Model.EndWorkDate = DateTime.Today;
        }
        #endregion
        #region 如果有工资生成判断离职时间
        if ((int)ViewState["PromotorID"] > 0)
        {
            string[]        allowday  = Addr_OrganizeCityParamBLL.GetValueByType(1, 3).Split(new char[] { ',', ',', ';', ';' });
            AC_AccountMonth lastmonth = GetMaxSalaryDate((int)ViewState["PromotorID"], AC_AccountMonthBLL.GetCurrentMonth() - 1);
            if (lastmonth != null && allowday.Contains(DateTime.Now.Day.ToString()) && _promotor.Model.BeginWorkDate > lastmonth.EndDate)
            {
                MessageBox.Show(this, "该导购在" + lastmonth.Name + "生成过工资,入职日期不能大于" + lastmonth.EndDate.ToString("yyyy-MM-dd"));
                return;
            }
            if (_promotor.Model.Dimission == 2 && _promotor.Model.EndWorkDate < _promotor.Model.BeginWorkDate && _promotor.Model.EndWorkDate.AddDays(40) > DateTime.Now)
            {
                MessageBox.Show(this, "导购离职日期不能小于入职日期!");
                return;
            }
            AC_AccountMonth month = GetMaxSalaryDate((int)ViewState["PromotorID"], 0);
            if (month != null && _promotor.Model.Dimission == 2 && _promotor.Model.EndWorkDate < month.BeginDate)
            {
                MessageBox.Show(this, "该导购在" + month.Name + "生成过工资,离职日期不能小于" + month.BeginDate.ToString("yyyy-MM-dd"));
                return;
            }
        }
        #endregion
        if (_promotor.Model["IDCode"] != string.Empty && _promotor._GetModelList("ID!=" + ViewState["PromotorID"].ToString() + " AND MCS_SYS.dbo.UF_Spilt(PM_Promotor.ExtPropertys,'|',1)='" + _promotor.Model["IDCode"] + "'").Count > 0)
        {
            MessageBox.Show(this, "对不起,该身份证号的导购员已在系统中,请核实后再新增!");
            return;
        }

        if ((int)ViewState["PromotorID"] == 0)
        {
            DateTime birthday;
            if (DateTime.TryParse(_promotor.Model["Birthday"], out birthday))
            {
                if (DateTime.Now < birthday.AddYears(16) || DateTime.Now > birthday.AddYears(50))
                {
                    int year = DateTime.Now.Year - birthday.Year;
                    if (birthday.AddYears(year) > DateTime.Now)
                    {
                        year++;
                    }
                    MessageBox.Show(this, "对不起,该导购年龄不符合规则(16~49岁),该人员年龄:" + year);
                    return;
                }
            }

            if (PM_PromotorNumberLimitBLL.CheckAllowAdd(_promotor.Model.OrganizeCity, classify) <= 0)
            {
                MessageBox.Show(this, "对不起当前城市导购员人数满额,要想继续新增请与人事经理联系");
                return;
            }

            _promotor.Model.InputStaff  = (int)Session["UserID"];
            _promotor.Model.ApproveFlag = 2;
            _promotor.Model.Dimission   = 1;
            _promotor.Model.EndWorkDate = new DateTime(1900, 1, 1);
            ViewState["PromotorID"]     = _promotor.Add();
        }
        else
        {
            if (!PM_PromotorNumberLimitBLL.IsSameLimit(oldOrganizeCity, _promotor.Model.OrganizeCity, oldClassify, classify) &&
                PM_PromotorNumberLimitBLL.CheckAllowAdd(_promotor.Model.OrganizeCity, classify) <= 0)
            {
                MessageBox.Show(this, "对不起当前城市导购员人数满额,要想继续新增请与人事经理联系");
                return;
            }

            _promotor.Model.UpdateStaff = (int)Session["UserID"];
            _promotor.Update();
        }
        if (sender != null)
        {
            Response.Redirect("PM_PromotorDetail.aspx?PromotorID=" + ViewState["PromotorID"].ToString());
        }
    }
    private void BindData()
    {
        PM_Promotor m = new PM_PromotorBLL((int)ViewState["PromotorID"]).Model;

        UC_DetailView1.BindData(m);
        gv_list.ConditionString = " Promotor= " + (int)ViewState["PromotorID"];
        gv_list.BindGrid();

        //验证身份证号码
        txt_BankName.Enabled = m["BankType"] == "3";

        if (m.ApproveFlag == 1)
        {
            bt_Approve.Visible = false;
            if (m.Dimission == 1)
            {
                TextBox txt_EndWorkDate = (TextBox)UC_DetailView1.FindControl("PM_Promotor_EndWorkDate");
                if (txt_EndWorkDate != null)
                {
                    txt_EndWorkDate.Enabled = false;
                }

                bt_AddApply.Visible = false;
                #region 导购兼职/专职转换
                int classfiy = 0;
                int.TryParse(m["Classfiy"], out classfiy);
                if (classfiy == 0)
                {
                    bt_ChangeClassify.Visible = false;
                }
                else if (classfiy == 1 || classfiy == 2)
                {
                    bt_ChangeClassify.Text    = "转为兼职";
                    bt_ChangeClassify.Visible = true;
                }
                else
                {
                    bt_ChangeClassify.Text    = "转为专职/流动";
                    bt_ChangeClassify.Visible = true;
                }
                bt_ChangeClassify.OnClientClick = "PopPMClassify_Approve(" + ViewState["PromotorID"].ToString() + ")";
                #endregion
            }
            Header.Attributes["WebPageSubCode"] = "Modify";
            //TextBox txt_BeginWorkDate = (TextBox)UC_DetailView1.FindControl("PM_Promotor_BeginWorkDate");

            //临时开放修改功能
            //if (txt_BeginWorkDate != null && m.Dimission==1) txt_BeginWorkDate.Enabled = false;

            //有些离职日期会填写错误,更新为权限修改 12.11.21
            //if (m.Dimission == 2)
            //{
            //    TextBox txt_EndWorkDate = (TextBox)UC_DetailView1.FindControl("PM_Promotor_EndWorkDate");
            //    if (txt_EndWorkDate != null) txt_EndWorkDate.Enabled = false;
            //}
            string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 9).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
            if (allowdays.Contains(DateTime.Now.Day.ToString()))
            {
                bt_ChangeClassify.Enabled = false;
                bt_ChangeClassify.ToolTip = "导购工资生成期间不能互转";
            }
        }

        if (m["State"] == "2")
        {
            //审批中
            bt_AddApply.Visible       = false;
            bt_OK.Visible             = false;
            bt_TaskDetail.Visible     = true;
            bt_ChangeClassify.Enabled = false;
            bt_ChangeClassify.ToolTip = "该导购有未完成的流程,请待流程完成后,再做调整!";
        }
        bt_OK.Text      = "保 存";
        bt_OK.ForeColor = System.Drawing.Color.Red;


        if (m["Classfiy"] != "")
        {
            int budget = PM_PromotorNumberLimitBLL.CheckOverBudget(m.OrganizeCity, int.Parse(m["Classfiy"]));
            if (budget == 0)
            {
                lb_OverBudgetInfo.Text = "导购员数量已等于预定的预算人数,请注意!";
            }
            else if (budget < 0)
            {
                lb_OverBudgetInfo.Text = "导购员数量已超过预定的预算人数 " + (0 - budget).ToString() + "人,请注意!";
            }
        }


        if (m["IDCode"].Length == 18 && !Tools.DoVerifyIDCode(m["IDCode"]))
        {
            lb_OverBudgetInfo.Text += "         注意:该导购员身份证号码错误!";
        }

        ddl_Classify_SelectedIndexChanged(null, null);
    }
    protected void bt_UploadExcel_Click(object sender, EventArgs e)
    {
        Session["DataTable-SellIn"]  = null;
        Session["DataTable-SellOut"] = null;
        UpdatePanel3.Visible         = false;
        bt_Import.Enabled            = false;

        #region 保存文件
        if (!FileUpload1.HasFile)
        {
            MessageBox.Show(this.Page, "请选择要上传的文件!");
            return;
        }
        int FileSize = (FileUpload1.PostedFile.ContentLength / 1024);

        if (FileSize > ConfigHelper.GetConfigInt("MaxAttachmentSize"))
        {
            MessageBox.Show(this.Page, "上传的文件不能大于" + ConfigHelper.GetConfigInt("MaxAttachmentSize") +
                            "KB!当前上传文件大小为:" + FileSize.ToString() + "KB");
            return;
        }

        //判断文件格式
        string FileName = FileUpload1.PostedFile.FileName;
        FileName = FileName.Substring(FileName.LastIndexOf('\\') + 1);
        FileName = FileName.Substring(0, FileName.LastIndexOf('.'));

        string FileExtName = FileUpload1.PostedFile.FileName.Substring(FileUpload1.PostedFile.FileName.LastIndexOf(".") + 1).ToLowerInvariant();

        if (FileExtName != "xls")
        {
            MessageBox.Show(this, "对不起,必须上传扩展名为xls的Excel文件!");
            return;
        }

        string path = ConfigHelper.GetConfigString("AttachmentPath");
        if (path.StartsWith("~"))
        {
            path = Server.MapPath(path);
        }
        if (!path.EndsWith("\\"))
        {
            path = path + "\\";
        }
        path += "ImportExcelSVM\\Upload\\" + Session["UserName"].ToString() + "\\";
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }

        path += FileName + "." + FileExtName;

        FileUpload1.SaveAs(path);
        #endregion

        #region 读取Excel文件
        string ErrorInfo = "";
        lb_ErrorInfo.Text = "";
        object           missing  = System.Reflection.Missing.Value;
        ApplicationClass ExcelApp = null;
        try
        {
            ExcelApp               = new ApplicationClass();
            ExcelApp.Visible       = false;
            ExcelApp.DisplayAlerts = false;

            Workbook  workbook1 = null;
            Worksheet worksheet1 = null, worksheet2 = null;

            try
            {
                workbook1 = ExcelApp.Workbooks.Open(path, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing, missing);

                #region 验证工作表数据格式
                if (workbook1.Worksheets.Count != 2)
                {
                    ErrorInfo += "Excel表格中必须且只能有2张工作表!";
                    goto End;
                }

                worksheet1 = (Worksheet)workbook1.Worksheets[1];
                worksheet2 = (Worksheet)workbook1.Worksheets[2];

                if (worksheet1.Name != "零售商进货")
                {
                    ErrorInfo += "Excel表格中第1个工作表名称必须为【零售商进货】!";
                    goto End;
                }
                if (worksheet2.Name != "零售商销货")
                {
                    ErrorInfo += "Excel表格中第2个工作表名称必须为【零售商销货】!";
                    goto End;
                }

                if (((Range)worksheet1.Cells[1, 1]).Text.ToString() != "零售商ID" ||
                    ((Range)worksheet1.Cells[1, 2]).Text.ToString() != "零售商编号" ||
                    ((Range)worksheet1.Cells[1, 3]).Text.ToString() != "零售商名称" ||
                    ((Range)worksheet1.Cells[1, 4]).Text.ToString() != "零售商分类" ||
                    ((Range)worksheet1.Cells[1, 5]).Text.ToString() != "归属月份")
                {
                    ErrorInfo += "零售商进货工作表表头(1~5列)错误!";
                    goto End;
                }

                if (((Range)worksheet2.Cells[1, 1]).Text.ToString() != "零售商ID" ||
                    ((Range)worksheet2.Cells[1, 2]).Text.ToString() != "零售商编号" ||
                    ((Range)worksheet2.Cells[1, 3]).Text.ToString() != "零售商名称" ||
                    ((Range)worksheet2.Cells[1, 4]).Text.ToString() != "零售商分类" ||
                    ((Range)worksheet2.Cells[1, 5]).Text.ToString() != "归属月份" ||
                    ((Range)worksheet2.Cells[1, 6]).Text.ToString() != "导购ID" ||
                    ((Range)worksheet2.Cells[1, 7]).Text.ToString() != "导购姓名")
                {
                    ErrorInfo += "零售商销货工作表表头(1~7列)错误!";
                    goto End;
                }


                string ParamValue = Addr_OrganizeCityParamBLL.GetValueByType(1, 26);
                ParamValue = string.IsNullOrEmpty(ParamValue) ? "0" : ParamValue;
                ParamValue = ParamValue.EndsWith(",") ? ParamValue.Remove(ParamValue.Length - 1) : ParamValue;

                IList <PDT_Product> productlists = PDT_ProductBLL.GetModelList(" Brand NOT IN(" + ParamValue + ") AND  Brand IN (SELECT ID FROM dbo.PDT_Brand WHERE IsOpponent='1') AND State=1 AND ApproveFlag=1 ORDER BY ISNULL(SubUnit,999999),Code");
                for (int i = 0; i < productlists.Count; i++)
                {
                    if (((Range)worksheet1.Cells[1, 6 + i]).Text.ToString() != productlists[i].ShortName)
                    {
                        ErrorInfo += "零售商进货工作表表头,(" + (6 + i).ToString() + "列)产品名称错误!必须为:" + productlists[i].ShortName;
                        goto End;
                    }
                    if (((Range)worksheet2.Cells[1, 8 + i]).Text.ToString() != productlists[i].ShortName)
                    {
                        ErrorInfo += "零售商进货工作表表头,(" + (8 + i).ToString() + "列)产品名称错误!必须为:" + productlists[i].ShortName;
                        goto End;
                    }
                }
                #endregion

                #region 创建DataTable
                System.Data.DataTable dtSellIn = new System.Data.DataTable();
                dtSellIn.Columns.Add(new System.Data.DataColumn("序号", Type.GetType("System.Int32")));
                dtSellIn.Columns.Add(new System.Data.DataColumn("零售商ID", Type.GetType("System.Int32")));
                dtSellIn.Columns.Add(new System.Data.DataColumn("零售商编号", Type.GetType("System.String")));
                dtSellIn.Columns.Add(new System.Data.DataColumn("零售商名称", Type.GetType("System.String")));
                dtSellIn.Columns.Add(new System.Data.DataColumn("零售商分类", Type.GetType("System.String")));
                dtSellIn.Columns.Add(new System.Data.DataColumn("归属月份", Type.GetType("System.String")));

                System.Data.DataTable dtSellOut = new System.Data.DataTable();
                dtSellOut.Columns.Add(new System.Data.DataColumn("序号", Type.GetType("System.Int32")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("零售商ID", Type.GetType("System.Int32")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("零售商编号", Type.GetType("System.String")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("零售商名称", Type.GetType("System.String")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("零售商分类", Type.GetType("System.String")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("归属月份", Type.GetType("System.String")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("导购ID", Type.GetType("System.Int32")));
                dtSellOut.Columns.Add(new System.Data.DataColumn("导购姓名", Type.GetType("System.String")));

                foreach (PDT_Product product in productlists)
                {
                    dtSellIn.Columns.Add(new System.Data.DataColumn("[" + product.ShortName + "]", Type.GetType("System.Int32")));
                    dtSellOut.Columns.Add(new System.Data.DataColumn("[" + product.ShortName + "]", Type.GetType("System.Int32")));
                }
                #endregion

                #region 读取Excel表格--零售商进货
                int sellinrow = 1;
                int emptyrow  = 0;
                while (true)
                {
                    sellinrow++;
                    if (((Range)worksheet1.Cells[sellinrow, 1]).Text.ToString() == string.Empty)
                    {
                        emptyrow++;
                        if (emptyrow > 5)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    int clientid = 0;
                    if (!int.TryParse(((Range)worksheet1.Cells[sellinrow, 1]).Text.ToString(), out clientid))
                    {
                        continue;
                    }
                    //DateTime selldate;
                    //if (!DateTime.TryParse(((Range)worksheet1.Cells[sellinrow, 5]).Text.ToString(), out selldate))
                    //{
                    //    continue;
                    //}

                    System.Data.DataRow row = dtSellIn.NewRow();
                    row[0] = sellinrow - 1;
                    row[1] = clientid;
                    row[2] = ((Range)worksheet1.Cells[sellinrow, 2]).Text.ToString();
                    row[3] = ((Range)worksheet1.Cells[sellinrow, 3]).Text.ToString();
                    row[4] = ((Range)worksheet1.Cells[sellinrow, 4]).Text.ToString();
                    row[5] = ((Range)worksheet1.Cells[sellinrow, 5]).Text.ToString();

                    for (int i = 0; i < productlists.Count; i++)
                    {
                        int quantity = 0;
                        int.TryParse(((Range)worksheet1.Cells[sellinrow, 6 + i]).Text.ToString(), out quantity);

                        row[6 + i] = quantity;
                    }

                    dtSellIn.Rows.Add(row);
                }

                Session["DataTable-SellIn"] = dtSellIn;
                #endregion

                #region 读取Excel表格--零售商销货
                int selloutrow = 1;
                emptyrow = 0;
                while (true)
                {
                    selloutrow++;
                    if (((Range)worksheet2.Cells[selloutrow, 1]).Text.ToString() == string.Empty)
                    {
                        emptyrow++;
                        if (emptyrow > 5)
                        {
                            break;
                        }
                        else
                        {
                            continue;
                        }
                    }

                    int clientid = 0;
                    if (!int.TryParse(((Range)worksheet2.Cells[selloutrow, 1]).Text.ToString(), out clientid))
                    {
                        continue;
                    }
                    //DateTime selldate;
                    //if (!DateTime.TryParse(((Range)worksheet2.Cells[selloutrow, 5]).Text.ToString(), out selldate))
                    //{
                    //    continue;
                    //}
                    int promotorid = 0;
                    if (((Range)worksheet2.Cells[selloutrow, 6]).Text.ToString() != "" &&
                        !int.TryParse(((Range)worksheet2.Cells[selloutrow, 6]).Text.ToString(), out promotorid))
                    {
                        continue;
                    }

                    System.Data.DataRow row = dtSellOut.NewRow();
                    row[0] = selloutrow - 1;
                    row[1] = clientid;
                    row[2] = ((Range)worksheet2.Cells[selloutrow, 2]).Text.ToString();
                    row[3] = ((Range)worksheet2.Cells[selloutrow, 3]).Text.ToString();
                    row[4] = ((Range)worksheet2.Cells[selloutrow, 4]).Text.ToString();
                    row[5] = ((Range)worksheet2.Cells[selloutrow, 5]).Text.ToString();
                    row[6] = promotorid;
                    row[7] = ((Range)worksheet2.Cells[selloutrow, 7]).Text.ToString();

                    for (int i = 0; i < productlists.Count; i++)
                    {
                        int quantity = 0;
                        int.TryParse(((Range)worksheet2.Cells[selloutrow, 8 + i]).Text.ToString(), out quantity);

                        row[8 + i] = quantity;
                    }

                    dtSellOut.Rows.Add(row);
                }

                Session["DataTable-SellIn"]  = dtSellIn;
                Session["DataTable-SellOut"] = dtSellOut;
                #endregion


End:
                ;
            }
            catch (System.Exception err)
            {
                string error = "Message:" + err.Message + "<br/>" + "Source:" + err.Source + "<br/>" +
                               "StackTrace:" + err.StackTrace + "<br/>";
                lb_ErrorInfo.Text = error;

                MessageBox.Show(this, "系统错误-4!" + err.Message);
            }
            finally
            {
                if (workbook1 != null)
                {
                    workbook1.Close(false, missing, missing);
                }

                if (worksheet1 != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet1);
                }
                if (worksheet2 != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(worksheet2);
                }
                if (workbook1 != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook1);
                }

                worksheet1 = null;
                worksheet2 = null;
                workbook1  = null;
            }
        }
        catch (System.Exception err)
        {
            string error = "Message:" + err.Message + "<br/>" + "Source:" + err.Source + "<br/>" +
                           "StackTrace:" + err.StackTrace + "<br/>";
            lb_ErrorInfo.Text = error;

            MessageBox.Show(this, "系统错误-5!" + err.Message);
        }
        finally
        {
            if (ExcelApp != null)
            {
                ExcelApp.Workbooks.Close();
                ExcelApp.Quit();

                System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApp);
                ExcelApp = null;
            }
            GC.Collect();
            //GC.WaitForPendingFinalizers();

            if (ErrorInfo != "")
            {
                lb_ErrorInfo.Text = ErrorInfo;
                MessageBox.Show(this, "对不起,Excel文件打开错误,请确认格式是否正确。错误提示:" + ErrorInfo);
                bt_Import.Enabled = false;
            }
            else
            {
                BindGrid();
                MessageBox.Show(this, "Excel文件上传并成功读取,请确认表格中的数据,无误后点【确认提交】按钮!");
                bt_Import.Enabled = true;
            }
        }
        #endregion
    }
Exemple #13
0
    //private void BindBudgetInfo(int month, int organizecity)
    //{
    //    tbl_BudgetInfo.Visible = true;
    //    int feetype = ConfigHelper.GetConfigInt("SalaryFeeType");

    //    lb_BudgetAmount.Text = (FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, feetype) +
    //        FNA_BudgetBLL.GetSumBudgetAmount(month, organizecity, 0)).ToString("0.###");

    //    lb_BudgetBalance.Text = (FNA_BudgetBLL.GetUsableAmount(month, organizecity, feetype) +
    //        FNA_BudgetBLL.GetUsableAmount(month, organizecity, 0)).ToString("0.###");
    //}
    #endregion



    private void BindData()
    {
        PM_SalaryBLL bll = new PM_SalaryBLL((int)ViewState["ID"]);

        pn_detail.BindData(bll.Model);
        ViewState["AccountMonth"] = bll.Model.AccountMonth;
        ViewState["ApplyMonth"]   = AC_AccountMonthBLL.GetMonthByDate(bll.Model.InputTime);
        ViewState["State"]        = bll.Model.State;

        #region 绑定管理片区
        Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
        tr_OrganizeCity.DataSource  = staff.GetStaffOrganizeCity();
        tr_OrganizeCity.RootValue   = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID.ToString();
        tr_OrganizeCity.SelectValue = bll.Model.OrganizeCity.ToString();
        lbl_PromotorCount.Text      = bll.Items.Count(p => p["FlagCancel"] != "1").ToString();
        lbl_SalesAmount.Text        = bll.Items.Where(p => p["FlagCancel"] != "1").Sum(p => p.ActSalesVolume).ToString();
        #endregion
        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y" && bll.Model.State == 2)
        {
            ViewState["Enable"] = true;
        }

        BindGrid();

        ShowBtnCancel(false);

        if (bll.Model.State != 1)
        {
            pn_detail.SetControlsEnable(false);

            bt_Delete.Visible = false;
            bt_Save.Visible   = false;
            bt_Submit.Visible = false;
            bt_Merge.Visible  = false;
        }
        else
        {
            //当前操作人为工资生成人(生成人未提交之前可以取消工资)
            int UserID = 0;
            if (int.TryParse(Session["UserID"].ToString(), out UserID) && UserID == bll.Model.InputStaff)
            {
                ShowBtnCancel(true);
            }
        }

        //if (bll.Model.State != 3)
        //{
        //    BindBudgetInfo((int)ViewState["ApplyMonth"], bll.Model.OrganizeCity);
        //}

        if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_Pass').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_bt_SaveDecisionComment').disabled='disabled'; </script>");
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "工资不能单条处理", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_WaitProcess').disabled='disabled'; </script>");
            string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 9).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
            if (!allowdays.Contains(DateTime.Now.Day.ToString()))
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "超时不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_NotPass').disabled='disabled'; </script>");
            }
            //流程中允许取消工资
            ShowBtnCancel(true);
        }
    }
Exemple #14
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int rtchannel    = int.Parse(ddl_RTChannel.SelectedValue);


        switch (MCSTabControl1.SelectedTabItem.Value)
        {
        case "0":
        {
            #region 显示统计分析
            DataTable dtSummary = PM_SalaryBLL.GetSummary(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue));
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }
            //MatrixTable.TableAddSummaryRow(dtSummary, "管理片区名称",
            //    new string[] { "导购员人数", "我司实发额", "上上月总销量", "上月总销量", "上月与上上月增长量", "本月总销量", "本月与上月增长量", "本月婴儿粉销量", "费用A", "费用B", "经销商承担薪资合计" });


            //dtSummary.Columns.Add("婴儿粉比(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,本月婴儿粉销量/本月总销量*100)").SetOrdinal(10);
            //dtSummary.Columns.Add("费率A(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用A/本月总销量*100)").SetOrdinal(13);
            //dtSummary.Columns.Add("费率B(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用B/本月总销量*100)").SetOrdinal(14);

            //gv_List.Width = new Unit(100, UnitType.Percentage);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[奶粉部费率A(%)]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }

            gv_List.DataSource = dtSummary.DefaultView;

            gv_List.DataBind();
            GridViewMergSampeValueRow(gv_List, 0, "", 0, "");
            GridViewMergSampeValueRow(gv_List, 1, "", 0, "");
            GridViewMergSampeValueRow(gv_List, 2, "", 0, "");
            #endregion
        }
        break;

        case "1":
        {
            #region 显示汇总单数据源
            DataTable dtSummary = PM_SalaryBLL.GetSummaryTotal(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue));
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }
            if (dtSummary.Columns.Count >= 24)
            {
                gv_List.Width = new Unit(dtSummary.Columns.Count * 65);
            }
            else
            {
                gv_List.Width = new Unit(100, UnitType.Percentage);
            }

            dtSummary.Columns.Add("费率A(%)", Type.GetType("System.Decimal"), "IIF(本月总销量=0,0,费用A/本月总销量*100)").SetOrdinal(dtSummary.Columns.Count - 1);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[费率A(%)]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }

            #region 增加合计行
            if (dtSummary.Rows.Count > 0)
            {
                DataRow dr = dtSummary.NewRow();
                dr[0]        = 0;
                dr["管理片区名称"] = "合计";

                for (int column = 2; column < dtSummary.Columns.Count - 1; column++)
                {
                    decimal sum = 0;
                    for (int i = 0; i < dtSummary.Rows.Count; i++)
                    {
                        decimal d = 0;
                        if (decimal.TryParse(dtSummary.Rows[i][column].ToString(), out d))
                        {
                            sum += d;
                        }
                    }
                    dr[column] = sum;
                }
                dtSummary.Rows.Add(dr);
            }
            #endregion
            gv_List.DataSource = dtSummary.DefaultView;
            gv_List.DataBind();

            MatrixTable.GridViewMatric(gv_List);
            #endregion
        }
        break;

        case "2":
        {
            //string condition = " MCS_SYS.dbo.UF_Spilt(PM_SalaryDetail.ExtPropertys,'|',31)!='1'	";//--FlagCancel	是否取消已生成的导购人员导购工(	31)
            string condition = " 1=1 ";

            #region 组织明细记录的查询条件
            //管理片区及所有下属管理片区
            if (tr_OrganizeCity.SelectValue != "1")
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue));
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;

                condition += " AND PM_Salary.OrganizeCity IN (" + orgcitys + ")";
            }
            if (ddl_SalaryClassify.SelectedValue != "0")
            {
                condition += "AND MCS_SYS.dbo.UF_Spilt2('MCS_Promotor.dbo.PM_Salary',PM_Salary.ExtPropertys,'PMClassfiy')=" + ddl_SalaryClassify.SelectedValue;
            }
            //会计月条件
            condition += " AND PM_Salary.AccountMonth = " + ddl_Month.SelectedValue;

            //审批状态
            if (ddl_State.SelectedValue == "0")
            {
                condition += " AND PM_Salary.State IN (2,3) ";
            }
            else if (ddl_State.SelectedValue == "1")
            {
                condition +=
                    @" AND	PM_Salary.State = 2 AND 
			MCS_SYS.dbo.UF_Spilt(PM_Salary.ExtPropertys,'|',1) IN (
				SELECT EWF_Task_Job.Task
				FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
					MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
					 INNER JOIN MCS_EWF.dbo.EWF_Task ON	 EWF_Task_Job.Task= EWF_Task.ID 
                     INNER JOIN MCS_EWF.dbo.EWF_Flow_App ON EWF_Task.App=EWF_Flow_App.ID AND EWF_Flow_App.Code='PM_SalaryApplyFlow'
				WHERE EWF_Task_JobDecision.RecipientStaff="                 + Session["UserID"].ToString() + @" AND
					EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3)"                    ;
            }
            else if (ddl_State.SelectedValue == "2")
            {
                condition += " AND PM_Salary.State = 3 ";
            }
            else if (ddl_State.SelectedValue == "3")
            {
                AC_AccountMonth m = new AC_AccountMonthBLL(month).Model;
                condition +=
                    @" AND PM_Salary.State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(PM_Salary.ExtPropertys,'|',1) IN 
                (SELECT EWF_Task_Job.Task FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
	                MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
                 INNER JOIN MCS_EWF.dbo.EWF_Task ON	 EWF_Task_Job.Task= EWF_Task.ID 
                 INNER JOIN MCS_EWF.dbo.EWF_Flow_App ON EWF_Task.App=EWF_Flow_App.ID AND EWF_Flow_App.Code='PM_SalaryApplyFlow'
                WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
	                EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND 
	                EWF_Task_JobDecision.DecisionTime BETWEEN DATEADD(month,-1,'"     + m.BeginDate.ToString("yyyy-MM-dd") + @"') AND 
		                DATEADD(month,3,'"         + m.BeginDate.ToString("yyyy-MM-dd") + @"'))";
            }
            #endregion

            gv_ListDetail.ConditionString = condition;
            gv_ListDetail.BindGrid();
        }
        break;

        case "3":
        {
            DataTable dtSummary = PM_SalaryBLL.GetDetailByState(month, organizecity, level, state, int.Parse(Session["UserID"].ToString()), int.Parse(ddl_SalaryClassify.SelectedValue), rtchannel);
            if (dtSummary.Rows.Count == 0)
            {
                gv_PromotorSalary.DataBind();
                return;
            }
            if (dtSummary.Columns.Count >= 24)
            {
                gv_PromotorSalary.Width = new Unit(dtSummary.Columns.Count * 65);
            }
            else
            {
                gv_PromotorSalary.Width = new Unit(100, UnitType.Percentage);
            }
            dtSummary.Columns.Add("所在门店").SetOrdinal(6);
            if (txt_FeeRate.Text != "0")
            {
                dtSummary.DefaultView.RowFilter = "[费率A%]" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
            }
            gv_PromotorSalary.DataSource = dtSummary.DefaultView;
            gv_PromotorSalary.DataBind();
            MatrixTable.GridViewMatric(gv_PromotorSalary);
        }
        break;
        }

        #region 是否可以批量审批
        if (state != 1)
        {
            gv_List.Columns[0].ItemStyle.Width = new Unit(1);
            bt_Approved.Visible   = false;
            bt_UnApproved.Visible = false;
        }
        else
        {
            bt_Approved.Visible   = true;
            bt_UnApproved.Visible = true;
            gv_List.Columns[0].ItemStyle.Width = new Unit(68);
            Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
            DataTable    dt     = _staff.GetLowerPositionTask(3, int.Parse(tr_OrganizeCity.SelectValue), month);

            if (AC_AccountMonthBLL.GetCurrentMonth() - 1 <= int.Parse(ddl_Month.SelectedValue))
            {
                string[] allowday1 = Addr_OrganizeCityParamBLL.GetValueByType(1, 3).Split(new char[] { ',', ',', ';', ';' });
                string[] allowday2 = Addr_OrganizeCityParamBLL.GetValueByType(1, 4).Split(new char[] { ',', ',', ';', ';' });
                int      day       = DateTime.Now.Day;
                if (allowday1.Contains(day.ToString()))
                {
                    bt_Approved.Visible = false;
                }
                else if (allowday2.Contains(day.ToString()))
                {
                    #region 判断费用申请进度
                    Org_StaffBLL bll = new Org_StaffBLL((int)Session["UserID"]);
                    DataTable    dt2 = new DataTable();
                    if (bll.Model.Position == 210)
                    {
                        dt2 = bll.GetFillProcessDetail(3);
                    }
                    if (dt.Rows.Count > 0)
                    {
                        bt_Approved.Visible = false;
                    }
                    #endregion
                }
                else
                {
                    bt_UnApproved.Enabled = false;
                    bt_Approved.Enabled   = dt.Rows.Count == 0;
                }
            }
            else
            {
                bt_UnApproved.Enabled = false;
                bt_Approved.Enabled   = dt.Rows.Count == 0;
            }
            if (dt.Rows.Count > 0)
            {
                bt_Approved.Enabled = false;

                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/Pop_ShowLowerPositionTask.aspx") +
                                                        "?Type=3&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
            }
        }
        #endregion
    }
 private void bindDetail(int detailID)
 {
     div_detail.Visible = true;
     if (detailID > 0)
     {
         Addr_OrganizeCityParamBLL param = new Addr_OrganizeCityParamBLL(detailID);
         ddl_ParamType2.SelectedValue = param.Model.ParamType.ToString();
         tbx_ParamValue.Text = param.Model.ParamValue;
         tbx_Remark.Text = param.Model.Remark;
     }
 }
    protected void bt_OK_Click(object sender, EventArgs e)
    {
        PM_PromotorSalaryBLL bll;

        if ((int)ViewState["PromotorSalaryID"] == 0)
        {
            bll = new PM_PromotorSalaryBLL();
        }
        else
        {
            bll = new PM_PromotorSalaryBLL((int)ViewState["PromotorSalaryID"]);
        }

        UC_DetailView1.GetData(bll.Model);

        #region 数据录入判断
        if (bll.Model.BasePayMode == 0)
        {
            MessageBox.Show(this, "请选择正确的底薪模式!");
            return;
        }
        if (bll.Model.BasePayMode == 1)
        {
            if (bll.Model.SeniorityPayMode == 0)
            {
                MessageBox.Show(this, "当底薪模式为固定底薪时,必须选择工龄工资模式!");
                return;
            }
            if (bll.Model.InsuranceMode == 0)
            {
                MessageBox.Show(this, "当底薪模式为固定底薪时,必须选择社保!");
                return;
            }
        }
        if (bll.Model.BasePaySubsidyMode != 0 && bll.Model.BasePaySubsidy == 0)
        {
            MessageBox.Show(this, "当选择了底薪补贴类型时,请设定补贴金额!");
            return;
        }

        if (bll.Model.BasePaySubsidyMode != 0 && bll.Model.BasePaySubsidyBeginDate.Year == 1900)
        {
            MessageBox.Show(this, "当选择了底薪补贴类型时,请设定底薪补贴起始日期!");
            return;
        }
        if (bll.Model.BasePaySubsidyMode == 1 && bll.Model.BasePaySubsidyEndDate.Year == 1900)
        {
            MessageBox.Show(this, "当选择了底薪补贴类型为临时补贴时,请设定底薪补贴截止日期!");
            return;
        }

        decimal BasePaySubsidylimt = 0;
        decimal.TryParse(Addr_OrganizeCityParamBLL.GetValueByType(1, 22), out BasePaySubsidylimt);
        if (BasePaySubsidylimt > 0 && BasePaySubsidylimt < bll.Model.BasePaySubsidy)
        {
            MessageBox.Show(this, "底薪补贴不得超过上限" + BasePaySubsidylimt.ToString() + "元");
            return;
        }

        if (bll.Model.MinimumWageMode == 2 && bll.Model.MinimumWage == 0)
        {
            MessageBox.Show(this, "当选择了特殊保底时,请设定保底金额!");
            return;
        }
        decimal MinimumWagelimit = 0;
        decimal.TryParse(Addr_OrganizeCityParamBLL.GetValueByType(1, 23), out MinimumWagelimit);
        if (bll.Model.MinimumWageMode == 2 && MinimumWagelimit > 0 && MinimumWagelimit < bll.Model.MinimumWage)
        {
            MessageBox.Show(this, "当选择了特殊保底时,保底工资不能超过上限" + MinimumWagelimit.ToString() + "元!");
            return;
        }
        if (bll.Model.MinimumWageMode != 0 && bll.Model.MinimumWageBeginDate.Year == 1900)
        {
            MessageBox.Show(this, "当选择了薪资保底时,请设定保底的起始日期!");
            return;
        }
        if (bll.Model.MinimumWageMode != 0 && bll.Model.MinimumWageEndDate.Year == 1900)
        {
            MessageBox.Show(this, "当选择了薪资保底时,请设定保底的截止日期!");
            return;
        }
        if (bll.Model.InsuranceMode == 0 && bll.Model.BasePayMode != 3)
        {
            MessageBox.Show(this, "非兼职,请选择正确的社保模式!");
            return;
        }
        if (bll.Model.InsuranceMode == 1 && bll.Model.InsuranceSubsidy <= 0)
        {
            MessageBox.Show(this, "请正确输入保险补贴金额!");
            return;
        }
        if (bll.Model.BasePayMode == 4 && bll.Model["FloatingTarget"] == "0")
        {
            MessageBox.Show(this, "当底薪模式为浮动底薪(非华南)时,请设定浮动底薪上限任务量!");
            return;
        }
        if (bll.Model.BasePayMode == 4 && bll.Model["AvgSales"] == "0")
        {
            MessageBox.Show(this, "当底薪模式为浮动底薪(非华南)时,请设定前两月平均销量!");
            return;
        }
        //if (bll.Model.BasePayMode == 4 && bll.Model["BaseFeeRate"] == "0")
        //{
        //    MessageBox.Show(this, "当底薪模式为浮动底薪(非华南)时,请设定底薪费率!");
        //    return;
        //}
        if (bll.Model.BasePayMode == 5 && bll.Model["SalesType"] == "0")
        {
            MessageBox.Show(this, "当底薪模式为浮动底薪(华南)时,请设定实销类别!");
            return;
        }
        if (bll.Model.BasePayMode == 5 && bll.Model["BaseFeeRate"] == "0")
        {
            MessageBox.Show(this, "当底薪模式为浮动底薪(华南)时,请设定底薪费率!");
            return;
        }
        #endregion
        bll.Model["ISArriveTarget"] = chk_arrivetarget.Checked ? "1" : "2";
        if ((int)ViewState["PromotorSalaryID"] == 0)
        {
            bll.Model.Promotor    = (int)ViewState["PromotorID"];
            bll.Model.State       = 1;
            bll.Model.ApproveFlag = 2;
            bll.Model.InsertStaff = (int)Session["UserID"];

            ViewState["PromotorSalaryID"] = bll.Add();
        }
        else
        {
            bll.Update();
        }

        BindGrid();
        MessageBox.ShowAndRedirect(this, "保存成功!", "PM_PromotorSalaryDetail.aspx?ID=" + ViewState["PromotorSalaryID"].ToString());
    }
Exemple #17
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int state        = int.Parse(ddl_State.SelectedValue);

        if (MCSTabControl1.SelectedTabItem.Value == "0")
        {
            #region 显示汇总数据
            gv_List.Visible = true; gv_DetailList.Visible = false;
            DataTable dtSummary = FNA_FeeApplyBLL.GetFLFeeSummary(month, organizecity, int.Parse(ddl_Level.SelectedValue), state, int.Parse(Session["UserID"].ToString()));
            if (dtSummary.Rows.Count == 0)
            {
                gv_List.DataBind();
                return;
            }

            dtSummary = MatrixTable.Matrix(dtSummary, new string[] { "管理片区名称", "行政属性" },
                                           new string[] { "RTChannel", "DisplayFeeType", "Title" }, "Summary", true, false);
            MatrixTable.TableAddRowSubTotal_Matric(dtSummary, new string[] { "管理片区名称" }, 2, new string[] { "RTChannel", "DisplayFeeType", "Title" }, false);

            #region 重新计算总计行的费率
            if (dtSummary.Rows.Count > 1)
            {
                foreach (DataRow dr in dtSummary.Rows)
                {
                    if (dr[1].ToString().EndsWith("计") || dr[2].ToString().EndsWith("计"))
                    {
                        foreach (DataColumn dc in dtSummary.Columns)
                        {
                            if (dc.ColumnName.EndsWith("费率%"))
                            {
                                string title = dc.ColumnName;
                                int    pos   = title.IndexOf('→');
                                if (pos > 0)
                                {
                                    title = title.Substring(0, pos);
                                    if (dtSummary.Columns.Contains(title + "→1.返利费总计(元/月)→A.我司承担") &&
                                        dtSummary.Columns.Contains(title + "→2.销量及费率→A.实际进货(元/月)") &&
                                        (decimal)dr[title + "→2.销量及费率→A.实际进货(元/月)"] != 0)
                                    {
                                        dr[dc.ColumnName] = Math.Round((decimal)dr[title + "→1.返利费总计(元/月)→A.我司承担"] / (decimal)dr[title + "→2.销量及费率→A.实际进货(元/月)"] * 100, 1, MidpointRounding.AwayFromZero);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion

            gv_List.DataSource = dtSummary;
            gv_List.DataBind();

            if (dtSummary.Columns.Count >= 24)
            {
                gv_List.Width = new Unit(dtSummary.Columns.Count * 65);
            }
            else
            {
                gv_List.Width = new Unit(100, UnitType.Percentage);
            }

            MatrixTable.GridViewMatric(gv_List);

            MatrixTable.GridViewMergSampeValueRow(gv_List, 0);
            MatrixTable.GridViewMergSampeValueRow(gv_List, 1);

            #endregion
        }
        else
        {
            gv_List.Visible = false; gv_DetailList.Visible = true;
            if (ddl_State.SelectedValue == "1" && Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1510, "BatApproveFee"))
            {
                bt_Approve.Visible         = false;
                bt_UnApprove.Visible       = true;
                bt_Approve.OnClientClick   = "return confirm('是否确认将所选中所有申请单批量设为审批通过?注意该操作可能耗时较长,请耐心等待!')";
                bt_UnApprove.OnClientClick = "return confirm('是否确认将所选中所有申请单批量设为审批不通过?注意该操作可能耗时较长,请耐心等待!')";
            }
            #region 组织明细查询条件
            string condition = "";
            condition += @"FNA_FeeApply.FeeType=7 AND EXISTS(SELECT 1 FROM MCS_FNA.dbo.FNA_FeeApplyDetail WHERE FNA_FeeApplyDetail.AccountTitle=82
                AND FNA_FeeApplyDetail.ApplyID=FNA_FeeApply.ID AND BeginMonth=" + ddl_Month.SelectedValue + ")";
            if (tr_OrganizeCity.SelectValue != "1")
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(organizecity);
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += organizecity;

                condition += " AND FNA_FeeApply.OrganizeCity IN (" + orgcitys + ")";
            }
            if (state == 0)
            {
                condition += " AND FNA_FeeApply.State IN (2,3) ";
            }
            else if (state == 1)
            {
                condition +=
                    @" AND	FNA_FeeApply.State = 2 AND 
			EXISTS (
				SELECT EWF_Task_Job.Task
				FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
					MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
					 INNER JOIN MCS_EWF.dbo.EWF_Task ON	 EWF_Task_Job.Task= EWF_Task.ID AND EWF_Task.App='4eb9e905-3502-4caf-88d0-aadcfec6e4dd'
				WHERE EWF_Task_JobDecision.RecipientStaff="                 + Session["UserID"].ToString() + @" AND
					EWF_Task_JobDecision.DecisionResult=1 and EWF_Task_Job.Status=3 AND FNA_FeeApply.ApproveTask=EWF_Task_Job.Task)"                    ;
            }
            else if (state == 2)
            {
                condition += " AND FNA_FeeApply.State = 3 ";
            }
            else if (state == 3)
            {
                AC_AccountMonth m = new AC_AccountMonthBLL(month).Model;
                condition +=
                    @" AND FNA_FeeApply.State IN (2,3) AND EXISTS 
            (SELECT EWF_Task_Job.Task FROM  MCS_EWF.dbo.EWF_Task_JobDecision INNER JOIN
	        MCS_EWF.dbo.EWF_Task_Job ON EWF_Task_JobDecision.Job = EWF_Task_Job.ID 
            INNER JOIN MCS_EWF.dbo.EWF_Task ON=EWF_Task_Job.Task=EWF_Task.ID AND EWF_Task.App='4eb9e905-3502-4caf-88d0-aadcfec6e4dd'
            WHERE EWF_Task_JobDecision.RecipientStaff=" + Session["UserID"].ToString() + @" AND
	            EWF_Task_JobDecision.DecisionResult IN(2,5,6) AND FNA_FeeApply.ApproveTask=EWF_Task_Job.Task)"    ;
            }
            #endregion
            gv_DetailList.ConditionString = condition;
            gv_DetailList.BindGrid();
        }


        #region 是否可以批量审批
        if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1510, "BatApproveFee"))
        {
            bt_Approve.Visible   = (ddl_State.SelectedValue == "1");
            bt_UnApprove.Visible = (ddl_State.SelectedValue == "1");
            bt_Approve.Enabled   = (ddl_State.SelectedValue == "1");
            bt_UnApprove.Enabled = (ddl_State.SelectedValue == "1");

            #region 判断费用申请进度
            if (ddl_State.SelectedValue == "1")
            {
                Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
                DataTable    dt     = _staff.GetLowerPositionTask(2, int.Parse(tr_OrganizeCity.SelectValue), month);
                if (AC_AccountMonthBLL.GetCurrentMonth() - 1 <= int.Parse(ddl_Month.SelectedValue))
                {
                    string[] allowdays1 = Addr_OrganizeCityParamBLL.GetValueByType(1, 5).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                    string[] allowdays2 = Addr_OrganizeCityParamBLL.GetValueByType(1, 6).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                    string   date       = DateTime.Now.Day.ToString();
                    if (allowdays1.Contains(date))
                    {
                        bt_Approve.Enabled = false;
                    }
                    else if (allowdays2.Contains(date))
                    {
                        DataTable dt2 = new DataTable();
                        if (_staff.Model.Position == 210)
                        {
                            dt2 = _staff.GetFillProcessDetail(2);
                        }
                        if (dt.Rows.Count > 0 || dt2.Rows.Count > 0)
                        {
                            bt_Approve.Enabled = false;
                        }
                    }
                    else
                    {
                        bt_UnApprove.Enabled = false;
                    }
                }
                else
                {
                    bt_UnApprove.Enabled = false;
                }
                if (dt.Rows.Count > 0)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/Pop_ShowLowerPositionTask.aspx") +
                                                            "?Type=2&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
                    bt_Approve.Enabled = false;
                }
            }
            #endregion
        }
        else
        {
            bt_Approve.Visible   = false;
            bt_UnApprove.Visible = false;
        }
        #endregion
    }
Exemple #18
0
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int RTChannel    = int.Parse(ddl_RTChannel.SelectedValue);
        int RTType       = int.Parse(ddl_RTType.SelectedValue);

        string condition = "";

        if (tbx_ApplyCost.Text != "0")
        {
            condition = "TotalApplyCost" + ddl_OP.SelectedValue + tbx_ApplyCost.Text;
        }

        if (txt_FeeRate.Text != "0")
        {
            if (condition != "")
            {
                condition += " AND ";
            }
            condition += "CONVERT(DECIMAL(10,3),REPLACE(ApplyCostRate,'%',''))" + ddl_FeeRateOP.SelectedValue + txt_FeeRate.Text;
        }
        DataTable dtSummary = FNA_FeeApplyBLL.GetRTChannelFLFee
                                  (month, organizecity, state, int.Parse(Session["UserID"].ToString()), RTChannel, condition, RTType);

        if (dtSummary.Rows.Count == 0)
        {
            gv_List.DataBind();
            return;
        }

        #region 求行小计
        MatrixTable.TableAddRowSubTotal(dtSummary, new string[] { "区域信息→大区", "区域信息→营业部", "区域信息→办事处", "零售店基本情况→费用代垫客户" },
                                        new string[] { "卖场销售额→上月", "卖场销售额→本月", "费用情况→总费用", "费用情况→我司费用", "费用情况→经销商费用" }, true);
        //计算小计行费率
        foreach (DataRow dr in dtSummary.Rows)
        {
            if (dr[0].ToString() == "总计" ||
                dr[1].ToString() == "小计" ||
                dr[2].ToString() == "小计" ||
                dr[3].ToString() == "小计" ||
                dr[4].ToString() == "小计")
            {
                dr["费用情况→我司费率"]  = (decimal)dr["卖场销售额→本月"] == 0 ? "100%" : ((decimal)dr["费用情况→我司费用"] / (decimal)dr["卖场销售额→本月"]).ToString("0.#%");
                dr["费用情况→经销商费率"] = (decimal)dr["卖场销售额→本月"] == 0 ? "100%" : ((decimal)dr["费用情况→经销商费用"] / (decimal)dr["卖场销售额→本月"]).ToString("0.#%");
            }
        }
        #endregion

        gv_List.DataSource = dtSummary;
        gv_List.DataBind();

        if (dtSummary.Columns.Count >= 24)
        {
            gv_List.Width = new Unit(dtSummary.Columns.Count * 60);
        }
        else
        {
            gv_List.Width = new Unit(100, UnitType.Percentage);
        }

        MatrixTable.GridViewMatric(gv_List);

        for (int i = 0; i < 4; i++)
        {
            MatrixTable.GridViewMergSampeValueRow(gv_List, i);
        }

        if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1510, "BatApproveFee"))
        {
            bt_Approve.Visible            = (ddl_State.SelectedValue == "1");
            bt_UnApprove.Visible          = (ddl_State.SelectedValue == "1");
            bt_ExcludeApplyDetail.Visible = (ddl_State.SelectedValue == "1");

            if (state == 1 && condition == "" && RTChannel == 0 && RTType == 0)
            {
                bt_Approve.Enabled   = true;
                bt_UnApprove.Enabled = true;

                #region 判断能否审批

                if (ddl_State.SelectedValue == "1")
                {
                    Org_StaffBLL _staff = new Org_StaffBLL((int)Session["UserID"]);
                    DataTable    dt     = _staff.GetLowerPositionTask(2, int.Parse(tr_OrganizeCity.SelectValue), month);

                    if (AC_AccountMonthBLL.GetCurrentMonth() - 1 <= int.Parse(ddl_Month.SelectedValue))
                    {
                        string[] allowdays1 = Addr_OrganizeCityParamBLL.GetValueByType(1, 5).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                        string[] allowdays2 = Addr_OrganizeCityParamBLL.GetValueByType(1, 6).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                        string   date       = DateTime.Now.Day.ToString();
                        if (allowdays1.Contains(date))
                        {
                            bt_Approve.Enabled = false;
                        }
                        else if (allowdays2.Contains(date))
                        {
                            DataTable dt2 = new DataTable();
                            if (_staff.Model.Position == 210)
                            {
                                dt2 = _staff.GetFillProcessDetail(2);
                            }
                            if (dt2.Rows.Count > 0)
                            {
                                bt_Approve.Enabled = false;
                            }
                        }
                        else
                        {
                            bt_UnApprove.Enabled = false;
                        }
                    }
                    else
                    {
                        bt_UnApprove.Enabled = false;
                    }

                    if (dt.Rows.Count > 0)
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "message", "<script language='javascript'>var tempid = Math.random() * 10000; \r\n window.showModalDialog('" + Page.ResolveClientUrl("~/SubModule/Pop_ShowLowerPositionTask.aspx") +
                                                                "?Type=2&StaffID=0&Month=" + ddl_Month.SelectedValue + "&City=" + tr_OrganizeCity.SelectValue + "&tempid='+tempid, window, 'dialogWidth:520px;DialogHeight=600px;status:yes;resizable=no');</script>", false);
                        bt_Approve.Enabled = false;
                    }
                }
                #endregion
            }
            else
            {
                bt_Approve.Enabled   = false;
                bt_UnApprove.Enabled = false;
            }
        }
        else
        {
            bt_Approve.Visible            = false;
            bt_UnApprove.Visible          = false;
            bt_ExcludeApplyDetail.Visible = false;
        }
    }
Exemple #19
0
    private void BindData()
    {
        int id = (int)ViewState["ID"];

        FNA_FeeApply apply = new FNA_FeeApplyBLL(id).Model;

        if (apply == null)
        {
            Response.Redirect("FeeApplyList.aspx");
        }

        ViewState["AccountMonth"]    = apply.AccountMonth;
        ViewState["OrganizeCity"]    = apply.OrganizeCity;
        ViewState["FeeType"]         = apply.FeeType;
        ViewState["AccountTitle2"]   = string.IsNullOrEmpty(apply["AccountTitle2"]) ? 0 : int.Parse(apply["AccountTitle2"]);
        ViewState["DicFeeType"]      = DictionaryBLL.GetDicCollections("FNA_FeeType")[ViewState["FeeType"].ToString()];
        ViewState["RelateCar"]       = string.IsNullOrEmpty(apply["RelateCar"]) ? 0 : int.Parse(apply["RelateCar"]);
        ViewState["GiftFeeClassify"] = string.IsNullOrEmpty(apply["GiftFeeClassify"]) ? 0 : int.Parse(apply["GiftFeeClassify"]);
        ViewState["FromGeneralFlow"] = string.IsNullOrEmpty(apply["FromGeneralFlow"]) ? "Y" : "N";

        pn_FeeApply.BindData(apply);

        if (apply.Client != 0)
        {
            cbx_NoInsteadPayClient.Visible = false;
        }

        UploadFile1.RelateID = (int)ViewState["ID"];

        if (((Dictionary_Data)ViewState["DicFeeType"]).Description == "BudgetControl")
        {
            BindBudgetInfo();
        }
        else if (((Dictionary_Data)ViewState["DicFeeType"]).Description == "FeeRateControl")
        {
            BindFeeRateInfo();
        }

        #region 根据审批状态控制页面
        bt_ViewWriteOff.Visible = false;
        if (apply.State == 1)
        {
            //未提交状态
            bt_ViewReport.Visible = false;

            tbx_Remark.Text    = apply["Remark"];
            tbl_Remark.Visible = true;
            gv_List.Columns[gv_List.Columns.Count - 1].Visible = true;  //删除按钮
        }

        if (apply.State != 1)
        {
            //非 未提交 状态
            bt_Delete.Visible    = false;
            bt_AddDetail.Visible = false;
            pn_FeeApply.SetPanelEnable("Panel_FNA_FeeApplyDetail_1", false);
            gv_List.Columns[gv_List.Columns.Count - 1].Visible = false;
            bt_Save.Visible   = false;
            bt_Submit.Visible = false;

            apply["Remark"] = apply["Remark"].Replace("\r", "<br/>");
            pn_Remark.BindData(apply);
            pn_Remark.Visible = true;

            cbx_NoInsteadPayClient.Visible = false;

            UploadFile1.CanDelete = false;

            if (apply.FeeType == 1)
            {
                bt_ViewReport.OnClientClick = "PopReport(" + apply.ID.ToString() + ")";
            }
            else
            {
                bt_ViewReport.Visible = false;
            }


            //可见调整金额及原因
            gv_List.Columns[gv_List.Columns.Count - 7].Visible  = true; //批复额
            gv_List.Columns[gv_List.Columns.Count - 10].Visible = true; //调整原因
            gv_List.Columns[gv_List.Columns.Count - 11].Visible = true; //调整金额
            if ((ViewState["Details"] as ListTable <FNA_FeeApplyDetail>).GetListItem().FirstOrDefault(p => p.AccountTitle == 82) != null)
            {
                gv_List.Columns[gv_List.Columns.Count - 6].Visible = true;  //批复额
                gv_List.Columns[gv_List.Columns.Count - 8].Visible = true;  //调整原因
                gv_List.Columns[gv_List.Columns.Count - 9].Visible = true;  //调整金额
            }
        }
        if ((ViewState["Details"] as ListTable <FNA_FeeApplyDetail>).GetListItem()[0].RelateContractDetail > 0)
        {
            gv_List.Columns[4].Visible = true;
        }

        if (apply.State == 2)
        {
            ///已提交状态,审批过程中,可以作金额调整
            ///审批过程中,可以作金额调整 Decision参数为在审批过程中传进来的参数
            if (Request.QueryString["Decision"] != "" && Request.QueryString["Decision"] == "Y")
            {
                gv_List.Columns[gv_List.Columns.Count - 2].Visible = true; //允许调整申请金额
                int fltype = ConfigHelper.GetConfigInt("ContractFeeType-FL");
                if (apply.FeeType == fltype)
                {
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "返利不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_Pass').disabled='disabled'; </script>");
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "返利不能单条审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_bt_SaveDecisionComment').disabled='disabled'; </script>");
                    Page.ClientScript.RegisterStartupScript(Page.GetType(), "返利不能单条处理", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_WaitProcess').disabled='disabled'; </script>");
                    string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 9).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                    if (!allowdays.Contains(DateTime.Now.Day.ToString()))
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "超时不能单独审批", " <script>window.parent.document.getElementById('ctl00_ContentPlaceHolder1_btn_NotPass').disabled='disabled'; </script>");
                    }
                }
            }
            bt_ViewWriteOff.Visible = false;
        }

        if (apply.State == 3)
        {
            //已审批
            bt_ViewWriteOff.Visible = true;
            gv_List.Columns[gv_List.Columns.Count - 3].Visible = true; //查看核销 链接
            gv_List.Columns[gv_List.Columns.Count - 4].Visible = true; //可报销额
            gv_List.Columns[gv_List.Columns.Count - 5].Visible = true; //报销标志

            bt_ViewWriteOff.OnClientClick = "PopWriteOffListByApplyID(" + id.ToString() + ")";
            if (Right_Assign_BLL.GetAccessRight(Session["UserName"].ToString(), 1503, "CancelWirteOffDetail"))
            {
                bt_CancelWriteOff.Visible       = true;
                bt_CancelWriteOff.OnClientClick = "return confirm('是否确定取消选中的费用,取消后,该费用不可再次核销!\n【若需要再次核销则需要重新发起申请!】')";
                gv_List.Columns[0].Visible      = true;
            }
        }

        if (apply.InsertStaff != (int)Session["UserID"] || apply.State != 3)
        {
            bt_Cancel.Visible = false;
        }

        if (apply.InsertStaff != (int)Session["UserID"] || apply.State >= 3)
        {
            UploadFile1.CanUpload = false;
            UploadFile1.CanDelete = false;
        }

        if (apply.State != 8)
        {
            bt_Copy.Visible = false;    //只有审批未通过才可重新激活
        }

        #endregion

        if (apply["FromGeneralFlow"] == "N")
        {
            if (apply.FeeType == ConfigHelper.GetConfigInt("ContractFeeType") ||
                apply.FeeType == ConfigHelper.GetConfigInt("ContractFeeType-KA") ||
                apply.FeeType == ConfigHelper.GetConfigInt("ContractFeeType-FL")
                )
            {
                bt_AddDetail.Visible = false;
            }
        }
        #region 增加客户后的详细内容按钮
        if (apply.Client != 0)
        {
            //MCSSelectControl sc_Client = (MCSSelectControl)pn_FeeApply.FindControl("FNA_FeeApply_Client");
            //if (sc_Client != null)
            //{
            //    HyperLink hy_clientdetail = new HyperLink();
            //    hy_clientdetail.ImageUrl = "~/Images/Gif/gif-0818.gif";
            //    hy_clientdetail.NavigateUrl = "~/SubModule/CM/RT/RetailerAnalysis.aspx?ClientID=" + apply.Client.ToString();
            //    hy_clientdetail.Target = "_blank";
            //    sc_Client.Parent.Controls.Add(hy_clientdetail);
            //}
        }
        #endregion

        #region 增加关联活动链接
        int activityid = 0;

        if (int.TryParse(apply["ActivityID"], out activityid) && activityid > 0)
        {
            Label label = (Label)pn_FeeApply.FindControl("FNA_FeeApply_ActivityID");
            if (label != null)
            {
                HyperLink hy_activitydetail = new HyperLink();
                hy_activitydetail.Text        = " 查看活动详情";
                hy_activitydetail.ForeColor   = System.Drawing.Color.Blue;
                hy_activitydetail.NavigateUrl = "~/SubModule/CAT/CAT_ActivityDetail.aspx?ID=" + activityid.ToString();
                hy_activitydetail.Target      = "_blank";
                label.Parent.Controls.Add(hy_activitydetail);
            }
        }
        #endregion

        #region 增加关联HDM结算单链接
        int hdmbalance = 0;

        if (int.TryParse(apply["HDMBalance"], out hdmbalance) && hdmbalance > 0)
        {
            Label label = (Label)pn_FeeApply.FindControl("FNA_FeeApply_HDMBalance");
            if (label != null)
            {
                HyperLink hy_hdmbalance = new HyperLink();
                hy_hdmbalance.Text        = " 查看结算单详情";
                hy_hdmbalance.ForeColor   = System.Drawing.Color.Blue;
                hy_hdmbalance.NavigateUrl = "~/SubModule/CSO/CSO_OfferBalanceDetail.aspx?OfferBalanceID=" + hdmbalance.ToString();
                hy_hdmbalance.Target      = "_blank";
                label.Parent.Controls.Add(hy_hdmbalance);
            }
        }
        #endregion
        BindGrid();
    }
Exemple #20
0
    protected void bt_Submit_Click(object sender, EventArgs e)
    {
        if (!Save())
        {
            return;
        }

        if ((int)ViewState["ID"] != 0)
        {
            ORD_OrderApplyBLL bll = new ORD_OrderApplyBLL((int)ViewState["ID"]);
            Session["SubmitOrderApplyID"] = (int)ViewState["ID"];
            if (bll.Model.State > 1)
            {
                Response.Redirect("OrderApplyList.aspx");
            }

            if (bll.Items.Count == 0)
            {
                MessageBox.ShowAndRedirect(this, "对不起,定单申请明细不能为空!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                return;
            }

            if (bll.Model.AccountMonth < AC_AccountMonthBLL.GetCurrentMonth())
            {
                MessageBox.Show(this, "对不起,该订单申请月份已不是当前月份,已不可提交,请删除该单后重新申请赠品!");
                return;
            }

            decimal totalcost = bll.Items.Sum(m => m.BookQuantity * m.Price);

            if (bll.Model.Type == 2)
            {
                //促销品申请
                #region 判断预算额度余额是否够申请
                ORD_ApplyPublish publish = new ORD_ApplyPublishBLL(bll.Model.PublishID).Model;
                int productbrand = 0, giftclassify = 0;
                int.TryParse(publish["ProductBrand"], out productbrand);
                int.TryParse(publish["GiftClassify"], out giftclassify);

                decimal _budgetbalance  = FNA_BudgetBLL.GetUsableAmount(bll.Model.AccountMonth, bll.Model.OrganizeCity, publish.FeeType);
                decimal _productbalance = ORD_GiftApplyAmountBLL.GetBalanceAmount(bll.Model.AccountMonth, bll.Model.Client, productbrand, giftclassify);

                decimal _balance = _productbalance;
                //2012-3-27 暂时限定赠品额度,不限定预算
                //decimal _balance = (_budgetbalance > _productbalance ? _productbalance : _budgetbalance);
                string[] nolimitbrand = Addr_OrganizeCityParamBLL.GetValueByType(1, 24).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                if (_balance < totalcost && !nolimitbrand.Contains(publish["ProductBrand"]))
                {
                    if (bll.Model["GiftClassify"] == "2" && _balance > 0 && ORD_OrderApplyBLL.GetModelList("Client=" + bll.Model.Client.ToString() + " AND AccountMonth=" + bll.Model.AccountMonth.ToString() + " AND State IN (2,3) AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)=" + bll.Model["ProductBrand"] + " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)=" + bll.Model["GiftClassify"]).Count == 0)
                    {
                        //判断是否可以申请最低金额赠品1件
                        decimal MinApplyAmount = 0, MaxApplyAmount = 0;

                        ORD_ApplyPublishBLL _publishbll = new ORD_ApplyPublishBLL(bll.Model.PublishID);
                        _publishbll.GetMinApplyAmount(out MinApplyAmount, out MaxApplyAmount);
                        if (_balance > 0 && _balance < MinApplyAmount)
                        {
                            if (bll.Items.Count > 1)
                            {
                                MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                return;
                            }
                            else
                            {
                                int applyproduct = bll.Items[0].Product;
                                ORD_ApplyPublishDetail applydetail = _publishbll.Items.FirstOrDefault(p => p.Product == applyproduct);
                                if (applydetail != null && applydetail.MinQuantity < bll.Items[0].BookQuantity)
                                {
                                    MessageBox.Show(this, "对不起,您当前的可申请余额不足,仅能申请最多1件赠品");
                                    return;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.ShowAndRedirect(this, "对不起,您当前的可申请余额[" + _balance.ToString("0.##") + "]不够申请这些品项!", "OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString());
                        return;
                    }
                }
                #endregion

                #region 发起工作流
                NameValueCollection dataobjects = new NameValueCollection();

                dataobjects.Add("ID", ViewState["ID"].ToString());
                dataobjects.Add("OrganizeCity", bll.Model.OrganizeCity.ToString());
                dataobjects.Add("AccountMonth", bll.Model.AccountMonth.ToString());
                dataobjects.Add("FeeType", publish.FeeType.ToString());
                dataobjects.Add("ProductBrand", publish["ProductBrand"]);
                dataobjects.Add("GiftClassify", publish["GiftClassify"]);
                dataobjects.Add("TotalFee", totalcost.ToString());

                int TaskID = EWF_TaskBLL.NewTask("CuXiaoPin_Apply", (int)Session["UserID"], "促销品申请申请流程", "~/SubModule/Logistics/Order/OrderApplyDetail3.aspx?ID=" + ViewState["ID"].ToString() + "&Type=2", dataobjects);

                new EWF_TaskBLL(TaskID).Start();
                #endregion

                bll.Submit((int)Session["UserID"], TaskID);

                Response.Redirect("~/SubModule/EWF/TaskDetail.aspx?TaskID=" + TaskID.ToString());
            }
            else
            {
                //产品申请申请
                bll.Submit((int)Session["UserID"], 0);
                Response.Redirect("OrderApplyList.aspx");
            }
        }
    }
    private void BindGrid()
    {
        int month        = int.Parse(ddl_Month.SelectedValue);
        int organizecity = int.Parse(tr_OrganizeCity.SelectValue);
        int level        = int.Parse(ddl_Level.SelectedValue);
        int state        = int.Parse(ddl_State.SelectedValue);
        int flag         = int.Parse(ddl_Flag.SelectedValue);

        #region 判断是否可以审批通过
        string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 7).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
        string   date      = DateTime.Now.Day.ToString();
        if (allowdays.Contains(date))
        {
            bt_Approve.Enabled = false;
            bt_Approve.ToolTip = "每月21-25号不可对进销存审批通过!";
        }
        #endregion

        if (new Addr_OrganizeCityBLL(organizecity).Model.Level >= 2 &&
            month == AC_AccountMonthBLL.GetMonthByDate(DateTime.Today.AddDays(-10)))
        {
            if ((int)ViewState["ClientType"] == 3 && (int)ViewState["Type"] == 2)
            {
                DataTable dtFillDataProgress = Org_StaffBLL.GetFillDataProgress((int)Session["UserID"], true);
                DataRow[] rows;
                if (flag == 1)
                {
                    rows = dtFillDataProgress.Select("ItemCode='006'");
                }
                else
                {
                    rows = dtFillDataProgress.Select("ItemCode='012'");
                }

                if (rows.Length > 0)
                {
                    int ItemTargetCount   = (int)rows[0]["ItemTargetCount"];
                    int ItemCompleteCount = (int)rows[0]["ItemCompleteCount"];
                    if (ItemTargetCount > ItemCompleteCount)
                    {
                        MessageBox.Show(this, "对不起,还有" + (ItemTargetCount - ItemCompleteCount).ToString() +
                                        "家门店销量尚未录入,无法提交或审核!具体请查看桌面填报进度表.");
                        bt_Approve.Enabled = false;
                        bt_Submit.Enabled  = false;
                    }
                }
            }
        }

        if (MCSTabControl1.SelectedIndex == 0)
        {
            DataTable dt_summary = SVM_SalesVolumeBLL.GetSummaryTotal(organizecity, month, (int)ViewState["ClientType"], flag, level, state, (int)ViewState["Type"], (int)Session["UserID"]);
            dt_summary            = MatrixTable.Matrix(dt_summary, new string[] { "管理片区名称" }, new string[] { "品牌", "段位" }, "金额", true, true);
            gv_Summary.DataSource = dt_summary;
            gv_Summary.DataBind();
            MatrixTable.GridViewMatric(gv_Summary);
            if (dt_summary.Columns.Count >= 24)
            {
                gv_Summary.Width = new Unit(dt_summary.Columns.Count * 60);
            }
            else
            {
                gv_Summary.Width = new Unit(100, UnitType.Percentage);
            }
        }
        else if (MCSTabControl1.SelectedIndex == 1)
        {
            if (organizecity == 1 || new Addr_OrganizeCityBLL(organizecity).Model.Level < 2)
            {
                MessageBox.Show(this, "按客户及SKU查询时,不能按总部及大区级别查询!");
                return;
            }
            DataTable dt_summary = SVM_SalesVolumeBLL.GetSummaryTotal2(organizecity, month, (int)ViewState["ClientType"], flag, state, (int)ViewState["Type"], (int)Session["UserID"]);
            dt_summary            = MatrixTable.Matrix(dt_summary, new string[] { "管理片区名称", "客户名称", "责任业代" }, new string[] { "品牌", "产品名称" }, "数量", true, true);
            gv_Summary.DataSource = dt_summary;
            gv_Summary.DataBind();
            MatrixTable.GridViewMatric(gv_Summary);
            if (dt_summary.Columns.Count >= 24)
            {
                gv_Summary.Width = new Unit(dt_summary.Columns.Count * 60);
            }
            else
            {
                gv_Summary.Width = new Unit(100, UnitType.Percentage);
            }
        }
        else
        {
            string            condition = " SVM_SalesVolume.AccountMonth=" + ddl_Month.SelectedValue;
            IList <CM_Client> cmlist    = new List <CM_Client>();
            if (organizecity > 1)
            {
                Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(organizecity);
                string orgcitys = orgcity.GetAllChildNodeIDs();
                if (orgcitys != "")
                {
                    orgcitys += ",";
                }
                orgcitys += tr_OrganizeCity.SelectValue;
                cmlist    = CM_ClientBLL.GetModelList("OrganizeCity IN (" + orgcitys + ") AND ActiveFlag=1 AND CM_Client.ClientType=" + ViewState["ClientType"].ToString());

                if (CM_ClientBLL.GetModelList("OrganizeCity IN (" + orgcitys + ") AND ActiveFlag=1 AND CM_Client.ClientType=" + ViewState["ClientType"].ToString()).Count != 0)
                {
                    condition += " AND SVM_SalesVolume.OrganizeCity IN (" + orgcitys + ")";
                }
            }

            condition += ddl_Flag.SelectedValue == "1" ? " AND SVM_SalesVolume.Flag<6" : " AND SVM_SalesVolume.Flag>6";

            AC_AccountMonthBLL _monthbll = new AC_AccountMonthBLL(month);

            if (ViewState["ClientType"] != null)
            {
                switch ((int)ViewState["ClientType"])
                {
                case 2:
                    if ((int)ViewState["Type"] == 1)
                    {
                        condition += " AND SVM_SalesVolume.Client IN( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_CM.dbo.CM_Client',CM_Client.ExtPropertys,'DIClassify')='2'";
                    }
                    else
                    {
                        condition += " AND SVM_SalesVolume.Supplier IN( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=2";
                    }
                    break;

                case 3:
                    condition += (int)ViewState["Type"] == 1 ? " AND SVM_SalesVolume.Client IN" : " AND SVM_SalesVolume.Supplier IN";
                    condition += "( Select ID FROM MCS_CM.dbo.CM_Client Where ClientType=3 ";
                    break;
                }
                if (cmlist.Count == 0)
                {
                    condition += " AND CM_Client.ClientManager=" + Session["UserID"].ToString();
                }
                condition += " AND ApproveFlag=1 AND OpenTime<='" + _monthbll.Model.EndDate + "'AND ISNULL(CloseTime,GETDATE())>='" + _monthbll.Model.BeginDate + "')";
            }
            switch (ddl_State.SelectedValue)
            {
            case "1":
                condition += "AND SVM_SalesVolume.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_SalesVolume',SVM_SalesVolume.ExtPropertys,'SubmitFlag')='2'";
                break;

            case "2":
                condition += "AND SVM_SalesVolume.ApproveFlag=2 AND  MCS_SYS.dbo.UF_Spilt2('MCS_SVM.dbo.SVM_SalesVolume',SVM_SalesVolume.ExtPropertys,'SubmitFlag')='1'";
                break;

            case "3":
                condition += " AND SVM_SalesVolume.ApproveFlag=1";
                break;
            }
            gv_List.ConditionString = condition;
            gv_List.BindGrid();
        }
    }
    private void BindGrid()
    {
        int _month = int.Parse(ddl_Month.SelectedValue);
        int _staff = 0;

        if (select_Staff.SelectValue != "")
        {
            _staff = int.Parse(select_Staff.SelectValue);
        }
        #region 编辑查询条件
        int _city = 1;
        if (tr_OrganizeCity.SelectValue != "")
        {
            _city = int.Parse(tr_OrganizeCity.SelectValue);
        }
        string RTCondition = "", DICondition = "";
        //if (ddl_DI.SelectedValue == "0")
        //{
        if (select_DI.SelectValue != "0" && select_DI.SelectValue != "")
        {
            DICondition += " AND Supplier.ID =" + select_DI.SelectValue;
        }
        //}
        //else
        //{
        //    if (tbx_DICode.Text != "")
        //    {
        //        DICondition += (ddl_DI.SelectedValue == "1" ? " AND Supplier.FullName" : " AND Supplier.Code") + " LIKE '%" + tbx_DICode.Text.Trim() + "%'";
        //    }
        //}
        //if (ddl_RT.SelectedValue == "0")
        //{
        if (select_RT.SelectValue != "0" && select_RT.SelectValue != "")
        {
            RTCondition += " AND CM_Client.ID =" + select_RT.SelectValue;
        }
        //}
        //else
        //{
        //    if (tbx_RTCode.Text != "")
        //    {
        //        RTCondition += (ddl_RT.SelectedValue == "1" ? " AND CM_Client.FullName" : " AND CM_Client.Code") + " LIKE '%" + tbx_RTCode.Text.Trim() + "%'";
        //    }
        //}
        #endregion


        Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
        if (staff.Model.Position == 211 ||
            staff.Model.Position == 212 ||
            staff.Model.Position == 209 ||
            staff.Model.Position == 210)
        {
            if (_month == AC_AccountMonthBLL.GetMonthByDate(DateTime.Now) - 1)
            {
                string[] allowdays = Addr_OrganizeCityParamBLL.GetValueByType(1, 25).Replace(" ", "").Split(new char[] { ',', ',', ';', ';' });
                if (allowdays.Contains(DateTime.Now.Day.ToString()))
                {
                    bt_Submit.Visible = true;
                    cbx_Head.Visible  = true;
                }
            }
        }
        DataTable dt = SVM_MYSaleInFlagBLL.GetList(_month, _city, _staff, DICondition, RTCondition);
        lt_RTCount.Text          = dt.Rows.Count.ToString();
        gv_ListDetail.DataSource = dt;
        gv_ListDetail.BindGrid();
    }