private void BindGrid() { if (ViewState["ClientID"] != null) { CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]); #region 绑定住宿人员 gv_Staff.ConditionString = "MCS_CM.dbo.CM_StaffInProperty.Client = " + ViewState["ClientID"].ToString() + " AND Org_Staff.Dimission=1"; gv_Staff.BindGrid(); #endregion #region 绑定兼管片区 if (bll.Model.OrganizeCity > 1) { ddl_PropertyInOrganizeCity.Items.Clear(); int superid = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID; IList <Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + superid.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString() + " AND ID NOT IN (SELECT OrganizeCity FROM MCS_CM.dbo.CM_PropertyInOrganizeCity WHERE Client=" + bll.Model.ID.ToString() + ")"); if (lists.Count > 0) { foreach (Addr_OrganizeCity city in lists) { ddl_PropertyInOrganizeCity.Items.Add(new ListItem("(" + city.Code + ")" + city.Name, city.ID.ToString())); } } ddl_PropertyInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0")); gv_PropertyInOrganizeCity.BindGrid <Addr_OrganizeCity>(bll.ClientInOrganizeCity_GetOrganizeCitys()); } else { tr_PropertyInOrganizeCity.Visible = false; } #endregion #region 绑定电话列表 gv_Telephone.ConditionString = "Client=" + bll.Model.ID.ToString(); gv_Telephone.BindGrid(); #endregion #region 绑定合同列表 gv_List_Contract.BindGrid(CM_ContractBLL.GetModelList("Client=" + bll.Model.ID.ToString())); #endregion } }
protected void bt_Add_PropertyInOrganizeCity_Click(object sender, EventArgs e) { if (ddl_PropertyInOrganizeCity.SelectedValue != "0" && (int)ViewState["ClientID"] != 0) { CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]); if (bll.ClientInOrganizeCity_GetOrganizeCitys().FirstOrDefault(p => p.ID == int.Parse(ddl_PropertyInOrganizeCity.SelectedValue)) == null) { bll.ClientInOrganizeCity_Add(int.Parse(ddl_PropertyInOrganizeCity.SelectedValue)); BindGrid(); } else { MessageBox.Show(this, "请勿重复添加该区域!"); return; } } }
protected void bt_Add_PropertyInOrganizeCity_Click(object sender, EventArgs e) { if (ddl_PropertyInOrganizeCity.SelectedValue != "0" && (int)ViewState["ClientID"] != 0) { CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]); if (bll.ClientInOrganizeCity_GetOrganizeCitys().FirstOrDefault(p => p.ID == int.Parse(ddl_PropertyInOrganizeCity.SelectedValue)) == null) { bll.ClientInOrganizeCity_Add(int.Parse(ddl_PropertyInOrganizeCity.SelectedValue)); BindGrid(); } else { MessageBox.Show(this, "请勿重复添加该区域!"); return; } } }
private void BindGrid() { if (ViewState["ClientID"] != null) { CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]); #region 绑定住宿人员 gv_Staff.ConditionString = "MCS_CM.dbo.CM_StaffInProperty.Client = " + ViewState["ClientID"].ToString() + " AND Org_Staff.Dimission=1"; gv_Staff.BindGrid(); #endregion #region 绑定兼管片区 if (bll.Model.OrganizeCity > 1) { ddl_PropertyInOrganizeCity.Items.Clear(); int superid = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID; IList<Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + superid.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString() + " AND ID NOT IN (SELECT OrganizeCity FROM MCS_CM.dbo.CM_PropertyInOrganizeCity WHERE Client=" + bll.Model.ID.ToString() + ")"); if (lists.Count > 0) { foreach (Addr_OrganizeCity city in lists) { ddl_PropertyInOrganizeCity.Items.Add(new ListItem("(" + city.Code + ")" + city.Name, city.ID.ToString())); } } ddl_PropertyInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0")); gv_PropertyInOrganizeCity.BindGrid<Addr_OrganizeCity>(bll.ClientInOrganizeCity_GetOrganizeCitys()); } else { tr_PropertyInOrganizeCity.Visible = false; } #endregion #region 绑定电话列表 gv_Telephone.ConditionString = "Client=" + bll.Model.ID.ToString(); gv_Telephone.BindGrid(); #endregion #region 绑定合同列表 gv_List_Contract.BindGrid(CM_ContractBLL.GetModelList("Client=" + bll.Model.ID.ToString())); #endregion } }