protected void bt_Delete_Click(object sender, EventArgs e) { 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][0]; CM_RebateRule_ApplyCityBLL bll = new CM_RebateRule_ApplyCityBLL(id); bll.Delete(); } } BindGrid(); }
protected void bt_Add_Click(object sender, EventArgs e) { IList <CM_RebateRule_ApplyCity> ApplyCitys = CM_RebateRule_ApplyCityBLL.GetModelList("RebateRule=" + ViewState["ID"].ToString()); int city = 0; if (int.TryParse(tr_OrganizeCity.SelectValue, out city) && city > 0) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == city) != null) { MessageBox.Show(this, "对不起,该区域已属于该返利方案,请勿重复添加!"); return; } Addr_OrganizeCityBLL c = new Addr_OrganizeCityBLL(city); foreach (DataRow row in c.GetFullPath().Rows) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == (int)row["ID"]) != null) { MessageBox.Show(this, "对不起,该区域的上级区域" + new Addr_OrganizeCityBLL((int)row["ID"]).Model.Name + "已属于该返利方案,请勿重复添加!"); return; } } foreach (DataRow row in c.GetAllChildNode().Rows) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == (int)row["ID"]) != null) { MessageBox.Show(this, "对不起,该区域的下级区域" + new Addr_OrganizeCityBLL((int)row["ID"]).Model.Name + "已属于该返利方案,请勿重复添加!"); return; } } CM_RebateRule_ApplyCityBLL bll = new CM_RebateRule_ApplyCityBLL(); bll.Model.RebateRule = (int)ViewState["ID"]; bll.Model.OrganizeCity = city; bll.Add(); } BindGrid(); }
protected void bt_Add_Click(object sender, EventArgs e) { IList<CM_RebateRule_ApplyCity> ApplyCitys = CM_RebateRule_ApplyCityBLL.GetModelList("RebateRule=" + ViewState["ID"].ToString()); int city = 0; if (int.TryParse(tr_OrganizeCity.SelectValue, out city) && city > 0) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == city) != null) { MessageBox.Show(this, "对不起,该区域已属于该返利方案,请勿重复添加!"); return; } Addr_OrganizeCityBLL c = new Addr_OrganizeCityBLL(city); foreach (DataRow row in c.GetFullPath().Rows) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == (int)row["ID"]) != null) { MessageBox.Show(this, "对不起,该区域的上级区域" + new Addr_OrganizeCityBLL((int)row["ID"]).Model.Name + "已属于该返利方案,请勿重复添加!"); return; } } foreach (DataRow row in c.GetAllChildNode().Rows) { if (ApplyCitys.FirstOrDefault(p => p.OrganizeCity == (int)row["ID"]) != null) { MessageBox.Show(this, "对不起,该区域的下级区域" + new Addr_OrganizeCityBLL((int)row["ID"]).Model.Name + "已属于该返利方案,请勿重复添加!"); return; } } CM_RebateRule_ApplyCityBLL bll = new CM_RebateRule_ApplyCityBLL(); bll.Model.RebateRule = (int)ViewState["ID"]; bll.Model.OrganizeCity = city; bll.Add(); } BindGrid(); }