/// <summary> /// 查询数据库中是否存在相同描述的地址,true 有,false 没有 /// </summary> /// <returns></returns> public CSException IsAllowed() { try { var db = new SAFEDB(); var res = (from x in db.TH_HAZALOCA where x.DEPT == this.DEPT && x.C_NAME == this.C_NAME && x.STATS != "04" select x).ToList(); if (res.Count() == 0) { try { var res1 = new ORG_JOBUNITRELATION_V().FindDeptById(this.DEPT); return(new CSException(false)); } catch { return(new CSException(true, "数据库中没有这个单位代号:" + this.DEPT)); } } else { var msgstr = string.Format("{0}、{1}的区域已经存在于数据库中", this.DEPT, this.C_NAME.ToString()); return(new CSException(true, msgstr)); } } catch (Exception ex) { return(new CSException(true, ex.Message)); } }
/// <summary> /// 填充下拉列表 /// </summary> protected void LoadDLData() { var db = new SAFEDB(); var neworg = new ORG_JOBUNITRELATION_V(); //var a = dbview.ORG_JOBUNITRELATION_V1.Select(x => x).ToList(); var corp1 = (from x in neworg.NITList group x by new { x.C_SECCODE } into gr1 select gr1).ToList(); List <DropListClass> DList1 = new List <DropListClass>(); DList1.Add(new DropListClass("", "")); foreach (var in_corp1 in corp1) { var code = in_corp1.First().C_SECCODE; var name = in_corp1.First().C_SECNAME; DList1.Add(new DropListClass(code, code + "_" + name)); } this.SECID_Select.DataTextField = "Name"; this.SECID_Select.DataValueField = "ID"; this.SECID_Select.DataSource = DList1; this.SECID_Select.DataBind(); }
protected void KSID_Select_SelectedIndexChanged(object sender, EventArgs e) { var ks_selected_code = this.KSID_Select.SelectedValue; var db = new SAFEDB(); var neworg = new ORG_JOBUNITRELATION_V(); var corp4 = (from x in neworg.NITList where x.C_KSCODE == ks_selected_code group x by new { x.C_UNITCODE } into gr1 select gr1).ToList(); List <DropListClass> DList1 = new List <DropListClass>(); DList1.Add(new DropListClass("", "")); foreach (var in_corp4 in corp4) { var code = in_corp4.First().C_UNITCODE; var name = in_corp4.First().C_UNITNAME; DList1.Add(new DropListClass(code, code + "_" + name)); } this.UNITID_Select.DataTextField = "Name"; this.UNITID_Select.DataValueField = "ID"; this.UNITID_Select.DataSource = DList1; this.UNITID_Select.DataBind(); this.SelectedDept.Text = this.KSID_Select.SelectedText; }