protected void btn_Save_Click(object sender, EventArgs e) { ListTable<PDT_ClassifyGiftCostRate> _details = (ListTable<PDT_ClassifyGiftCostRate>)ViewState["Details"]; PDT_ClassifyGiftCostRateBLL _bll = new PDT_ClassifyGiftCostRateBLL(); foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Added)) { _bll.Model = m; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.ApproveFlag = 1; _bll.Add(); } foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Modified)) { _bll.Model = m; _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Deleted)) { _bll.Model = m; _bll.Delete(m.ID); } if ((int)ViewState["Client"] != 0) Response.Redirect("PDT_ClassifyGiftCostRate.aspx?Client=" + select_Client.SelectValue); else Response.Redirect("PDT_ClassifyGiftCostRate.aspx?OrganizeCity=" + tr_OrganizeCity.SelectValue); }
protected void btn_Search_Click(object sender, EventArgs e) { if (select_Client.SelectValue == "" || select_Client.SelectValue == "0") { int level = int.Parse(ddl_Level.SelectedValue); string citys = ""; DataTable dt = TreeTableBLL.GetAllChildNodeByNodes("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "SuperID", tr_OrganizeCity.SelectValue); if (level > 0) { foreach (DataRow row in dt.Select("Level=" + level)) { citys += row["ID"] + ","; } citys = citys.Substring(0, citys.Length - 1); } else { citys = tr_OrganizeCity.SelectValue; } ListTable <PDT_ClassifyGiftCostRate> _details = new ListTable <PDT_ClassifyGiftCostRate> (PDT_ClassifyGiftCostRateBLL.GetModelList("OrganizeCity in (" + citys + ") "), "ID"); ViewState["Details"] = _details; } else { ListTable <PDT_ClassifyGiftCostRate> _details = new ListTable <PDT_ClassifyGiftCostRate> (PDT_ClassifyGiftCostRateBLL.GetModelList("Client=" + select_Client.SelectValue), "ID"); ViewState["Details"] = _details; } BindGrid(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ViewState["Client"] = Request.QueryString["Client"] == null ? 0 : int.Parse(Request.QueryString["Client"]); ViewState["OrganizeCity"] = Request.QueryString["OrganizeCity"] == null ? 0 : int.Parse(Request.QueryString["OrganizeCity"]); BindDropDown(); if ((int)ViewState["Client"] != 0) { select_Client.SelectValue = ViewState["Client"].ToString(); select_Client.SelectText = new CM_ClientBLL((int)ViewState["Client"]).Model.FullName; } else if ((int)ViewState["OrganizeCity"] != 0) { tr_OrganizeCity.SelectValue = ViewState["OrganizeCity"].ToString(); } if (select_Client.SelectValue == "" || select_Client.SelectValue == "0") { int level = int.Parse(ddl_Level.SelectedValue); string citys = ""; Addr_OrganizeCityBLL orgcity = new Addr_OrganizeCityBLL(int.Parse(tr_OrganizeCity.SelectValue)); DataTable dt = TreeTableBLL.GetAllChildNodeByNodes("MCS_SYS.dbo.Addr_OrganizeCity", "ID", "SuperID", tr_OrganizeCity.SelectValue); if (level > 0) { foreach (DataRow row in dt.Select("Level=" + level)) { citys += row["ID"] + ","; } citys = citys.Substring(0, citys.Length - 1); } else { citys = tr_OrganizeCity.SelectValue; } ListTable <PDT_ClassifyGiftCostRate> _details = new ListTable <PDT_ClassifyGiftCostRate> (PDT_ClassifyGiftCostRateBLL.GetModelList("OrganizeCity in (" + citys + ") "), "ID"); ViewState["Details"] = _details; } else { ListTable <PDT_ClassifyGiftCostRate> _details = new ListTable <PDT_ClassifyGiftCostRate> (PDT_ClassifyGiftCostRateBLL.GetModelList("Client=" + select_Client.SelectValue), "ID"); ViewState["Details"] = _details; } ViewState["MAXID"] = ((ListTable <PDT_ClassifyGiftCostRate>)ViewState["Details"]).GetListItem().Count > 0 ? ((ListTable <PDT_ClassifyGiftCostRate>)ViewState["Details"]).GetListItem().Max(p => p.ID) : 0; BindGrid(); } }
protected void btn_Save_Click(object sender, EventArgs e) { ListTable <PDT_ClassifyGiftCostRate> _details = (ListTable <PDT_ClassifyGiftCostRate>)ViewState["Details"]; PDT_ClassifyGiftCostRateBLL _bll = new PDT_ClassifyGiftCostRateBLL(); foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Added)) { _bll.Model = m; _bll.Model.InsertStaff = (int)Session["UserID"]; _bll.Model.ApproveFlag = 1; _bll.Add(); } foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Modified)) { _bll.Model = m; _bll.Model.UpdateStaff = (int)Session["UserID"]; _bll.Update(); } foreach (PDT_ClassifyGiftCostRate m in _details.GetListItem(ItemState.Deleted)) { _bll.Model = m; _bll.Delete(m.ID); } if ((int)ViewState["Client"] != 0) { Response.Redirect("PDT_ClassifyGiftCostRate.aspx?Client=" + select_Client.SelectValue); } else { Response.Redirect("PDT_ClassifyGiftCostRate.aspx?OrganizeCity=" + tr_OrganizeCity.SelectValue); } }
private void threadStartImport(BackgroundWorker worker, DoWorkEventArgs e) { bool bFind = false; StringBuilder _xhs_success = new StringBuilder("");//成功导入的记录序号(用于定期批量更新导入标志) string XH = ""; int ClientID = 0, AccountMonth = 0, Brand = 0, Classify = 0,DIClassify=0; decimal FeeRate; try { lb_Count.Text = dt_Amount.Rows.Count.ToString(); for (int i = 0; i < dt_Amount.Rows.Count; i++) { worker.ReportProgress((i + 1) * 100 / this.dt_Amount.Rows.Count, i); if (worker.CancellationPending) { e.Cancel = true; break; } XH = dt_Amount.Rows[i]["序号"].ToString(); IList<CM_Client> _cmlist = CM_ClientBLL.GetModelList("Code='" + dt_Amount.Rows[i]["经销商代码"].ToString() + "' AND ActiveFlag=1 AND ApproveFlag=1"); if (_cmlist.Count == 1 && _cmlist[0].FullName == dt_Amount.Rows[i]["经销商名称"].ToString() && _cmlist[0]["DIClassify"]=="1") { ClientID = _cmlist[0].ID;//经销商为子户头时,取主户头 } else { UpdateImportFlag(i, "导入失败,经销商代码不正确"); continue; } if (dt_Amount.Rows[i]["品牌"].ToString()!= "") { IList<PDT_Brand> _listbrand = PDT_BrandBLL.GetModelList("Name='" + dt_Amount.Rows[i]["品牌"].ToString()+"'"); if (_listbrand.Count == 0) { UpdateImportFlag(i, "导入失败,该品牌不存在"); continue; } else { Brand = _listbrand[0].ID; } } foreach (Dictionary_Data item in DictionaryBLL.Dictionary_Data_GetAlllList("Type IN (SELECT ID FROM MCS_SYS.dbo.Dictionary_Type WHERE TableName='ORD_GiftClassify')")) { if (item.Name == dt_Amount.Rows[i]["有导无导标志"].ToString().Trim()) { Classify = int.Parse(item.Code); bFind = true; break; } } if (!bFind) { UpdateImportFlag(i, "导入失败,有导无导标志错误!"); continue; } IList<PDT_ClassifyGiftCostRate> _listamount = PDT_ClassifyGiftCostRateBLL.GetModelList("Enabled='Y' AND Client=" + ClientID.ToString() + " AND PDTBrand=" + Brand.ToString() + " AND GiftCostClassify=" + Classify.ToString()); PDT_ClassifyGiftCostRateBLL _bll = new PDT_ClassifyGiftCostRateBLL(); if (_listamount.Count > 0) { _bll = new PDT_ClassifyGiftCostRateBLL(_listamount[0].ID); } else { _bll.Model.AccountMonth = AccountMonth; _bll.Model.Client = ClientID; _bll.Model.PDTBrand = Brand; _bll.Model.GiftCostClassify = Classify; _bll.Model.Enabled = "Y"; _bll.Model.OrganizeCity = 1; } #region 记录需更新费用 decimal.TryParse(dt_Amount.Rows[i]["赠品费率%"].ToString().Trim(), out FeeRate); _bll.Model.GiftCostRate = FeeRate; _bll.Model.Remark = dt_Amount.Rows[i]["备注"].ToString().Trim(); if (_bll.Model.ID > 0) { _bll.Update(); } else { _bll.Add(); } dt_Amount.Rows[i]["导入标志"] = "导入成功"; _xhs_success.Append(XH + ","); #endregion } UpdateSuccess(_xhs_success.ToString()); } catch (System.Exception err) { UpdateSuccess(_xhs_success.ToString()); MessageBox.Show(err.Source + "~r~n" + err.StackTrace, err.Message); } return; }
private void threadStartImport(BackgroundWorker worker, DoWorkEventArgs e) { bool bFind = false; StringBuilder _xhs_success = new StringBuilder("");//成功导入的记录序号(用于定期批量更新导入标志) string XH = ""; int ClientID = 0, AccountMonth = 0, Brand = 0, Classify = 0, DIClassify = 0; decimal FeeRate; try { lb_Count.Text = dt_Amount.Rows.Count.ToString(); for (int i = 0; i < dt_Amount.Rows.Count; i++) { worker.ReportProgress((i + 1) * 100 / this.dt_Amount.Rows.Count, i); if (worker.CancellationPending) { e.Cancel = true; break; } XH = dt_Amount.Rows[i]["序号"].ToString(); IList <CM_Client> _cmlist = CM_ClientBLL.GetModelList("Code='" + dt_Amount.Rows[i]["经销商代码"].ToString() + "' AND ActiveFlag=1 AND ApproveFlag=1"); if (_cmlist.Count == 1 && _cmlist[0].FullName == dt_Amount.Rows[i]["经销商名称"].ToString() && _cmlist[0]["DIClassify"] == "1") { ClientID = _cmlist[0].ID;//经销商为子户头时,取主户头 } else { UpdateImportFlag(i, "导入失败,经销商代码不正确"); continue; } if (dt_Amount.Rows[i]["品牌"].ToString() != "") { IList <PDT_Brand> _listbrand = PDT_BrandBLL.GetModelList("Name='" + dt_Amount.Rows[i]["品牌"].ToString() + "'"); if (_listbrand.Count == 0) { UpdateImportFlag(i, "导入失败,该品牌不存在"); continue; } else { Brand = _listbrand[0].ID; } } foreach (Dictionary_Data item in DictionaryBLL.Dictionary_Data_GetAlllList("Type IN (SELECT ID FROM MCS_SYS.dbo.Dictionary_Type WHERE TableName='ORD_GiftClassify')")) { if (item.Name == dt_Amount.Rows[i]["有导无导标志"].ToString().Trim()) { Classify = int.Parse(item.Code); bFind = true; break; } } if (!bFind) { UpdateImportFlag(i, "导入失败,有导无导标志错误!"); continue; } IList <PDT_ClassifyGiftCostRate> _listamount = PDT_ClassifyGiftCostRateBLL.GetModelList("Enabled='Y' AND Client=" + ClientID.ToString() + " AND PDTBrand=" + Brand.ToString() + " AND GiftCostClassify=" + Classify.ToString()); PDT_ClassifyGiftCostRateBLL _bll = new PDT_ClassifyGiftCostRateBLL(); if (_listamount.Count > 0) { _bll = new PDT_ClassifyGiftCostRateBLL(_listamount[0].ID); } else { _bll.Model.AccountMonth = AccountMonth; _bll.Model.Client = ClientID; _bll.Model.PDTBrand = Brand; _bll.Model.GiftCostClassify = Classify; _bll.Model.Enabled = "Y"; _bll.Model.OrganizeCity = 1; } #region 记录需更新费用 decimal.TryParse(dt_Amount.Rows[i]["赠品费率%"].ToString().Trim(), out FeeRate); _bll.Model.GiftCostRate = FeeRate; _bll.Model.Remark = dt_Amount.Rows[i]["备注"].ToString().Trim(); if (_bll.Model.ID > 0) { _bll.Update(); } else { _bll.Add(); } dt_Amount.Rows[i]["导入标志"] = "导入成功"; _xhs_success.Append(XH + ","); #endregion } UpdateSuccess(_xhs_success.ToString()); } catch (System.Exception err) { UpdateSuccess(_xhs_success.ToString()); MessageBox.Show(err.Source + "~r~n" + err.StackTrace, err.Message); } return; }