protected void bt_DownloadTemplate_Click(object sender, EventArgs e) { #region 获取最迟的销量日期 AC_AccountMonth month = (AC_AccountMonth)ViewState["month"]; DateTime day = DateTime.Today < month.EndDate ? DateTime.Today : month.EndDate; #endregion #region 判断有无选择业代 if (string.IsNullOrEmpty(select_Staff.SelectValue) || select_Staff.SelectValue == "0") { MessageBox.Show(this, "对不起,请选择责任业代!"); return; } #endregion #region 获取业代负责的零售商及所有产品数据 int staff = int.Parse(select_Staff.SelectValue); string condtion = ViewState["ClientType"].ToString() == "2" ? " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)='2'" : ""; IList <CM_Client> clientlists = CM_ClientBLL.GetModelList("ClientType=" + ViewState["ClientType"].ToString() + " AND ClientManager=" + staff.ToString() + " AND ActiveFlag=1 AND ApproveFlag=1 " + condtion + "AND OpenTime<'" + day.ToString("yyyy-MM-dd") + " 23:59:59' ORDER BY Code"); if (clientlists.Count == 0) { MessageBox.Show(this, "对不起,没有当前人直接负责的终端店!"); return; } #endregion string title = (int)ViewState["ClientType"] == 2 ? "分销商" : "零售商"; string filename = title + ((int)ViewState["IsOpponent"] == 9 ? "赠品进货导入模板-" : "产品进销货量导入模板") + select_Staff.SelectText + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; if ((int)ViewState["ClientType"] == 2 && (int)ViewState["IsOpponent"] == 1) { filename = "分销商产品进货导入模板" + select_Staff.SelectText + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; } SVM_DownloadTemplateBLL _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth = month.ID; _bll.Model.State = 1; _bll.Model.IsOpponent = (int)ViewState["IsOpponent"]; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model.DownStaff = staff; if ((int)ViewState["IsOpponent"] == 9) { _bll.Model.ProductGifts = ProdutctGifts.ToString().EndsWith(",") ? ProdutctGifts.ToString().Substring(0, ProdutctGifts.Length - 1) : ProdutctGifts.ToString(); _bll.Model.Testers = Testers.ToString().EndsWith(",") ? Testers.ToString().Substring(0, Testers.Length - 1) : Testers.ToString(); _bll.Model.Gifts = Gifts.ToString().EndsWith(",") ? Gifts.ToString().Substring(0, Gifts.Length - 1) : Gifts.ToString(); } _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Model["ClientType"] = ViewState["ClientType"].ToString(); _bll.Add(); //StringBuilder builder = new StringBuilder(); //builder.Append("alert('请到该页面下载模版!');"); //builder.Append("window.open('ImportHistory.aspx?IsOpponent=" + ViewState["IsOpponent"].ToString()+"&ClientType=" + ViewState["ClientType"].ToString()+"','_blank')"); //MessageBox.ResponseScript(this, builder.ToString()); Response.Redirect("ImportHistory.aspx?IsOpponent=" + ViewState["IsOpponent"].ToString() + "&ClientType=" + ViewState["ClientType"].ToString()); }
protected void bt_DownloadTemplate_Click(object sender, EventArgs e) { #region 获取最迟的销量日期 AC_AccountMonth month = (AC_AccountMonth)ViewState["month"]; DateTime day = DateTime.Today < month.EndDate ? DateTime.Today : month.EndDate; #endregion #region 判断有无选择业代 if (string.IsNullOrEmpty(select_Staff.SelectValue) || select_Staff.SelectValue == "0") { MessageBox.Show(this, "对不起,请选择责任业代!"); return; } #endregion #region 获取业代负责的零售商及所有产品数据 int staff = int.Parse(select_Staff.SelectValue); string condtion = ViewState["ClientType"].ToString() == "2" ? " AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',7)='2'" : ""; IList<CM_Client> clientlists = CM_ClientBLL.GetModelList("ClientType=" + ViewState["ClientType"].ToString() + " AND ClientManager=" + staff.ToString() + " AND ActiveFlag=1 AND ApproveFlag=1 " + condtion + "AND OpenTime<'" + day.ToString("yyyy-MM-dd") + " 23:59:59' ORDER BY Code"); if (clientlists.Count == 0) { MessageBox.Show(this, "对不起,没有当前人直接负责的终端店!"); return; } #endregion string title = (int)ViewState["ClientType"] == 2 ? "分销商" : "零售商"; string filename = title+((int)ViewState["IsOpponent"] == 9 ? "赠品进货导入模板-" : "产品进销货量导入模板") + select_Staff.SelectText + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; if ((int)ViewState["ClientType"] == 2 && (int)ViewState["IsOpponent"] == 1) { filename = "分销商产品进货导入模板" + select_Staff.SelectText + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; } SVM_DownloadTemplateBLL _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth = month.ID; _bll.Model.State = 1; _bll.Model.IsOpponent = (int)ViewState["IsOpponent"]; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model.DownStaff = staff; if ((int)ViewState["IsOpponent"] == 9) { _bll.Model.ProductGifts = ProdutctGifts.ToString().EndsWith(",") ? ProdutctGifts.ToString().Substring(0,ProdutctGifts.Length - 1) : ProdutctGifts.ToString(); _bll.Model.Testers = Testers.ToString().EndsWith(",") ? Testers.ToString().Substring(0,Testers.Length - 1) : Testers.ToString(); _bll.Model.Gifts = Gifts.ToString().EndsWith(",") ? Gifts.ToString().Substring(0,Gifts.Length - 1) : Gifts.ToString(); } _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Model["ClientType"] = ViewState["ClientType"].ToString(); _bll.Add(); //StringBuilder builder = new StringBuilder(); //builder.Append("alert('请到该页面下载模版!');"); //builder.Append("window.open('ImportHistory.aspx?IsOpponent=" + ViewState["IsOpponent"].ToString()+"&ClientType=" + ViewState["ClientType"].ToString()+"','_blank')"); //MessageBox.ResponseScript(this, builder.ToString()); Response.Redirect("ImportHistory.aspx?IsOpponent=" + ViewState["IsOpponent"].ToString() + "&ClientType=" + ViewState["ClientType"].ToString()); }
protected void ddl_AccountMonth2_SelectedIndexChanged(object sender, EventArgs e) { if ((int)(ViewState["IsOpponent"]) == 3 && SVM_DownloadTemplateBLL.GetModelList("AccountMonth=" + ddl_AccountMonth2.SelectedValue + " AND IsOpponent=3 AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3)='1'").Count == 0) { string filename = "办事处月度费率导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; SVM_DownloadTemplateBLL _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth = int.Parse(ddl_AccountMonth2.SelectedValue); _bll.Model.State = 1; _bll.Model.IsOpponent = 3; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model["OrganizeCity"] = "1"; _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Add(); } }
protected void ddl_AccountMonth2_SelectedIndexChanged(object sender, EventArgs e) { if ((int)(ViewState["IsOpponent"]) == 3 && SVM_DownloadTemplateBLL.GetModelList("AccountMonth=" + ddl_AccountMonth2.SelectedValue + " AND IsOpponent=3 AND MCS_SYS.dbo.UF_Spilt(ExtPropertys,'|',3)='1'").Count == 0) { string filename = "办事处月度费率导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; SVM_DownloadTemplateBLL _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth = int.Parse(ddl_AccountMonth2.SelectedValue); _bll.Model.State = 1; _bll.Model.IsOpponent = 3; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model["OrganizeCity"] = "1"; _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Add(); } }
protected void bt_DownloadTemplate_Click(object sender, EventArgs e) { SVM_DownloadTemplateBLL _bll; string filename; if (Produtcts.Length == 1) { MessageBox.Show(this, "对不起,请选择品项!"); return; } // string filename = ddl_OrganizeCity.SelectedItem.Text.Replace("------已操作", "") + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; StringBuilder organizecitys = new StringBuilder(); StringBuilder citynames = new StringBuilder(); foreach (ListItem item in chk_Citylist.Items) { if (item.Selected) { organizecitys.Append(item.Value + ","); citynames.Append(item.Text.Substring(0, item.Text.IndexOf("营业部")) + ","); } } if (organizecitys.ToString().EndsWith(",")) { organizecitys.Remove(organizecitys.Length - 1, 1); citynames.Remove(citynames.Length - 1, 1); } filename = citynames.ToString() + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; if (filename.Length > 100) { filename = ddl_AccountMonth.SelectedItem.Text + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; } _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth = int.Parse(ddl_AccountMonth.SelectedValue); _bll.Model.State = 1; _bll.Model.IsOpponent = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model["OrganizeCity"] = organizecitys.ToString(); _bll.Model.ProductGifts = Produtcts.ToString().Substring(1, Produtcts.Length - 2); _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Add(); Response.Redirect("ImportHistory.aspx?IsOpponent=2"); }
protected void bt_DownloadTemplate_Click(object sender, EventArgs e) { SVM_DownloadTemplateBLL _bll; string filename; if (Produtcts.Length == 1) { MessageBox.Show(this, "对不起,请选择品项!"); return; } // string filename = ddl_OrganizeCity.SelectedItem.Text.Replace("------已操作", "") + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; StringBuilder organizecitys = new StringBuilder(); StringBuilder citynames = new StringBuilder(); foreach (ListItem item in chk_Citylist.Items) { if (item.Selected) { organizecitys.Append(item.Value+","); citynames.Append(item.Text.Substring(0, item.Text.IndexOf("营业部"))+","); } } if (organizecitys.ToString().EndsWith(",")) { organizecitys.Remove(organizecitys.Length - 1,1); citynames.Remove(citynames.Length - 1, 1); } filename = citynames.ToString() + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; if (filename.Length > 100) filename = ddl_AccountMonth.SelectedItem.Text + "重点品项目标导入模板" + "-" + DateTime.Today.ToString("yyyyMMdd") + ".xls"; _bll = new SVM_DownloadTemplateBLL(); _bll.Model.Name = filename; _bll.Model.AccountMonth =int.Parse(ddl_AccountMonth.SelectedValue); _bll.Model.State = 1; _bll.Model.IsOpponent = 2; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.InsertTime = DateTime.Now; _bll.Model["OrganizeCity"] = organizecitys.ToString(); _bll.Model.ProductGifts = Produtcts.ToString().Substring(1, Produtcts.Length - 2); _bll.Model["UserName"] = Session["UserName"].ToString(); _bll.Add(); Response.Redirect("ImportHistory.aspx?IsOpponent=2"); }