protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // hide menu U_RolesBU role1 = new U_RolesBU(); //财务开票权限设置 if (role1.isRole("会计") == false && role1.isRole("出纳") == false) { this.ZCCWKP.Visible = false; this.ZCBCWKP.Visible = false; } //单据审核权限设置 if (role1.isRole("会计") == false) { this.DJSH.Visible = false; } role1.Close(); this.SetMenu(); } }
public static bool IsRole(string RoleName) { U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole(RoleName); role1.Close(); return(check1); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole("系统管理员"); bool check2 = role1.isRole("资讯管理员"); role1.Close(); if (check1 || check2) { this.ZX_menu1.Visible = true; this.ZX_menu0.Visible = true; } else { this.ZX_menu1.Visible = false; this.ZX_menu0.Visible = false; } } }
//设置当前用户是否有角色的权限,没有则转错误页 public static void SetAccess(string curuser, string RoleName) { U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole(RoleName); role1.Close(); if (check1 == false) { System.Web.HttpContext.Current.Response.Redirect("~/Error.aspx?info=NoAccess", true); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); String[] arr1 = new String[] { "系统管理员", "公司领导", "资产评审员" }; bool isAllSee = role1.isRole(arr1); this.IsAllSeeMember = isAllSee; this.time2.Text = DateTime.Parse((DateTime.Today.Year + 1) + "-1-1").AddDays(-1).ToString("yyyy-MM-dd"); this.time1.Text = DateTime.Today.Year + "-1-1"; //isAllSee = false; if (isAllSee == false) { // this.Row1.Visible = false; // this.Row2.Visible = true; } else { // this.Row1.Visible = true; // this.Row2.Visible = false; } //设置人员1和人员2 /* * this.SetMyData(); * List<String> list1 = JSJ.CJZC.Business.Comm.GetMyPersonList(Page.User.Identity.Name); * if (list1.Count > 0) * { * this.zeren1.DataSource = list1; * this.zeren1.DataBind(); * String temp1 = String.Empty; * foreach (String m in list1) * { * if (temp1 == String.Empty) * { * temp1 = m; * } * else * { * temp1 = temp1 + "," + m; * } * } * this.AllSelectPerson = temp1; * }*/ } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool user = role1.isRole("档案管理员"); role1.Close(); if (user == false) { for (int i = 1; i <= 2; i++) { this.AJM1.Parent.FindControl("DAG" + i).Visible = false; } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CW_PayBU pay1 = new CW_PayBU(); Hashtable ht = pay1.GetObjectByID(Request.QueryString["id"]); pay1.Close(); for (int i = 0; i < arr1.Length; i++) { Util.SetControlValue(this.bill.Parent.FindControl(arr1[i]), ht[arr1[i]]); } if (this.billtime.Text != "" && this.billtime.Text != null) { this.billtime.Text = DateTime.Parse(this.billtime.Text).ToString("yyyy-M-d"); } for (int j = 0; j < arr2.Length; j++) { Label lab1 = this.bill.Parent.FindControl(arr2[j]) as Label; if (lab1 != null) { lab1.Text = Comm.GetNumberFormat(lab1.Text); } } if (ht["checktime"] != DBNull.Value) { this.Button1.Visible = false; this.Button2.Attributes["onclick"] = "history.go(-1);return false;"; } else { this.Button2.Attributes["onclick"] = "top.location.href='CheckShouKuanList.aspx';return false;"; } //会计和出纳和修改单据的信息 U_RolesBU role1 = new U_RolesBU(); bool caiwu = role1.isRole(new string[] { "会计", "出纳" }); role1.Close(); if (caiwu == false) { this.Button3.Visible = false; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool isLeader = role1.isRole(new String[] { "公司领导", "综合管理", "评审部角色" }); role1.Close(); if (isLeader) { Response.Redirect("~/ZcMng1/ZongHeSearch.aspx", true); } else { this.BindData(null); //设置时效警告、邮件、最新信息的提示数据 U_ZCTimeBU time1 = new U_ZCTimeBU(); DataSet ds1 = time1.GetMyTimeList(User.Identity.Name, null, 1); this.MyTimeCount.Value = ds1.Tables[0].Rows.Count + ""; time1.Close(); ZX_EmailBu email1 = new ZX_EmailBu(); this.MyEmail.Value = email1.GetNewMailCount() + ""; email1.Close(); ZX_InfoBU info1 = new ZX_InfoBU(); this.MyInfo.Value = info1.GetNewInfoCount() + ""; info1.Close(); if ((this.MyTimeCount.Value != "0" || this.MyEmail.Value != "0" || this.MyInfo.Value != "0") && Session["noReminder_" + User.Identity.Name] == null && Request.Cookies["noReminder_" + User.Identity.Name] == null) { string js = "StartReminder();"; if (!Page.ClientScript.IsStartupScriptRegistered("StartJS")) { Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "StartJS", js, true); } } } } this.AdvanceSearch1.SetDepartRow(false); this.AdvanceSearch1.OnMySearchClick += new EventHandler(AdvanceSearch1_OnMySearchClick); this.SearchControl1.SearchEvent += new EventHandler(SearchControl1_SearchEvent); }
//绑定审批的数据 protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e) { U_RolesBU role1 = new U_RolesBU(); this.IsLeaderMiShu = role1.isRole("领导秘书"); role1.Close(); DataRowView dv = e.Item.DataItem as DataRowView; if (dv != null) { DataRow dr = dv.Row; String zeren1 = dr["zeren"].ToString().Trim(); String time1 = dr["time1"].ToString().Trim(); LinkButton link1 = e.Item.FindControl("budPy") as LinkButton; if (time1 != String.Empty) { link1.Visible = false; //表示资产已经批阅过 } else { if (zeren1 == Page.User.Identity.Name || this.IsLeaderMiShu) { link1.Visible = true; //当前批阅人和登陆用户不一致 } else { link1.Visible = false; } } if (dr["zx"].ToString().Trim() == "1") { Label lab1 = e.Item.FindControl("zeren") as Label; if (lab1 != null) { lab1.Text = "<font color=red>★</font>" + dr["zeren"].ToString(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int pos1 = Request.Url.AbsoluteUri.LastIndexOf("/"); String url1 = "http://" + FrameLib.ServerHost; if (FrameLib.ServerPort != "80") { url1 = url1 + ":" + FrameLib.ServerPort; } this.wordUrl.Value = url1 + "/Common/AttachFiles/"; if (String.IsNullOrEmpty(Request.QueryString["doc"]) == false) { this.wordUrl.Value = this.wordUrl.Value + Request.QueryString["doc"]; String ext = Path.GetExtension(Request.QueryString["doc"]).Replace(".", ""); this.wordExt.Value = ext; this.saveDoc.Value = url1 + "/saveWordDoc.aspx"; this.filename.Value = Request.QueryString["doc"]; } else { this.wordUrl.Value = ""; } U_RolesBU role1 = new U_RolesBU(); bool user = role1.isRole("档案管理员"); role1.Close(); if (user) { this.isAdmin.Value = "1"; } else { this.isAdmin.Value = ""; } this.but2.Visible = user; this.Row1.Visible = user; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole("资产管理员"); role1.Close(); if (check1 == false) { Response.Redirect("~/Error.aspx?info=NoAccess", true); } else { this.BindData(null); } this.AdvanceSearch1.SetDepartRow(false); } this.AdvanceSearch1.OnMySearchClick += new EventHandler(AdvanceSearch1_OnMySearchClick); }
/// <summary> /// 设置部门和人员 /// </summary> private void SetDepartAndPerson() { string depart1 = this.depart.SelectedValue; Comm.SetZeRen(this.zeren, depart1, "所有责任人"); this.zeren.SelectedValue = ""; //判断是否为公司领导 U_RolesBU role1 = new U_RolesBU(); bool isLeader = role1.isRole(new String[] { "公司领导", "综合管理", "评审部角色" }); role1.Close(); if (isLeader == false) { this.depart.Visible = false; this.zeren.Items.Clear(); ListItem list1 = new ListItem(Page.User.Identity.Name, Page.User.Identity.Name); this.zeren.Items.Add(list1); this.zeren.SelectedIndex = 0; } }
protected override void OnPreRenderComplete(EventArgs e) { U_RolesBU bu1 = new U_RolesBU(); bool flag1 = bu1.isRole("档案管理员"); bu1.Close(); foreach (GridViewRow row1 in this.GridView1.Rows) { LinkButton link1 = row1.FindControl("butDelete") as LinkButton; if (link1 != null) { link1.Enabled = flag1; link1.ToolTip = "提示:只有档案管理员才能进行删除操作"; } HyperLink hyper1 = row1.FindControl("hyper1") as HyperLink; if (hyper1 != null) { hyper1.Enabled = flag1; hyper1.ToolTip = "提示:只有档案管理员才能进行此操作"; } } base.OnPreRenderComplete(e); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole("系统管理员"); role1.Close(); if (check1 == false) { this.ZX_menu1.Visible = false; this.ZX_menu0.Visible = false; } //判断是否只为法律顾问角色 if (this.isOnlyLaw()) { this.ZX_menu2.Visible = false; } else { this.ZX_menu2.Visible = true; } } }
//调整系统菜单 private void SetMenu() { string currentuser = Page.User.Identity.Name; U_RolesBU role1 = new U_RolesBU(); if (!role1.isRole("系统管理员")) { this.SYS_Menu1.Visible = false; this.SYS_Menu2.Visible = false; } if (role1.isRole("公司领导") == false && role1.isRole("财务数据浏览") == false && role1.isRole("会计") == false && role1.isRole("出纳") == false) { this.CWZX1.Visible = false; this.CWZX2.Visible = false; } if (role1.isRole("公司领导") == false) { this.JCZC1.Visible = false; this.JCZC2.Visible = false; } role1.Close(); //设置法律顾问的权限 if (this.isOnlyLaw()) { this.tabInfo1.Visible = false; this.tabInfo2.Visible = true; } else { this.tabInfo1.Visible = true; this.tabInfo2.Visible = false; } }
/// <summary> /// 设置按钮的出现或隐藏 /// </summary> /// <param name="index1"></param> private void SelectControl(int index1, String status1) { for (int i = 1; i <= 6; i++) { Control con1 = this.MenuKind1.Parent.FindControl("info" + i) as Control; if (con1 != null) { if (i != index1) { con1.Visible = false; } else { con1.Visible = true; } } } ///////////////////////////////////////////////////////////// U_RolesBU bu1 = new U_RolesBU(); bool check1 = bu1.isRole("领导秘书"); bu1.Close(); bool check0 = false; if (User.Identity.Name == ViewState["zeren"].ToString()) { check0 = true; } //根据条件设置不同的按钮出现 switch (index1) { case 1: case 2: case 3: case 4: case 6: if (check0 || (check1 && (index1 == 3 || index1 == 4))) { this.span1.Visible = true; this.span3.Visible = true; } else { this.span1.Visible = false; this.span3.Visible = false; } this.span2.Visible = false; this.span4.Visible = false; this.span5.Visible = false; break; case 5: this.span1.Visible = false; this.span3.Visible = false; this.span4.Visible = false; if (check0 || check1) { if (status1 == "04") { this.span2.Visible = true; this.span5.Visible = false; } else { if (check1) { this.span5.Visible = true; } else { this.span5.Visible = false; } this.span2.Visible = false; } } else { this.span2.Visible = false; this.span5.Visible = false; } break; } //调整提交的按钮功能(金寿吉 2015年1月27日) if (status1 == "14" || status1 == "16") { this.span1.Visible = false; } }
/// <summary> /// 设置页面上控件的值 /// </summary> /// <param name="ht"></param> public void SetControlData(Hashtable ht) { foreach (String m in this.contrArrName) { if (ht.ContainsKey(m)) { Control con1 = this.FindControl(m) as Control; if (con1 != null) { Util.SetControlValue(con1, ht[m]); //设置控件的值 } Control con2 = this.FindControl(m + "_1") as Control; if (con2 != null) { Util.SetControlValue(con2, ht[m]); //设置控件的值 } } } U_RolesBU bu1 = new U_RolesBU(); bool role1 = bu1.isRole("领导秘书"); bu1.Close(); if (ht["zeren"].ToString() == Page.User.Identity.Name || role1) { this.Row1.Visible = true; this.Row2.Visible = true; this.Row3.Visible = false; this.Row4.Visible = false; } else { this.Row1.Visible = false; this.Row2.Visible = false; this.Row3.Visible = true; this.Row4.Visible = true; } //设置意见信息 String weiyuan1 = ""; String weiyuan2 = ""; String weiyuan3 = ""; String zhuxi = ""; String zhuxiTime = ""; String zhuxiyijian = ""; JSJ.CJZC.Business.Comm.GetWeiYuan1(ht["id"].ToString(), "15", out weiyuan1, out weiyuan2, out weiyuan3, out zhuxi, out zhuxiTime, out zhuxiyijian); this.ztwy2.Text = weiyuan1; this.fdwy2.Text = weiyuan2; this.shren2.Text = zhuxi; this.shsj2.Text = zhuxiTime; this.shyj2.Text = zhuxiyijian; this.wy3.Text = weiyuan3; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // hide menu U_RolesBU role1 = new U_RolesBU(); bool check1 = role1.isRole("系统管理员"); //系统管理员权限部分 if (check1 == false) { this.ZC_SYS1.Visible = false; this.ZC_SYS2.Visible = false; this.ZC_SYS3.Visible = false; this.ZC_SYS4.Visible = false; this.ZC_SYS5.Visible = false; this.ZC_SYS6.Visible = false; this.ZC_SYS7.Visible = false; } //公司领导权限部分 check1 = role1.isRole(new String[] { "公司领导", "综合管理" }); if (check1 == false) { this.ZC_LEADER1.Visible = false; this.ZC_LEADER2.Visible = false; this.ZC_LEADER3.Visible = false; } //部门领导权限部分 check1 = role1.isRole("资产部门领导"); if (check1 == false) { this.ZC_Depart1.Visible = false; this.ZC_Depart2.Visible = false; //this.ZC_Depart3.Visible = false; } check1 = role1.isRole("资产清收人员"); if (check1) { this.ZC_GR1.Visible = true; this.ZC_GR1_1.Visible = true; this.ZC_GR2.Visible = true; this.ZC_GR2_1.Visible = true; this.ZC_GR3.Visible = true; this.ZC_GR4.Visible = true; this.ZC_GR5.Visible = true; this.ZC_SP1.Visible = false; this.ZC_SP2.Visible = false; this.ZC_SP3.Visible = false; this.ZC_SP4.Visible = false; } else { this.ZC_GR1.Visible = false; this.ZC_GR1_1.Visible = false; this.ZC_GR2.Visible = false; this.ZC_GR2_1.Visible = false; this.ZC_GR3.Visible = false; this.ZC_GR4.Visible = false; this.ZC_GR5.Visible = false; //this.ZC_SP1.Visible = true; //this.ZC_SP2.Visible = true; //this.ZC_SP3.Visible = true; //this.ZC_SP4.Visible = true; } //增加法律顾问专栏 check1 = role1.isRole("法律顾问"); if (check1) { this.ZC_LAW1.Visible = true; this.ZC_LAW2.Visible = true; } else { this.ZC_LAW1.Visible = false; this.ZC_LAW2.Visible = false; } role1.Close(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { //判断用户是否有部门资产 if (JSJ.CJZC.Business.Comm.HaveBuZC() == false) { this.AddRow.Visible = false; this.SPList1.Visible = false; this.SPList2.Visible = false; if (Request.RawUrl.ToLower().IndexOf("fangan1.aspx") > 0 || Request.RawUrl.ToLower().IndexOf("fangan2.aspx") > 0) { Response.Redirect("fangan3.aspx", true); } } else { //表示用户没有直接负责的资产 if (JSJ.CJZC.Business.Comm.HaveZC() == false) { this.AddRow.Visible = false; this.SPList1.Visible = false; if (Request.RawUrl.ToLower().IndexOf("fangan1.aspx") > 0) { Response.Redirect("fangan2.aspx", true); } } } U_RolesBU role1 = new U_RolesBU(); bool isAllCanSee = role1.isRole(new string[] { "公司领导", "综合管理", "会计", "出纳", "领导秘书" }); if (isAllCanSee == false) { this.SPList3.Visible = false; this.Tr3.Visible = false; this.Tr5.Visible = false; } bool isLeaderMiShu = role1.isRole("领导秘书"); if (isLeaderMiShu == false) { this.LeaderMiShu.Visible = false; } if (this.SPList1.Visible == false && this.SPList2.Visible == false && this.SPList3.Visible == false) { this.HR1.Visible = false; if (Request.RawUrl.ToLower().IndexOf("fangan3.aspx") > 0) { Response.Redirect("fangan4.aspx", true); } } role1.Close(); //增加法律顾问的权限设置 if (LawBU.isOnlyLaw()) { this.tabNavigator.Visible = false; } } }
private void SetPageInfo() { CommTable comm1 = new CommTable(); comm1.TabName = "UserLogin"; //U_RolesBU role1 = new U_RolesBU(); List <SearchField> list1 = new List <SearchField>(); list1.Add(new SearchField("UserName", User.Identity.Name)); DataSet ds = comm1.SearchData("loginCount", list1); if (ds.Tables[0].Rows.Count > 0) { this.labLogin.Text = ds.Tables[0].Rows[0]["loginCount"].ToString(); } else { this.labLogin.Text = "1"; } //设置未读邮件 comm1.TabName = "ZX_Email"; list1.Clear(); list1.Add(new SearchField("to1", User.Identity.Name)); list1.Add(new SearchField("readcount", "", SearchOperator.空值)); ds.Clear(); ds = comm1.SearchData("count(*)", list1); this.HypEmail.Text = ds.Tables[0].Rows[0][0].ToString(); //设置未读消息 comm1.TabName = "ZX_QuickTalk"; list1.Clear(); list1.Add(new SearchField("tmen", User.Identity.Name)); list1.Add(new SearchField("isRead", "0", SearchFieldType.数值型)); ds.Clear(); ds = comm1.SearchData("count(*)", list1); this.HypMessage.Text = ds.Tables[0].Rows[0][0].ToString(); //资产批阅申请 comm1.TabName = "U_ZCSP"; list1.Clear(); list1.Add(new SearchField("zeren", User.Identity.Name)); list1.Add(new SearchField("time1", "", SearchOperator.空值)); ds.Clear(); ds = comm1.SearchData("distinct czid", list1); if (ds.Tables[0].Rows.Count > 0) { this.HyperZc.Text = ds.Tables[0].Rows.Count + ""; } //设置今天工作安排 comm1.TabName = "ZX_RCAP"; list1.Clear(); list1.Add(new SearchField("sname", User.Identity.Name)); list1.Add(new SearchField("year(plantime)", DateTime.Now.Year + "", SearchFieldType.数值型)); list1.Add(new SearchField("month(plantime)", DateTime.Now.Month + "", SearchFieldType.数值型)); list1.Add(new SearchField("day(plantime)", DateTime.Now.Day + "", SearchFieldType.数值型)); ds.Clear(); ds = comm1.SearchData("distinct id,subject", list1); if (ds.Tables[0].Rows.Count > 0) { this.HypToday.Text = ds.Tables[0].Rows[0]["subject"].ToString(); this.HypToday.NavigateUrl = "~/Info/RcanpaiDetails.aspx?id=" + ds.Tables[0].Rows[0]["id"].ToString(); } //计算本周的日程安排 ds.Clear(); list1.Clear(); list1.Add(new SearchField("sname", User.Identity.Name)); DateTime dt1 = DateTime.Now.Date; int day1 = (int)dt1.DayOfWeek; string begtime = dt1.AddDays(-day1).ToString("yyyy-MM-dd"); string endtime = dt1.AddDays(6 - day1).ToString("yyyy-MM-dd") + " 23:59:59"; list1.Add(new SearchField("plantime", begtime, SearchOperator.大于等于)); list1.Add(new SearchField("plantime", endtime, SearchOperator.小于等于)); DataSet ds1 = comm1.SearchData("*", list1, "plantime"); this.GridView1.DataSource = ds1; this.GridView1.DataBind(); //设置在线用户 Hashtable ht = (Hashtable)Application["OnLineUser"]; this.DataList1.DataSource = ht; this.DataList1.DataBind(); U_RolesBU role1 = new U_RolesBU(); //设置个人时效警告数据 string sql = @"select U_Zctime.* from U_Zctime inner join U_ZC On U_zctime.zcid=U_ZC.id and U_ZC.zeren='{0}' AND U_Zctime.time0 is not null and DateAdd(dd,-tellday,U_Zctime.time0)<getdate()"; sql = String.Format(sql, User.Identity.Name); ds.Clear(); ds = comm1.TableComm.SearchData(sql); if (ds.Tables[0].Rows.Count > 0) { this.HypTime1.Text = ds.Tables[0].Rows.Count + ""; } //设置部门时效的数据 bool check1 = role1.isRole("资产部门领导"); if (check1 == false) { this.BLeader.Visible = false; } else { sql = @"select U_Zctime.* from U_Zctime inner join U_ZC On U_zctime.zcid=U_ZC.id inner join U_UserName on U_zc.zeren=u_username.sname inner join U_depart on u_username.depart=U_depart.depart where ( U_UserName.sname='{0}' or U_Username.leader='{1}') AND U_Zctime.time0 is not null and DateAdd(dd,-tellday,U_Zctime.time0)<getdate()"; sql = String.Format(sql, User.Identity.Name, User.Identity.Name); ds.Clear(); ds = comm1.TableComm.SearchData(sql); if (ds.Tables[0].Rows.Count > 0) { this.HypTime2.Text = ds.Tables[0].Rows.Count + ""; } } comm1.Close(); }
/// <summary> /// 统计方案数据 /// </summary> /// <param name="time0"></param> /// <param name="time1"></param> /// <returns></returns> private DataSet GetTongJiData(String time0, String time1) { DataSet ds0 = new DataSet(); DataTable dt0 = new DataTable("Table0"); ds0.Tables.Add(dt0); dt0.Columns.Add("depart"); for (int i = 1; i <= 12; i++) { dt0.Columns.Add("num" + i); } List <SearchField> condition = new List <SearchField>(); if (time0.Trim() != String.Empty) { condition.Add(new SearchField("shijian1", time0, SearchOperator.大于等于)); } if (time1.Trim() != String.Empty) { condition.Add(new SearchField("shijian1", time1, SearchOperator.小于等于)); } //设置查询范围 U_RolesBU role1 = new U_RolesBU(); bool isAllCanSee = role1.isRole(new string[] { "公司领导", "评审部角色", "会计", "出纳", "领导秘书" }); role1.Close(); //1)公司领导、会计、出纳、领导秘书 可查询所有的项目 if (isAllCanSee == false) { //普通的用户只能查询自己负责(或下属负责的项目) List <SearchField> condition1 = new List <SearchField>(); U_UserNameBU user1 = new U_UserNameBU(); String userName1 = user1.GetSelfAndXiaShu(User.Identity.Name); user1.Close(); if (userName1 != String.Empty) { condition.Add(new SearchField("zeren", userName1, SearchOperator.集合)); } } //2)统计新数据 int[] sum1 = new int[12]; String fdepart = ""; CommTable comm1 = new CommTable(); comm1.TabName = "U_ZC2"; DataSet ds1 = comm1.SearchData("id,depart,status,spstatus,spkind", condition, "depart"); DataRow dr1 = null; foreach (DataRow dr in ds1.Tables[0].Rows) { if (dr["depart"].ToString().Trim() != fdepart) { if (dr1 != null) { ds0.Tables[0].Rows.Add(dr1); } //设置初值 dr1 = ds0.Tables[0].NewRow(); dr1["depart"] = dr["depart"]; fdepart = dr["depart"].ToString().Trim(); for (int i = 1; i <= 12; i++) { dr1["num" + i] = 0; } } //设置值 String spstatus = dr["spstatus"].ToString().Trim(); if (spstatus == "0") { dr1["num1"] = int.Parse(dr1["num1"].ToString()) + 1; sum1[0] += 1; } else if (spstatus == "1") { dr1["num2"] = int.Parse(dr1["num2"].ToString()) + 1; dr1["num4"] = int.Parse(dr1["num4"].ToString()) + 1; sum1[1] += 1; sum1[3] += 1; } else if (spstatus == "2") { dr1["num3"] = int.Parse(dr1["num3"].ToString()) + 1; dr1["num4"] = int.Parse(dr1["num4"].ToString()) + 1; sum1[2] += 1; sum1[3] += 1; } String status = dr["status"].ToString().Trim(); if (status == "21") { dr1["num5"] = int.Parse(dr1["num5"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[4] += 1; sum1[11] += 1; } else if (status == "22") { dr1["num6"] = int.Parse(dr1["num6"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[5] += 1; sum1[11] += 1; } else if (status == "23") { dr1["num7"] = int.Parse(dr1["num7"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[6] += 1; sum1[11] += 1; } else if (status == "24") { dr1["num8"] = int.Parse(dr1["num8"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[7] += 1; sum1[11] += 1; } else if (status == "25") { dr1["num9"] = int.Parse(dr1["num9"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[8] += 1; sum1[11] += 1; } else if (status == "26") { dr1["num10"] = int.Parse(dr1["num10"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[9] += 1; sum1[11] += 1; } else if (status == "27") { dr1["num11"] = int.Parse(dr1["num11"].ToString()) + 1; dr1["num12"] = int.Parse(dr1["num12"].ToString()) + 1; sum1[10] += 1; sum1[11] += 1; } else { ; } } if (dr1 != null) { ds0.Tables[0].Rows.Add(dr1); dr1 = ds0.Tables[0].NewRow(); dr1["depart"] = "合计"; for (int i = 1; i <= 12; i++) { dr1["num" + i] = sum1[i - 1]; } ds0.Tables[0].Rows.Add(dr1); } comm1.Close(); return(ds0); }