protected void bt_refresh_Click(object sender, EventArgs e)
 {
     Button t = (Button)sender;
     GridViewRow drv = (GridViewRow)t.NamingContainer;
     int rowIndex = drv.RowIndex;
     int id = (int)gv_List.DataKeys[rowIndex]["PM_SalaryDataObject_ID"];
     PM_SalaryDataObjectBLL.Refresh(id);
     BindGrid();
 }
 private void ApproveData(string approveflag)
 {
     if (approveflag == "1")
     {
         BtnSave_Click(null, null);
     }
     foreach (GridViewRow row in gv_List.Rows)
     {
         CheckBox chk = (CheckBox)row.FindControl("cbx");
         if (chk.Checked)
         {
             int id = (int)gv_List.DataKeys[row.RowIndex]["PM_SalaryDataObject_ID"];
             PM_SalaryDataObjectBLL bll = new PM_SalaryDataObjectBLL(id);
             bll.Model["ApproveFlag"] = approveflag;
             bll.Update();
         }
     }
 }
 protected void BtnSelect_Click(object sender, EventArgs e)
 {
     PM_SalaryDataObjectBLL.Init(int.Parse(tr_OrganizeCity.SelectValue), int.Parse(ddl_AccountMonth.SelectedValue));
     gv_List.PageIndex = 0;
     BindGrid();
 }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[row.RowIndex]["PM_SalaryDataObject_ID"];
            PM_SalaryDataObjectBLL bll = new PM_SalaryDataObjectBLL(id);
            bll.Model.ActWorkDays = int.Parse(((TextBox)row.FindControl("tbx_ActWorkDays")).Text);
            if (bll.Model.ActWorkDays > Convert.ToDecimal(ViewState["monthdays"]))
            {
                MessageBox.Show(this, "实际工作天数不能大于会计月天数!错误行:" + (row.RowIndex + 1).ToString() + ";导购员姓名:" + row.Cells[2].Text);
                BindGrid();
                return;

            }

            bll.Model["Remark1"] = ((TextBox)row.FindControl("tbx_Remark1")).Text;
            bll.Model["Remark2"] = ((TextBox)row.FindControl("tbx_Remark2")).Text;
            bll.Model["Remark3"] = ((TextBox)row.FindControl("tbx_Remark3")).Text;
            bll.Model["Remark4"] = ((TextBox)row.FindControl("tbx_Remark4")).Text;

            //判断是否使用浮动底薪
            DropDownList ddl_IsFloating = row.FindControl("ddl_ISFloating") == null ? null : (DropDownList)row.FindControl("ddl_ISFloating");
            if (ddl_IsFloating != null)
                bll.Model["ISFloating"] = ddl_IsFloating.SelectedValue;

            //奖惩Data01~Data09; Data10为小计;社保报销额 Data17;提成调整 Data18;经销商补贴调整金额 Data19
            //卖场导购其他管理费用 Data20~Data29;Data20 为管理费调整金额,Data30 为小计(21~29)         
            bll.Model.Data10 = 0; bll.Model.Data30 = 0;
            for (int i = 1; i < 30; i++)
            {
                TextBox txt = row.FindControl("tbx_Data" + (i < 10 ? "0" : "") + i.ToString()) == null ? null : (TextBox)row.FindControl("tbx_Data" + (i < 10 ? "0" : "") + i.ToString());
                if (txt != null)
                {
                    bll.Model["Data" + (i < 10 ? "0" : "") + i.ToString()] = txt.Text == "" ? "0" : txt.Text;
                    if (i < 10) bll.Model.Data10 += decimal.Parse(bll.Model["Data0" + i.ToString()]);//奖惩小计

                    if (i > 20) bll.Model.Data30 += decimal.Parse(bll.Model["Data" + i.ToString()]);//为管理费调整金额小计
                }
            }
            if (bll.Model.Data11+bll.Model.Data18 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额和调整金额之和不可小于0!");
                return;
            }
            if (bll.Model.Data30 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 卖场导购管理费小计不可小于0!");
                return;
            }
            if (decimal.Parse((row.FindControl("PM_PromotorSalary_RTManageCost") as Label).Text) + bll.Model.Data20 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 导购管理费和调整金额之和不可小于0!");
                return;
            }
            if (bll.Model.Data11 == 0)
            {
                if (bll.Model.Data01 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,销售奖罚不可小于0!");
                    return;
                }
                if (bll.Model.Data02 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,VIP奖罚不可小于0!");
                    return;
                }
                if (bll.Model.Data09 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,奖惩项其他不可小于0!");
                    return;
                }
                if (bll.Model.Data19 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,经销商承担调整金额不可小于0!");
                    return;
                }
            }
            //社保模式为【自购保险】,社保报销额必填
            IList<PM_PromotorSalary> PM_SalaryList = PM_PromotorSalaryBLL.GetModelList("Promotor=" + bll.Model.Promotor + " AND State=3 AND ApproveFlag=1");
            if (PM_SalaryList.Count > 0 && PM_SalaryList[0].InsuranceMode == 8 && bll.Model.Data17 == 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 社保为自购,社保报销额必填!");
                BindGrid();
                return;
            }
            bll.Update();
        }
        if (sender != null)
        {
            BindGrid();
            MessageBox.Show(this, "保存成功");
        }
    }
    protected void BtnSave_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_List.Rows)
        {
            int id = (int)gv_List.DataKeys[row.RowIndex]["PM_SalaryDataObject_ID"];
            PM_SalaryDataObjectBLL bll = new PM_SalaryDataObjectBLL(id);
            bll.Model.ActWorkDays = int.Parse(((TextBox)row.FindControl("tbx_ActWorkDays")).Text);
            if (bll.Model.ActWorkDays > Convert.ToDecimal(ViewState["monthdays"]))
            {
                MessageBox.Show(this, "实际工作天数不能大于会计月天数!错误行:" + (row.RowIndex + 1).ToString() + ";导购员姓名:" + row.Cells[2].Text);
                BindGrid();
                return;

            }

            bll.Model["Remark1"] = ((TextBox)row.FindControl("tbx_Remark1")).Text;
            bll.Model["Remark2"] = ((TextBox)row.FindControl("tbx_Remark2")).Text;
            bll.Model["Remark3"] = ((TextBox)row.FindControl("tbx_Remark3")).Text;
            bll.Model["Remark4"] = ((TextBox)row.FindControl("tbx_Remark4")).Text;

            //判断是否使用浮动底薪
            DropDownList ddl_IsFloating = row.FindControl("ddl_ISFloating") == null ? null : (DropDownList)row.FindControl("ddl_ISFloating");
            if (ddl_IsFloating != null)
                bll.Model["ISFloating"] = ddl_IsFloating.SelectedValue;

            //奖惩Data01~Data09; Data10为小计;社保报销额 Data17;提成调整 Data18;经销商补贴调整金额 Data19
            //卖场导购其他管理费用 Data20~Data29;Data20 为管理费调整金额,Data30 为小计(21~29)
            bll.Model.Data10 = 0; bll.Model.Data30 = 0;
            for (int i = 1; i < 30; i++)
            {
                TextBox txt = row.FindControl("tbx_Data" + (i < 10 ? "0" : "") + i.ToString()) == null ? null : (TextBox)row.FindControl("tbx_Data" + (i < 10 ? "0" : "") + i.ToString());
                if (txt != null)
                {
                    bll.Model["Data" + (i < 10 ? "0" : "") + i.ToString()] = txt.Text == "" ? "0" : txt.Text;
                    if (i < 10) bll.Model.Data10 += decimal.Parse(bll.Model["Data0" + i.ToString()]);//奖惩小计

                    if (i > 20) bll.Model.Data30 += decimal.Parse(bll.Model["Data" + i.ToString()]);//为管理费调整金额小计
                }
            }
            if (bll.Model.Data11+bll.Model.Data18 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额和调整金额之和不可小于0!");
                return;
            }
            if (bll.Model.Data30 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 卖场导购管理费小计不可小于0!");
                return;
            }
            if (decimal.Parse((row.FindControl("PM_PromotorSalary_RTManageCost") as Label).Text) + bll.Model.Data20 < 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 导购管理费和调整金额之和不可小于0!");
                return;
            }
            if (bll.Model.Data11 == 0)
            {
                if (bll.Model.Data01 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,销售奖罚不可小于0!");
                    return;
                }
                if (bll.Model.Data02 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,VIP奖罚不可小于0!");
                    return;
                }
                if (bll.Model.Data09 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,奖惩项其他不可小于0!");
                    return;
                }
                if (bll.Model.Data19 < 0)
                {
                    MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 提成总金额为0时,经销商承担调整金额不可小于0!");
                    return;
                }
            }
            //社保模式为【自购保险】,社保报销额必填
            IList<PM_PromotorSalary> PM_SalaryList = PM_PromotorSalaryBLL.GetModelList("Promotor=" + bll.Model.Promotor + " AND State=3 AND ApproveFlag=1");
            if (PM_SalaryList.Count > 0 && PM_SalaryList[0].InsuranceMode == 8 && bll.Model.Data17 == 0)
            {
                MessageBox.Show(this, "错误行:" + (row.RowIndex + 1).ToString() + ";导购员:" + row.Cells[2].Text + " 社保为自购,社保报销额必填!");
                BindGrid();
                return;
            }
            bll.Update();
        }
        if (sender != null)
        {
            BindGrid();
            MessageBox.Show(this, "保存成功");
        }
    }
 private void ApproveData(string approveflag)
 {
     if (approveflag == "1")
     {
         BtnSave_Click(null, null);
     }
     foreach (GridViewRow row in gv_List.Rows)
     {
         CheckBox chk = (CheckBox)row.FindControl("cbx");
         if (chk.Checked)
         {
             int id = (int)gv_List.DataKeys[row.RowIndex]["PM_SalaryDataObject_ID"];
             PM_SalaryDataObjectBLL bll = new PM_SalaryDataObjectBLL(id);
             bll.Model["ApproveFlag"] = approveflag;
             bll.Update();
         }
     }
 }