private void BindGrid() { int month = 0, organizecity = 0, staff = 0; if (int.TryParse(ddl_AccountMonth.SelectedValue, out month) && int.TryParse(tr_OrganizeCity.SelectValue, out organizecity)) { string condition = "AccountMonth = " + month.ToString() + " AND TrackDate IS NULL"; int.TryParse(select_Staff.SelectValue, out staff); if (staff > 0) { string client = string.Empty; IList <CM_Client> list = CM_ClientBLL.GetModelList(" OrganizeCity =" + organizecity + " AND ClientType = 3 AND ActiveFlag = 1 AND ApproveFlag = 1 AND [MCS_SYS].[dbo].[UF_Spilt](ExtPropertys,'|',27) = '1' AND ClientManager = " + staff.ToString()); if (list != null && list.Count > 0) { foreach (CM_Client item in list) { client += item.ID.ToString() + ","; } client = client.Substring(0, client.Length - 1); } if (!string.IsNullOrEmpty(client)) { condition += " AND (Staff = " + staff.ToString() + " OR Client in(" + client + "))"; } else { condition += " AND Staff = " + staff.ToString(); } } if (organizecity > 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 OrganizeCity IN (" + orgcitys + ")"; } if (ddl_IsSubmit.SelectedValue != "0") { condition += " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)='" + ddl_IsSubmit.SelectedItem.Text + "'"; } gv_List.BindGrid(TC_TrackCardBLL.GetModelList(condition)); cbx_CheckAll.Checked = false; } }
protected void bt_Init_Click(object sender, EventArgs e) { int month = 0, organizecity = 0, staff = 0; if (int.TryParse(ddl_AccountMonth.SelectedValue, out month) && int.TryParse(tr_OrganizeCity.SelectValue, out organizecity) && int.TryParse(select_Staff.SelectValue, out staff)) { TC_TrackCardBLL.InitTarget(month, organizecity, staff, (int)Session["UserID"]); } gv_List.PageIndex = 0; BindGrid(); }
protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"]; TC_TrackCardBLL bll = new TC_TrackCardBLL(id); CheckBox cbx = (CheckBox)e.Row.FindControl("cbx"); if (bll != null && bll.Model["IsSubmit"] == "是") { cbx.Checked = true; } else { cbx.Checked = false; } } }
protected void bt_Approve_Click(object sender, EventArgs e) { if (gv_List.Rows.Count > 0) { bt_Save_Click(null, null); foreach (GridViewRow row in gv_List.Rows) { CheckBox cbx = (CheckBox)row.FindControl("cbx"); if (cbx != null && cbx.Checked) { int id = (int)gv_List.DataKeys[row.RowIndex]["ID"]; TC_TrackCardBLL bll = new TC_TrackCardBLL(id); bll.Model.ApproveFlag = 1; bll.Update(); } } Response.Redirect("TC_TrackCardListByStaff.aspx?OrganizeCity=" + tr_OrganizeCity.SelectValue + "&AccountMonth=" + ddl_AccountMonth.SelectedValue + "&Staff=" + (select_Staff.SelectValue == "" ? "0" : select_Staff.SelectValue)); } }
private void BindGrid() { int month = 0, organizecity = 0, staff = 0; DateTime trackdate = DateTime.Today; if (int.TryParse(tr_OrganizeCity.SelectValue, out organizecity) && DateTime.TryParse(tbx_TrackDate.Text, out trackdate)) { month = AC_AccountMonthBLL.GetMonthByDate(trackdate); string condition = "TrackDate = '" + trackdate.ToString("yyyy-MM-dd") + "'"; int.TryParse(select_Staff.SelectValue, out staff); if (staff > 0) { condition += " AND Staff = " + staff.ToString(); } if (organizecity > 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 OrganizeCity IN (" + orgcitys + ")"; } if (ddl_IsSubmit.SelectedValue != "0") { condition += " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',5)='" + ddl_IsSubmit.SelectedItem.Text + "'"; } IList <TC_TrackCard> list = TC_TrackCardBLL.GetModelList(condition); gv_List.BindGrid <TC_TrackCard>(list); } }
protected void bt_Init_Click(object sender, EventArgs e) { int month = 0, organizecity = 0, staff = 0; DateTime trackdate = DateTime.Today; if (int.TryParse(tr_OrganizeCity.SelectValue, out organizecity) && int.TryParse(select_Staff.SelectValue, out staff) && DateTime.TryParse(tbx_TrackDate.Text, out trackdate)) { month = AC_AccountMonthBLL.GetMonthByDate(trackdate); #region 限制填报规则 if (trackdate > DateTime.Today) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报今天之后的数据!"); return; } if (trackdate < DateTime.Today.AddDays(-7)) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报7天之前的数据!"); return; } if (DateTime.Today.Day > 5 && trackdate.Day <= 5) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报5日之前的数据!"); return; } else if (DateTime.Today.Day > 10 && trackdate.Day <= 10) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报10日之前的数据!"); return; } else if (DateTime.Today.Day > 15 && trackdate.Day <= 15) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报15日之前的数据!"); return; } else if (DateTime.Today.Day > 20 && trackdate.Day <= 20) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报20日之前的数据!"); return; } else if (DateTime.Today.Day > 25 && trackdate.Day <= 25) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报25日之前的数据!"); return; } else if (DateTime.Today.Month != trackdate.Month) { tbx_TrackDate.Text = DateTime.Today.ToString("yyyy-MM-dd"); MessageBox.Show(this, "对不起,不能填报上月的数据!"); return; } #endregion TC_TrackCardBLL.InitTrack(month, organizecity, staff, trackdate, (int)Session["UserID"]); } BindGrid(); }
protected void bt_Save_Click(object sender, EventArgs e) { bool IsCheck = false; for (int i = 0; i < gv_List.Rows.Count; i++) { int id = (int)gv_List.DataKeys[i]["ID"]; CheckBox cbx = (CheckBox)gv_List.Rows[i].FindControl("cbx"); TC_TrackCardBLL bll = new TC_TrackCardBLL(id); if (bll.Model != null && bll.Model.ApproveFlag != 1 && cbx.Checked) { TextBox tbx; tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data01"); if (tbx != null) { bll.Model.Data01 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data02"); if (tbx != null) { bll.Model.Data02 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data03"); if (tbx != null) { bll.Model.Data03 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data04"); if (tbx != null) { bll.Model.Data04 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data05"); if (tbx != null) { bll.Model.Data05 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data06"); if (tbx != null) { bll.Model.Data06 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data07"); if (tbx != null) { bll.Model.Data07 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data08"); if (tbx != null) { bll.Model.Data08 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data09"); if (tbx != null) { bll.Model.Data09 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data10"); if (tbx != null) { bll.Model.Data10 = int.Parse(tbx.Text); } bll.Model["IsSubmit"] = "是"; bll.Update(); IsCheck = true; } } if (!IsCheck) { MessageBox.Show(this, "请勾选要保存的日跟踪表数据"); return; } BindGrid(); MessageBox.Show(this, "保存成功!"); }
protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int id = (int)gv_List.DataKeys[e.Row.RowIndex]["ID"]; TC_TrackCardBLL bll = new TC_TrackCardBLL(id); CheckBox cbx = (CheckBox)e.Row.FindControl("cbx"); if (bll != null && bll.Model["IsSubmit"] == "是") { cbx.Checked = true; } else cbx.Checked = false; } }
protected void bt_Save_Click(object sender, EventArgs e) { bool IsCheck = false; for (int i = 0; i < gv_List.Rows.Count; i++) { int id = (int)gv_List.DataKeys[i]["ID"]; CheckBox cbx = (CheckBox)gv_List.Rows[i].FindControl("cbx"); TC_TrackCardBLL bll = new TC_TrackCardBLL(id); if (bll.Model != null && bll.Model.ApproveFlag != 1 && cbx.Checked) { TextBox tbx; tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data01"); if (tbx != null) bll.Model.Data01 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data02"); if (tbx != null) bll.Model.Data02 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data03"); if (tbx != null) bll.Model.Data03 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data04"); if (tbx != null) bll.Model.Data04 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data05"); if (tbx != null) bll.Model.Data05 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data06"); if (tbx != null) bll.Model.Data06 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data07"); if (tbx != null) bll.Model.Data07 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data08"); if (tbx != null) bll.Model.Data08 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data09"); if (tbx != null) bll.Model.Data09 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data10"); if (tbx != null) bll.Model.Data10 = int.Parse(tbx.Text); bll.Model["IsSubmit"] = "是"; bll.Update(); IsCheck = true; } } if (!IsCheck) { MessageBox.Show(this,"请勾选要保存的日跟踪表数据"); return; } BindGrid(); MessageBox.Show(this, "保存成功!"); }
private void BindGrid() { int month = 0, organizecity = 0, staff = 0; if (int.TryParse(tr_OrganizeCity.SelectValue, out organizecity) && int.TryParse(ddl_AccountMonth.SelectedValue, out month)) { int.TryParse(select_Staff.SelectValue, out staff); //员工不选时,查看该片区所有人员跟踪表 DataTable dt = TC_TrackCardBLL.GetListByStaff(month, organizecity, staff, ddl_ISWanYuan.SelectedValue); if (dt.Rows.Count > 0) { #region 矩阵表 dt = MatrixTable.Matrix(dt, new string[] { "CityName1", "CityName2", "CityName3", "CityName4", "CityName5", "StaffName", "ClientName", "ShortName", "IsPromote", "Promotor", "Salesroom", "PreMonthSalesVolume", "TargetDate01", "TargetDate02", "TargetDate04", "TargetDate03" }, new string[] { "D", "TrackDate" }, new string[] { "Data01", "Data02", "Data04", "Data03" }, false, true); dt = MatrixTable.ColumnSummaryTotal(dt, new int[] { 1 }, new string[] { "Data01", "Data02", "Data04", "Data03" }); #endregion #region 加入行小计 MatrixTable.TableAddRowSubTotal_Matric(dt, new string[] { "CityName1", "CityName2", "CityName3", "CityName4", "CityName5", "StaffName" }, 11, new string[] { "Data01", "Data02", "Data04", "Data03" }, true); #endregion #region 统计完成率 dt.Columns.Add(new DataColumn("完成率%→Data01", Type.GetType("System.Int32"), "IIF([TargetDate01]=0,0,[合计→Data01]/[TargetDate01])*100")); dt.Columns.Add(new DataColumn("完成率%→Data02", Type.GetType("System.Int32"), "IIF([TargetDate02]=0,0,[合计→Data02]/[TargetDate02])*100")); dt.Columns.Add(new DataColumn("完成率%→Data04", Type.GetType("System.Int32"), "IIF([TargetDate04]=0,0,[合计→Data04]/[TargetDate04])*100")); dt.Columns.Add(new DataColumn("完成率%→Data03", Type.GetType("System.Int32"), "IIF([TargetDate03]=0,0,[合计→Data03]/[TargetDate03])*100")); #endregion #region 统计排名 dt.Columns.Add(new DataColumn("排名→Data01", Type.GetType("System.Int32"))); dt.Columns.Add(new DataColumn("排名→Data02", Type.GetType("System.Int32"))); dt.Columns.Add(new DataColumn("排名→Data04", Type.GetType("System.Int32"))); dt.Columns.Add(new DataColumn("排名→Data03", Type.GetType("System.Int32"))); DataView dv = new DataView(dt); dv.RowFilter = "CityName1<>'总计' AND CityName2<>'小计' AND CityName3<>'小计' AND CityName4<>'小计' AND CityName5<>'小计' AND StaffName<>'小计' AND ClientName<>'小计'"; int prevalue = -1, presort = 0; #region Data01完成率排名 dv.Sort = "[完成率%→Data01] DESC"; for (int i = 0; i < dv.Count; i++) { if ((int)dv[i]["完成率%→Data01"] == prevalue) { dv[i]["排名→Data01"] = presort; } else { dv[i]["排名→Data01"] = i + 1; prevalue = (int)dv[i]["完成率%→Data01"]; presort = i + 1; } } #endregion #region Data02完成率排名 dv.Sort = "[完成率%→Data02] DESC"; for (int i = 0; i < dv.Count; i++) { if ((int)dv[i]["完成率%→Data02"] == prevalue) { dv[i]["排名→Data02"] = presort; } else { dv[i]["排名→Data02"] = i + 1; prevalue = (int)dv[i]["完成率%→Data02"]; presort = i + 1; } } #endregion #region Data04完成率排名 dv.Sort = "[完成率%→Data04] DESC"; for (int i = 0; i < dv.Count; i++) { if ((int)dv[i]["完成率%→Data04"] == prevalue) { dv[i]["排名→Data04"] = presort; } else { dv[i]["排名→Data04"] = i + 1; prevalue = (int)dv[i]["完成率%→Data04"]; presort = i + 1; } } #endregion #region Data03完成率排名 dv.Sort = "[完成率%→Data03] DESC"; for (int i = 0; i < dv.Count; i++) { if ((int)dv[i]["完成率%→Data03"] == prevalue) { dv[i]["排名→Data03"] = presort; } else { dv[i]["排名→Data03"] = i + 1; prevalue = (int)dv[i]["完成率%→Data03"]; presort = i + 1; } } #endregion #endregion #region 列表字段名称替换 dt.Columns["CityName1"].ColumnName = "部"; dt.Columns["CityName2"].ColumnName = "省区"; dt.Columns["CityName3"].ColumnName = "区域"; dt.Columns["CityName4"].ColumnName = "城市"; dt.Columns["CityName5"].ColumnName = "县城"; dt.Columns["ClientName"].ColumnName = "门店全称"; dt.Columns["ShortName"].ColumnName = "门店简称"; dt.Columns["StaffName"].ColumnName = "员工"; dt.Columns["IsPromote"].ColumnName = "促销店"; dt.Columns["Promotor"].ColumnName = "促销员"; dt.Columns["Salesroom"].ColumnName = "门店容量(元)"; dt.Columns["PreMonthSalesVolume"].ColumnName = "上月销量"; dt.Columns["TargetDate01"].ColumnName = "任务→ →销量(元)"; dt.Columns["TargetDate02"].ColumnName = "任务→ →档案数(自抢档案)"; dt.Columns["TargetDate04"].ColumnName = "任务→ →档案数(NE提供档案)"; dt.Columns["TargetDate03"].ColumnName = "任务→ →送货上门数"; foreach (DataColumn c in dt.Columns) { if (c.ColumnName.EndsWith("→Data01")) { c.ColumnName = c.ColumnName.Replace("→Data01", "→销量(元)"); } if (c.ColumnName.EndsWith("→Data02")) { c.ColumnName = c.ColumnName.Replace("→Data02", "→档案数(自抢档案)"); } if (c.ColumnName.EndsWith("→Data04")) { c.ColumnName = c.ColumnName.Replace("→Data04", "→档案数(NE提供档案)"); } if (c.ColumnName.EndsWith("→Data03")) { c.ColumnName = c.ColumnName.Replace("→Data03", "→送货上门数"); } } #endregion gv_List.DataSource = dt; gv_List.DataBind(); gv_List.Width = new Unit(dt.Columns.Count * 50); MatrixTable.GridViewMatric(gv_List); } else { gv_List.DataBind(); } } }
protected void bt_Save_Click(object sender, EventArgs e) { if (gv_List.Rows.Count > 0) { for (int i = 0; i < gv_List.Rows.Count; i++) { int id = (int)gv_List.DataKeys[i]["ID"]; TC_TrackCardBLL bll = new TC_TrackCardBLL(id); if (bll.Model != null && bll.Model.ApproveFlag != 1) { TextBox tbx; tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data01"); if (tbx != null) bll.Model.Data01 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data02"); if (tbx != null) bll.Model.Data02 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data03"); if (tbx != null) bll.Model.Data03 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data04"); if (tbx != null) bll.Model.Data04 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data05"); if (tbx != null) bll.Model.Data05 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data06"); if (tbx != null) bll.Model.Data06 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data07"); if (tbx != null) bll.Model.Data07 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data08"); if (tbx != null) bll.Model.Data08 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data09"); if (tbx != null) bll.Model.Data09 = int.Parse(tbx.Text); tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data10"); if (tbx != null) bll.Model.Data10 = int.Parse(tbx.Text); if (bll.Model.Data01 != 0 || bll.Model.Data02 != 0 || bll.Model.Data03 != 0 || bll.Model.Data04 != 0 || bll.Model.Data05 != 0 || bll.Model.Data06 != 0 || bll.Model.Data07 != 0 || bll.Model.Data08 != 0 || bll.Model.Data09 != 0 || bll.Model.Data10 != 0) { bll.Model["IsSubmit"] = "是"; } bll.Update(); } } if (sender != null) { BindGrid(); MessageBox.Show(this, "保存成功!"); } } }
protected void bt_Save_Click(object sender, EventArgs e) { if (gv_List.Rows.Count > 0) { for (int i = 0; i < gv_List.Rows.Count; i++) { int id = (int)gv_List.DataKeys[i]["ID"]; TC_TrackCardBLL bll = new TC_TrackCardBLL(id); if (bll.Model != null && bll.Model.ApproveFlag != 1) { TextBox tbx; tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data01"); if (tbx != null) { bll.Model.Data01 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data02"); if (tbx != null) { bll.Model.Data02 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data03"); if (tbx != null) { bll.Model.Data03 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data04"); if (tbx != null) { bll.Model.Data04 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data05"); if (tbx != null) { bll.Model.Data05 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data06"); if (tbx != null) { bll.Model.Data06 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data07"); if (tbx != null) { bll.Model.Data07 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data08"); if (tbx != null) { bll.Model.Data08 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data09"); if (tbx != null) { bll.Model.Data09 = int.Parse(tbx.Text); } tbx = (TextBox)gv_List.Rows[i].FindControl("tbx_Data10"); if (tbx != null) { bll.Model.Data10 = int.Parse(tbx.Text); } if (bll.Model.Data01 != 0 || bll.Model.Data02 != 0 || bll.Model.Data03 != 0 || bll.Model.Data04 != 0 || bll.Model.Data05 != 0 || bll.Model.Data06 != 0 || bll.Model.Data07 != 0 || bll.Model.Data08 != 0 || bll.Model.Data09 != 0 || bll.Model.Data10 != 0) { bll.Model["IsSubmit"] = "是"; } bll.Update(); } } if (sender != null) { BindGrid(); MessageBox.Show(this, "保存成功!"); } } }