private DataTable GetDataTable() { try { string sex = ddl_sex.SelectedValue; string birth_start = input_birth_start.Value; string birth_end = input_birth_end.Value; DataTable dt = GetAllEducation(); DataTable dt_student = PeopleBusiness.GetAllData(sex, "", birth_start, birth_end); if (dt != null) { dt.Columns.Add("Count"); // 总人数 dt.Columns.Add("Percent"); //百分比 int itemCount = dt.Rows.Count; //总项数 int totals = dt_student.Rows.Count; //总人数 foreach (DataRow dr in dt.Rows) { int count = dt_student.Select("ComeReason = '" + dr["ItemValue"] + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(count * 1.0 / totals, 4); dr["Percent"] = percent * 100 + "%"; dr["Count"] = count.ToString(); } DataRow dr_total = dt.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt.Rows.Add(dr_total); return(dt); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } }
public async Task <Execute <TicketEntity> > SignUpAsync(SignUpEntity signUp) { var result = new Execute <TicketEntity>(); if (!await ValidateSignUp.IsSatisfiedByAsync(signUp, result)) { return(result); } var(person, user, provider) = await CastNewUser(signUp); using (var db = new Context.XCommonDbContext()) { using (var transaction = await db.Database.BeginTransactionAsync()) { result.AddMessage(await PeopleBusiness.SaveAsync(person, db)); result.AddMessage(await UsersBusiness.SaveAsync(user, db)); result.AddMessage(await UsersProvidersBusiness.SaveAsync(provider, db)); if (!result.HasErro) { transaction.Commit(); } } } if (!result.HasErro) { result.Entity = new TicketEntity { Culture = person.Culture, Key = person.IdPerson, Name = person.Name, Roles = await GetUserRolesAsync(user) }; } return(result); }
private void Bind_statistic() { try { string comereason = ddl_ComeReason.SelectedValue; string birth_start = input_birth_start.Value; string birth_end = input_birth_end.Value; string label = ""; if (!birth_start.IsNullOrEmpty()) { label += "【出生年份>=" + birth_start + "年】"; } if (!birth_end.IsNullOrEmpty()) { label += "【出生年份<=" + birth_end + "年】"; } if (!comereason.Equals("99")) { label += "【" + ddl_ComeReason.SelectedItem.Text + "】"; } if (label == "") { label = "【全体】"; } label += "教职工性别统计"; label_head.Text = label; DataTable dt = PeopleBusiness.GetStatisticBySex("", comereason, birth_start, birth_end); if (dt != null) { if (dt.Rows.Count == 1) { if (dt.Rows[0]["Column"].Equals("True")) { DataRow dr = dt.NewRow(); dr["Column"] = "False"; dr["Count"] = 0; dt.Rows.InsertAt(dr, 0); } else { DataRow dr1 = dt.NewRow(); dr1["Column"] = "True"; dr1["Count"] = 0; dt.Rows.Add(dr1); } } else if (dt.Rows.Count == 0) { DataRow dr = dt.NewRow(); dr["Column"] = "False"; dr["Count"] = 0; dt.Rows.Add(dr); DataRow dr1 = dt.NewRow(); dr1["Column"] = "True"; dr1["Count"] = 0; dt.Rows.Add(dr1); } dt.Columns["Column"].ColumnName = "Sex"; dt.Columns.Add("ItemName"); //item名称 dt.Columns.Add("Percent"); //百分比 int itemCount = dt.Rows.Count; //总项数 int totals = 0; //总人数 foreach (DataRow dr in dt.Rows) { totals += Convert.ToInt32(dr["Count"].ToString()); } foreach (DataRow dr in dt.Rows) { dr["ItemName"] = dr["Sex"].ToString().Equals("True") ? "女" : "男"; double percent = totals == 0 ? 0.0000 : Math.Round(Convert.ToDouble(dr["Count"].ToString()) / totals, 4); dr["Percent"] = percent * 100 + "%"; if (PercentString.Equals("")) { PercentString = "['" + dr["ItemName"] + "'," + percent + "]"; } else { PercentString += ",['" + dr["ItemName"] + "'," + percent + "]"; } } DataRow dr_total = dt.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt.Rows.Add(dr_total); gv_result.DataSource = dt; gv_result.DataBind(); Label_Result.Text = itemCount.ToString(); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } }
private DataTable GetDataTable() { try { string comereason = ddl_ComeReason.SelectedValue; string birth_start = input_birth_start.Value; string birth_end = input_birth_end.Value; DataTable dt = PeopleBusiness.GetStatisticBySex("", comereason, birth_start, birth_end); if (dt != null) { if (dt.Rows.Count == 1) { if (dt.Rows[0]["Column"].Equals("True")) { DataRow dr = dt.NewRow(); dr["Column"] = "False"; dr["Count"] = 0; dt.Rows.InsertAt(dr, 0); } else { DataRow dr1 = dt.NewRow(); dr1["Column"] = "True"; dr1["Count"] = 0; dt.Rows.Add(dr1); } } else if (dt.Rows.Count == 0) { DataRow dr = dt.NewRow(); dr["Column"] = "False"; dr["Count"] = 0; dt.Rows.Add(dr); DataRow dr1 = dt.NewRow(); dr1["Column"] = "True"; dr1["Count"] = 0; dt.Rows.Add(dr1); } dt.Columns["Column"].ColumnName = "Sex"; dt.Columns.Add("ItemName"); //item名称 dt.Columns.Add("Percent"); //百分比 int itemCount = dt.Rows.Count; //总项数 int totals = 0; //总人数 foreach (DataRow dr in dt.Rows) { totals += Convert.ToInt32(dr["Count"].ToString()); } foreach (DataRow dr in dt.Rows) { dr["ItemName"] = dr["Sex"].ToString().Equals("True") ? "女" : "男"; double percent = totals == 0 ? 0.0000 : Math.Round(Convert.ToDouble(dr["Count"].ToString()) / totals, 4); dr["Percent"] = percent * 100 + "%"; } DataRow dr_total = dt.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt.Rows.Add(dr_total); return(dt); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } }
public virtual async Task <Execute <TicketEntity> > SignInAsync(SignInEntity signIn) { var result = new Execute <TicketEntity>(); if (!await ValidateSignIn.IsSatisfiedByAsync(signIn, result)) { return(result); } var person = await PeopleBusiness.GetFirstByFilterAsync(new PeopleFilter { Email = signIn.User }); if (person == null) { result.AddMessage(ExecuteMessageType.Error, Resources.Authentication.InvalidUserPassword); return(result); } var user = await UsersBusiness.GetByKeyAsync(person.IdPerson); if (user == null) { result.AddMessage(ExecuteMessageType.Error, Resources.Authentication.InvalidUserPassword); return(result); } if (signIn.Provider == ProviderType.Local) { if (!await VerifyPasswordHashAsync(user, signIn.Password)) { result.AddMessage(ExecuteMessageType.Error, Resources.Authentication.InvalidUserPassword); return(result); } result.Entity = new TicketEntity { Culture = person.Culture, Key = person.IdPerson, Name = person.Name, Roles = await GetUserRolesAsync(user) }; await SetTicketCustomValuesAsync(result.Entity); return(result); } var provider = await UsersProvidersBusiness.GetFirstByFilterAsync(new UsersProvidersFilter { IdUser = person.IdPerson, Provider = signIn.Provider }); if (provider == null) { result.AddMessage(ExecuteMessageType.Error, Resources.Authentication.InvalidUserPassword); return(result); } result.Entity = new TicketEntity { Culture = person.Culture, Key = person.IdPerson, Name = person.Name, Roles = await GetUserRolesAsync(user) }; await SetTicketCustomValuesAsync(result.Entity); return(result); }
public PeopleController(TechTestContext context) { peopleBusiness = new PeopleBusiness(context); }
private DataTable GetDataTable() { try { string sex = ddl_sex.SelectedValue; string comereason = ddl_ComeReason.SelectedValue; DataTable dt_people = PeopleBusiness.GetAllData(sex, comereason, "", ""); int thisYear = DateTime.Now.Year; if (dt_people != null) { DataTable dt_grid = new DataTable(); dt_grid.Columns.Add("ItemName"); //item名称 dt_grid.Columns.Add("Count"); //item 人数 dt_grid.Columns.Add("Percent"); //百分比 int itemCount = 8; //总项数 20岁及以下、21-25岁、26-30岁、31-35岁、36-40岁、40-45岁、46-50岁、50岁以上 int totals = dt_people.Rows.Count; //总人数 if (true) { DataRow dr = dt_grid.NewRow();//grid 行数据 dr["ItemName"] = "20岁及以下"; int count = dt_people.Select("Birthday >= '" + new DateTime(thisYear - 20, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "21-25岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 20, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 25, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "26-30岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 25, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 30, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "31-35岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 30, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 35, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "36-40岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 35, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 40, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "41-45岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 40, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 45, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "46-50岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 45, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 50, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "50岁以上"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 50, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); } DataRow dr_total = dt_grid.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt_grid.Rows.Add(dr_total); return(dt_grid); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); return(new DataTable()); } }
private void Bind_statistic() { try { string sex = ddl_sex.SelectedValue; string comereason = ddl_ComeReason.SelectedValue; string label = ""; if (!sex.Equals("99")) { label += "【" + ddl_sex.SelectedItem.Text + "性】"; } if (!comereason.Equals("99")) { label += "【" + ddl_ComeReason.SelectedItem.Text + "】"; } if (label == "") { label = "【全体】"; } label += "教职工年龄统计"; label_head.Text = label; DataTable dt_people = PeopleBusiness.GetAllData(sex, comereason, "", ""); int thisYear = DateTime.Now.Year; if (dt_people != null) { DataTable dt_grid = new DataTable(); dt_grid.Columns.Add("ItemName"); //item名称 dt_grid.Columns.Add("Count"); //item 人数 dt_grid.Columns.Add("Percent"); //百分比 int itemCount = 8; //总项数 20岁及以下、21-25岁、26-30岁、31-35岁、36-40岁、40-45岁、46-50岁、50岁以上 int totals = dt_people.Rows.Count; //总人数 StringBuilder sb_pic_x = new StringBuilder(); //sb_pic_x.Append("["); StringBuilder sb_pic_sum = new StringBuilder(); //sb_pic_sum.Append("{name: '总人数',data: ["); StringBuilder sb_pic_percent = new StringBuilder(); //sb_pic_percent.Append("{name: '所占比例',data: ["); if (true) { DataRow dr = dt_grid.NewRow();//grid 行数据 dr["ItemName"] = "20岁及以下"; int count = dt_people.Select("Birthday >= '" + new DateTime(thisYear - 20, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "21-25岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 20, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 25, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "26-30岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 25, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 30, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "31-35岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 30, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 35, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "36-40岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 35, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 40, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "41-45岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 40, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 45, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "46-50岁"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 45, 1, 1).ToString() + "' and Birthday >= '" + new DateTime(thisYear - 50, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } if (true) { DataRow dr = dt_grid.NewRow(); dr["ItemName"] = "50岁以上"; int count = dt_people.Select("Birthday < '" + new DateTime(thisYear - 50, 1, 1).ToString() + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(1.0 * count / totals, 4); dr["Count"] = count; dr["Percent"] = percent * 100 + "%"; dt_grid.Rows.Add(dr); if (sb_pic_x.Length == 0)//柱状图 横坐标 { sb_pic_x.Append("'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append(count); sb_pic_percent.Append(percent); } else { sb_pic_x.Append(",'" + dr["ItemName"].ToString() + "'"); sb_pic_sum.Append("," + count); sb_pic_percent.Append("," + percent); } } DataRow dr_total = dt_grid.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt_grid.Rows.Add(dr_total); gv_result.DataSource = dt_grid; gv_result.DataBind(); Label_Result.Text = itemCount.ToString(); xAxis = sb_pic_x.ToString(); Data_Sum = "{name: '总人数',data: [" + sb_pic_sum + "]}"; Data_Percent = "{name: '所占比例',data: [" + sb_pic_sum + "]}"; } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } }
private void Bind_statistic() { try { string sex = ddl_sex.SelectedValue; string birth_start = input_birth_start.Value; string birth_end = input_birth_end.Value; string label = ""; if (!birth_start.IsNullOrEmpty()) { label += "【出生年份>=" + birth_start + "年】"; } if (!birth_end.IsNullOrEmpty()) { label += "【出生年份<=" + birth_end + "年】"; } if (!sex.Equals("99")) { label += "【" + ddl_sex.SelectedItem.Text + "性】"; } if (label == "") { label = "【全体】"; } label += "教职工担任职务统计"; label_head.Text = label; DataTable dt = GetAllEducation(); DataTable dt_student = PeopleBusiness.GetAllData(sex, "", birth_start, birth_end); if (dt != null) { dt.Columns.Add("Count"); // 总人数 dt.Columns.Add("Percent"); //百分比 int itemCount = dt.Rows.Count; //总项数 int totals = dt_student.Rows.Count; //总人数 foreach (DataRow dr in dt.Rows) { int count = dt_student.Select("ComeReason = '" + dr["ItemValue"] + "'").Length; double percent = totals == 0 ? 0.0000 : Math.Round(count * 1.0 / totals, 4); dr["Percent"] = percent * 100 + "%"; dr["Count"] = count.ToString(); if (PercentString.Equals("")) { PercentString = "['" + dr["ItemName"] + "'," + percent + "]"; } else { PercentString += ",['" + dr["ItemName"] + "'," + percent + "]"; } } DataRow dr_total = dt.NewRow();//添加一条 总计 dr_total["ItemName"] = "总计"; dr_total["Count"] = totals; dr_total["Percent"] = totals == 0 ? "0.00%" : "100%"; dt.Rows.Add(dr_total); gv_result.DataSource = dt; gv_result.DataBind(); Label_Result.Text = itemCount.ToString(); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "alter", "layer.alert('数据加载错误!')", true); } }
protected void Button3_Click(object sender, EventArgs e) { try { //新增时判重,通过姓名,证件类型,证件号码进行唯一性判别别。 if (isNew == 1 && People.FindOne(CK.K["Name"] == tb_AssociationName.Text && CK.K["IdentityNo"] == tb_RegisteredFund.Text && CK.K["IsDelete"] == false) != null) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('此人信息已存在,请勿重复添加!')", true); return; } string name = tb_AssociationName.Text; bool sex = !radio_1.SelectedValue.Equals("1"); DateTime arriveDate = new DateTime(1900, 1, 2); try { arriveDate = Text1.Value.Equals("") ? arriveDate : Convert.ToDateTime(Text1.Value); } catch (Exception ex) { text(ex.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('时间输入格式不规范,请重新输入!')", true); return; } DateTime birthday = new DateTime(1900, 1, 2); try { birthday = input_RegisterDate.Value.Equals("") ? birthday : Convert.ToDateTime(input_RegisterDate.Value); } catch (Exception ex) { text(ex.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('时间输入格式不规范,请重新输入!')", true); return; } String identityNo = tb_RegisteredFund.Text; String phoneNo = tb_ContactName.Text; DateTime validityOfTW = new DateTime(1900, 1, 2); String address = TextBox6.Text; String tempApplication = TextBox7.Text; int comeReason = int.Parse(ddl.SelectedValue); String tip = TextBox3.Text; if (isNew == 0) //修改 { PeopleBusiness.UpdatePeople(id, name, sex, arriveDate, birthday, identityNo, phoneNo, address, tempApplication, comeReason, tip); LogInfoBusiness.AddLogInfo(Convert.ToInt32(log_userid), DateTime.Now, Convert.ToInt32(log_usertype), log_username, 4, "教职工信息", log_ip, log_account);//修改添加日志 操作类型->4 } else { string result = PeopleBusiness.AddPeopleForNew(id, name, sex, arriveDate, birthday, identityNo, phoneNo, address, tempApplication, comeReason, tip); LogInfoBusiness.AddLogInfo(Convert.ToInt32(log_userid), DateTime.Now, Convert.ToInt32(log_usertype), log_username, 2, "教职工信息", log_ip, log_account);//新增添加日志 操作类型->2 BusinessBusiness.AddBusinessNull(id); AgedBusiness.AddAgedNull(id); RelativeOfPeopleBusiness.AddRelativeNull(id); StudyBusiness.AddStudyNull(id); VisitBusiness.AddVisitNull(id); WorkBusiness.AddWorkNull(id); } Response.Redirect("./CheckAffairList_cztb.aspx"); } catch (Exception ex) { //Page.RegisterStartupScript("alert", "<script>alert('数据加载失败!')</script>"); Page.ClientScript.RegisterStartupScript(this.GetType(), "alter", "alert('数据加载错误!')", true); text(ex.ToString()); } }