//添加信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.LearningEntity model = new Entity.LearningEntity(); model.Sauthor = UserName; model.Stitle = this.txtTitle.Text; model.Sdate = DateTime.Now; model.Spath = this.kindeditor.Value; model.Did = UserDepartmentId; int i = new Daiv_OA.BLL.LearningBLL().Add(model); if (i > 0) { Daiv_OA.BLL.UserBLL user = new Daiv_OA.BLL.UserBLL(); DataTable dt = new DataTable(); string aa = ""; if (UserPowerId <= 3) { dt = user.GetList("").Tables[0]; } else { dt = user.GetList("Did=" + UserDepartmentId).Tables[0]; } for (int j = 0; j < dt.Rows.Count; j++) { aa += dt.Rows[j]["Uid"].ToString() + ","; } Daiv_OA.BLL.OA_SysMessageIn.ADDsysMessage(2, "," + aa, "[新资料]" + txtTitle.Text, Daiv_OA.Utils.Strings.Left(Daiv_OA.Utils.Strings.delhtml(kindeditor.Value.ToString()), 53), "My_Learning_Show.aspx?id=" + i.ToString()); string addtype = "添加学习资料"; Addlog(addtype); aa = ""; } }
/// <summary> /// 登录 /// </summary> /// <param name="context"></param> /// <returns></returns> private ResponeDataEntity LoginIn(HttpContext context, JObject ob) { string uname = ob["uname"].ToString(); string pwd = ob["pwd"].ToString(); int iExpires = 0; logHelper.logInfo(" LoginIn params:uname:" + uname + " pwd:" + pwd); string uid = new Daiv_OA.BLL.UserBLL().Existslongin(uname, Daiv_OA.Utils.MD5.Lower32(pwd)); if (uid != "") { Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(int.Parse(uid)); new BLL.UserBLL().SetUserCookies(model, HttpContext.Current.Request.UserHostAddress, iExpires); HttpContext.Current.Session["UserName"] = uname; return(new ResponeDataEntity() { Status = 1, Msg = "登录成功!", Data = model }); } return(new ResponeDataEntity() { Status = 0, Msg = "登录失败!" }); }
//判断是否自动登录 void Autologin() { if (Daiv_OA.Utils.Cookie.GetValue("oa_user") != null) { if (Daiv_OA.Utils.Cookie.GetValue("oa_user", "ip") == Request.UserHostAddress) { Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(Convert.ToInt32(Daiv_OA.Utils.Cookie.GetValue("oa_user", "id"))); int pid = model.Pid; new BLL.UserBLL().UpdateTime(model.Uid); switch (pid) { case 1: Session["UserName"] = model.Uname; Response.Redirect("Index.aspx"); break; case 2: Session["UserName"] = model.Uname; Response.Redirect("Index.aspx"); break; case 3: Session["UserName"] = model.Uname; Response.Redirect("Index.aspx"); break; case 4: Session["UserName"] = model.Uname; Response.Redirect("Index.aspx"); break; } } } }
//添加 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { int PId = 4; Entity.UserEntity userEntity = new Entity.UserEntity(); Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(PId); userEntity.Pid = PId; userEntity.Uname = this.txtUname.Text; userEntity.Position = this.txtPosition.Text; userEntity.Setting = powerEntity.Setting; userEntity.Did = Str2Int(this.ddlDid.SelectedValue, 0); userEntity.Upwd = Daiv_OA.Utils.MD5.Lower32(this.txtPwd.Text.Trim()); if (this.txtIpaddress.Text != "") { userEntity.Uipaddress = this.txtIpaddress.Text; } int i = new Daiv_OA.BLL.UserBLL().Add(userEntity); if (i > 0) { Addadminlog("添加用户"); } else { FinalMessage("相同的用户已经存在", "", 1); } }
//数据绑定 void Bind() { int uid = Str2Int(q("id"), 0); Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(uid); this.txtUname.Text = model.Uname; }
//更新 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.UserEntity model = new Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(Str2Int(q("id"), 0)); model.Upwd = Daiv_OA.Utils.MD5.Lower32(this.txtAgainpwd.Text.Trim()); new Daiv_OA.BLL.UserBLL().Update(model); Addadminlog("修改用户密码"); }
//绑定 void Bind() { Entity.UserEntity model = new Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); this.txtUname.Text = model.Uname; ViewState["pid"] = model.Pid.ToString(); this.txtUname.ReadOnly = true; }
//个人密码修改 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.UserEntity model = new Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); model.Upwd = Daiv_OA.Utils.MD5.Lower32(this.txtAgainpwd.Text.Trim()); new Daiv_OA.BLL.UserBLL().Update(model); FinalMessage("操作成功", "Password_Edit.aspx", 0); }
protected void dropuser() { Daiv_OA.BLL.UserBLL user = new Daiv_OA.BLL.UserBLL(); touser.DataSource = user.GetList("Did in(1,2,3)").Tables[0]; touser.DataTextField = "Uname"; touser.DataValueField = "Uname"; touser.DataBind(); }
//获取角色 string Getposi(int uid) { string sql = "select * from [OA_Power] where Pid = (select Pid FROM [OA_User] where uid ='" + uid + "')"; Entity.PowerEntity posi = new Entity.PowerEntity(); posi = new Daiv_OA.BLL.UserBLL().Getpomodel(sql); string pname = posi.PName; return(pname); }
//ddlUname绑定 void BindMyEmployeeInfo() { DataSet ds = new Daiv_OA.BLL.UserBLL().GetList(" pid=4" + wherestr2); DataTable dt = ds.Tables[0]; for (int i = 0; i < dt.Rows.Count; i++) { this.ddlUname.Items.Add(new ListItem(dt.Rows[i]["Uname"].ToString(), dt.Rows[i]["UId"].ToString())); } dt.Clear(); dt.Dispose(); ds.Clear(); ds.Dispose(); }
//更新 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.UserEntity model = new Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(Str2Int(q("id"), 0)); // model.Position = this.txtPosition.Text; model.Setting = "," + f("user_setting") + ","; model.Pid = Convert.ToInt32(DropDownList2.SelectedValue.ToString()); model.Did = Convert.ToInt32(DropDownList1.SelectedValue.ToString()); model.Uipaddress = this.txtIpaddress.Text; model.UClassID = Convert.ToInt32(this.ddlGid.SelectedItem.Value); model.ULongName = this.ULongName.Text; model.UClassName = this.ddlGid.SelectedItem.Text; model.Mphone = this.Mphone.Text; new Daiv_OA.BLL.UserBLL().Update(model); Addadminlog("修改用户权限"); }
private PagedDataSource pds() { string sql = "select [OA_User].uid,[OA_User].uname,[OA_User].upwd,[OA_User].PID,Position,IsNull((select DName from [OA_Department] where [OA_Department].Did=[OA_User].did),'管理部') as Dname,[OA_Power].pname FROM [OA_User] left join [OA_Power] on [OA_User].pid = [OA_Power].pid where [OA_User].uid <> 1 "; DataSet ds = new Daiv_OA.BLL.UserBLL().Getall(sql); //this.user_repeater.DataBind(); //this.user_repeater.DataSource = new Daiv_OA.BLL.UserBLL().Getall(sql); //this.user_repeater.DataBind(); PagedDataSource pds = new PagedDataSource(); pds.DataSource = ds.Tables[0].DefaultView; pds.AllowPaging = true; //允许分页 pds.PageSize = 4; //单页显示项数 pds.CurrentPageIndex = Convert.ToInt32(Request.QueryString["page"]); return(pds); }
/// <summary> /// 检查登录情况(用于自动登录) /// </summary> /// <param name="context"></param> /// <param name="ob"></param> /// <returns></returns> private ResponeDataEntity CheckLogin(HttpContext context, JObject ob) { if (Daiv_OA.Utils.Cookie.GetValue("oa_user") != null) { if (Daiv_OA.Utils.Cookie.GetValue("oa_user", "ip") == context.Request.UserHostAddress) { Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(Convert.ToInt32(Daiv_OA.Utils.Cookie.GetValue("oa_user", "id"))); return(new ResponeDataEntity() { Status = 1, Msg = "登录成功!", Data = model }); } } return(new ResponeDataEntity() { Status = 0, Msg = "未成功!", Data = null }); }
//checkboxlist的绑定 void ddlWorkerbind() { this.txtBegintime.Text = DateTime.Now.ToString(); Daiv_OA.BLL.UserBLL user = new Daiv_OA.BLL.UserBLL(); DataTable table = user.GetList(wherestr2).Tables[0]; for (int i = 0; i < table.Rows.Count; i++) { ListItem item = new ListItem(); item.Value = table.Rows[i]["Uid"].ToString(); DataSet ds = new Daiv_OA.BLL.TaskBLL().GetList(" uid = " + Convert.ToInt32(table.Rows[i]["Uid"].ToString()) + " and worktime > '" + Convert.ToDateTime(this.txtBegintime.Text) + "' and [Workprogress]in(2,5,6,7,8)"); if (ds.Tables[0].Rows.Count != 0) { item.Text = table.Rows[i]["Uname"].ToString() + "<font style=\"color:#FF0000\">(" + ds.Tables[0].Rows.Count + ")</font>"; } else { item.Text = table.Rows[i]["Uname"].ToString(); } ddlWorker.Items.Add(item); } }
void showdp() { Daiv_OA.BLL.COMDLL com = new Daiv_OA.BLL.COMDLL(); int uid = Convert.ToInt32(com.getsid("fid")); if (uid != -1) { int dpid = new Daiv_OA.BLL.UserBLL().GetEntity(uid).Did; DropDownList1.SelectedValue = dpid.ToString(); DropDownList1.Enabled = false; this.DropDownList2.DataSource = new Daiv_OA.BLL.UserBLL().GetList("Did=" + DropDownList1.SelectedValue.ToString()); this.DropDownList2.DataTextField = "Uname"; this.DropDownList2.DataValueField = "Uid"; this.DropDownList2.DataBind(); DropDownList2.SelectedValue = uid.ToString(); DropDownList2.Enabled = false; } else { DropDownList1.Enabled = true; DropDownList2.Enabled = true; } }
//添加 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.ParentMessageEntity parentMessageEntity = new Entity.ParentMessageEntity(); parentMessageEntity.Mtitle = this.Mtitle.Text; parentMessageEntity.Content = this.Content.Text; parentMessageEntity.ToUid = UserId; parentMessageEntity.FromUid = UserId; parentMessageEntity.Addtime = DateTime.Now; //获取用户实体 Entity.UserEntity userEntity = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); //获取学生信息 Entity.StudentEntity stuEntity = new Daiv_OA.BLL.StudentBLL().GetEntityByNumber(userEntity.Uname); if (stuEntity != null) { parentMessageEntity.Touser = stuEntity.Sname; } int i = new Daiv_OA.BLL.ParentMessageBLL().Add(parentMessageEntity); if (i > 0) { logHelper.logInfo("添加留言成功!"); FinalMessage("操作成功", "ParentMessage_List.aspx", 0); } }
//添加信息 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.PlacardEntity model = new Entity.PlacardEntity(); model.Pauthor = UserName; model.Ptitle = this.txtTitle.Text; model.Pdate = DateTime.Now; model.Ptext = this.kindeditor.Value; int i = new Daiv_OA.BLL.PlacardBLL().Add(model); if (i > 0) { Daiv_OA.BLL.UserBLL user = new Daiv_OA.BLL.UserBLL(); DataTable dt = user.GetList("").Tables[0]; string aa = ""; for (int j = 0; j < dt.Rows.Count; j++) { aa += dt.Rows[j]["Uid"].ToString() + ","; } Daiv_OA.BLL.OA_SysMessageIn.ADDsysMessage(1, "," + aa, "[新通知]" + txtTitle.Text, Daiv_OA.Utils.Strings.Left(Daiv_OA.Utils.Strings.delhtml(kindeditor.Value.ToString()), 53), "My_Placard_Show.aspx?id=" + i.ToString()); aa = ""; string addtype = "添加通知公告"; Addlog(addtype); } }
//添加 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { int PId = 1; Entity.UserEntity userEntity = new Entity.UserEntity(); Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(PId); userEntity.Pid = PId; userEntity.Uname = this.txtUname.Text; userEntity.Position = this.txtPosition.Text; userEntity.Setting = powerEntity.Setting; userEntity.Upwd = Daiv_OA.Utils.MD5.Lower32(this.txtPwd.Text.Trim()); userEntity.UClassID = 0; userEntity.ULongName = this.ULongName.Text; userEntity.UClassName = ""; userEntity.Mphone = this.Mphone.Text; //检查电话号码 //if (!string.IsNullOrEmpty(Mphone.Text) && !Validator.IsMobileNum(Mphone.Text)) //{ // FinalMessage(Mphone.Text + "电话号码无效!", "" , 1); // return; //} if (this.txtIpaddress.Text != "") { userEntity.Uipaddress = this.txtIpaddress.Text; } int i = new Daiv_OA.BLL.UserBLL().Add(userEntity); if (i > 0) { Addadminlog("添加用户"); } else { FinalMessage("相同的用户已经存在", "", 1); } }
//通过参数获取被更改的用户名 string Getoname() { Entity.UserEntity model = new Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); return(model.Uname); }
protected void btnSubmit_Click(object sender, EventArgs e) { // 记录其IP地址,下次登录时验证,IP为空则记录,IP不为空则验证 string uname = this.txtUserName.Text.Trim(); string upwd = this.txtUserPwd.Text.Trim(); string code = txtCode.Text.Trim(); if (uname.Equals("") || upwd.Equals("")) { lblTip.Visible = true; lblTip.Text = "请输入用户名或密码"; return; } if (code.Equals("")) { lblTip.Visible = true; lblTip.Text = "请输入验证码"; return; } if (Session[verify_code.SESSION_CODE] == null) { lblTip.Visible = true; lblTip.Text = "系统找不到验证码"; return; } if (code.ToLower() != Session[verify_code.SESSION_CODE].ToString().ToLower()) { lblTip.Visible = true; lblTip.Text = "验证码输入不正确"; return; } string uid = new Daiv_OA.BLL.UserBLL().Existslongin(uname, Daiv_OA.Utils.MD5.Lower32(upwd)); if (uid != "") { Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(int.Parse(uid)); if (model.Uipaddress != "") { if (model.Uipaddress != Page.Request.UserHostAddress) { Response.Write("<script>alert('非法IP,请在本机登陆!');</script>"); Response.End(); } } int iExpires = 0; //设置Cookies //System.Collections.Specialized.NameValueCollection myCol = new System.Collections.Specialized.NameValueCollection(); //myCol.Add("id", uid.ToString()); //myCol.Add("name", uname); //myCol.Add("ip", Request.UserHostAddress); //new BLL.UserBLL().UpdateTime(model.Uid); int pid = model.Pid; //myCol.Add("Powerid", pid.ToString()); //Daiv_OA.Utils.Cookie.SetObj("oa_user", 60 * 60 * 15 * iExpires, myCol, "", "/"); new BLL.UserBLL().SetUserCookies(model, Request.UserHostAddress, iExpires); switch (pid) { case 1: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //管理员 break; case 2: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //管理组织层 break; case 3: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //网站编辑 break; case 4: Session["UserName"] = uname; Response.Redirect("Index.aspx"); //美工和程序员 break; } } else { this.txtUserName.Text = ""; this.txtUserPwd.Text = ""; System.Web.UI.Page page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler; page.ClientScript.RegisterStartupScript(page.GetType(), "clientScript", "<script language='javascript'>alert('请正确填写用户名和密码!');</script>"); } }
public string GetUserNameById(string uid) { Daiv_OA.Entity.UserEntity user = new Daiv_OA.BLL.UserBLL().GetEntity(Str2Int(uid)); return(user.Uname); }
//更新 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.StudentEntity model = new Entity.StudentEntity(); Daiv_OA.BLL.ContactBLL contactBll = new Daiv_OA.BLL.ContactBLL(); Daiv_OA.BLL.StudentBLL studentBll = new Daiv_OA.BLL.StudentBLL(); Daiv_OA.BLL.GradeBLL gradeBll = new BLL.GradeBLL(); string uuid = Guid.NewGuid().ToString("N"); //修改联系电话 //保存上传文件 string fName = UploadFile(uuid); string path = Path.Combine(Server.MapPath("/"), "upload/" + DateTime.Now.ToString("yyyy/MM").Replace("/", "").Substring(0, 6)); ImportExcel import = new ImportExcel(); import.LoadFile(path + "/" + fName); DataSet ds = import.GetAllTables(true); DataTable dataTable = ds.Tables[0]; //获取班级数据 List <Entity.GradeEntity> glist = gradeBll.GetModelList(""); if (glist == null || glist.Count <= 0) { logHelper.logInfo("未添加任何班级数据!"); FinalMessage("导入失败,请先添加班级数据!", "", 0); } #region 验证表格 //验证表格 if (dataTable.Rows.Count <= 0) { logHelper.logInfo(fName + ",未填写任何学生数据!"); FinalMessage(fName + ",未填写任何学生数据!", "", 0); return; } for (int i = 0; i < colmun.Length; i++) { if (colmun[i] != dataTable.Columns[i].ColumnName) { FinalMessage("导入的excel表与模板excel表不符合!", "", 0); message.Visible = true; return; } } //验证班级数据 int tbCount = dataTable.Rows.Count; string tempCName = string.Empty; if (Request["schClassgcid"] == null || string.IsNullOrEmpty(Request["schClassgcid"].ToString())) { FinalMessage("没有选择班级,请重新选择!", "", 0); return; } try { SchClassId = int.Parse(Request["schClassgcid"].ToString()); } catch (Exception ex) { FinalMessage("班级转换失败,请重新选择!", "", 0); return; } //for (int j = 0; j < tbCount; j++) //{ // tempCName = Convert.ToString(dataTable.Rows[j][colmun[2]]); // if (glist.Where(g=>g.Gname == tempCName).FirstOrDefault() == null) // { // logHelper.logInfo(tempCName + " 未匹配到此班级名称!"); // FinalMessage(tempCName + " 未匹配到此班级名称!", "", 0); // message.Visible = true; // return; // } //} //验证时间的有效性 for (int i = 0; i < tbCount; i++) { try { Convert.ToDateTime(dataTable.Rows[i][colmun[3]]); } catch (Exception) { logHelper.logInfo(string.Format("'{0}' 出生年月日无效!", tempCName)); FinalMessage(Convert.ToString(dataTable.Rows[i][colmun[1]]) + "学生出生时间无效!", "", 0); message.Visible = true; return; } //验证学号 //验证学生序号是否存在 string snumbertemp = Convert.ToString(dataTable.Rows[i][colmun[0]]); bool exixt = new Daiv_OA.BLL.StudentBLL().Exists(snumbertemp); Daiv_OA.BLL.ContactBLL ctBll = new Daiv_OA.BLL.ContactBLL(); if (exixt) { FinalMessage(snumbertemp + "相同的学生学号已经存在", "", 0); message.Visible = true; return; } } #endregion //遍历表格 Entity.StudentEntity studentEntity = null; Entity.UserEntity parent = null; Entity.ContactEntity contactEnitty = null; for (int i = 0; i < tbCount; i++) { studentEntity = new Entity.StudentEntity(); parent = new Entity.UserEntity(); contactEnitty = new Entity.ContactEntity(); //保存数据 try { //学生实体相关信息保存 studentEntity.Gname = glist.Where(g => g.Gid == SchClassId).FirstOrDefault().Gname; //班级名称 列索引:2 studentEntity.Gid = glist.Where(g => g.Gid == SchClassId).FirstOrDefault().Gid; studentEntity.Snumber = Convert.ToString(dataTable.Rows[i][colmun[0]]); //学生学号 列索引:0 studentEntity.Sname = Convert.ToString(dataTable.Rows[i][colmun[1]]); //学生名称 列索引:1 studentEntity.Sbirthday = Convert.ToDateTime(dataTable.Rows[i][colmun[3]]); //出生年月日 列索引:3 //家长实体相关信息保存 parent.Uname = studentEntity.Snumber; string pwd = studentEntity.Sbirthday.ToString("yy") + studentEntity.Sbirthday.ToString("MM") + studentEntity.Sbirthday.ToString("dd"); parent.Upwd = Daiv_OA.Utils.MD5.Lower32(pwd); parent.Pid = 4; parent.Did = 0; parent.Position = "家长"; parent.Mphone = ""; Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(parent.Pid); parent.Setting = powerEntity.Setting; //联系电话实体相关信息保存 contactEnitty.Cphone = Convert.ToString(dataTable.Rows[i][colmun[4]]); //家长联系电话1 列索引:4 contactEnitty.Cphone2 = Convert.ToString(dataTable.Rows[i][colmun[5]]); //家长联系电话2 列索引:5 contactEnitty.Cphone3 = Convert.ToString(dataTable.Rows[i][colmun[6]]); //家长联系电话3 列索引:6 contactEnitty.Cphone4 = Convert.ToString(dataTable.Rows[i][colmun[7]]); //家长联系电话4 列索引:7 List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>(); contactList.Add(new Entity.ContactEntity() { CPhoneName = "家长1", Cphone = contactEnitty.Cphone }); contactList.Add(new Entity.ContactEntity() { CPhoneName = "家长2", Cphone = contactEnitty.Cphone2 }); contactList.Add(new Entity.ContactEntity() { CPhoneName = "家长3", Cphone = contactEnitty.Cphone3 }); contactList.Add(new Entity.ContactEntity() { CPhoneName = "家长4", Cphone = contactEnitty.Cphone4 }); //当前操作人对象 Entity.UserEntity opera = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); new Daiv_OA.BLL.StudentBLL().Add(studentEntity, parent, contactList, opera); } catch (Exception ex) { FinalMessage("操作失败!" + ex.Message, "Student_List.aspx", 1); return; } // FinalMessage("操作成功", "Student_List.aspx", 0); } logHelper.logInfo("导入成功!操作人:" + UserId); FinalMessage("导入成功", "Student_List.aspx", 0); }
/// <summary> /// 添加数据 /// </summary> /// <param name="studentEntity"></param> /// <param name="parent"></param> /// <param name="contactEnitty"></param> /// <param name="operatModel"></param> /// <returns></returns> public int Add(Entity.StudentEntity studentEntity, Entity.UserEntity parent, List <Entity.ContactEntity> contactList, Entity.UserEntity operatModel) { //验证学生序号是否存在 bool exixt = new Daiv_OA.BLL.StudentBLL().Exists(studentEntity.Snumber); Daiv_OA.BLL.ContactBLL ctBll = new Daiv_OA.BLL.ContactBLL(); if (exixt) { throw new Exception("相同的学生学号已经存在"); } int pId = 0; int sid = 0; try { //验证电话号码 foreach (var item in contactList) { if (!string.IsNullOrEmpty(item.Cphone) && !Validator.IsMobileNum(item.Cphone)) { throw new Exception(item.Cphone + "电话号码无效!"); } } //添加家长信息 pId = new Daiv_OA.BLL.UserBLL().Add(parent); if (pId > 0) { studentEntity.Uid = pId; //添加设置人员 studentEntity.MechID = operatModel.Uid; } else { throw new Exception("添加家长账号失败,请重新添加!"); } sid = new Daiv_OA.BLL.StudentBLL().Add(studentEntity); if (sid > 0) { //删除情亲好 ctBll.DeleteBySid(sid); //联系电话实体添加 foreach (var item in contactList) { item.Sid = sid; new Daiv_OA.BLL.ContactBLL().Add(item); } } else if (sid == 0) { throw new Exception("相同的学生已经存在"); } else if (sid == -1) { throw new Exception("相同的年级已经存在"); } } catch (Exception ex) { if (pId > 0) { new Daiv_OA.BLL.UserBLL().Delete(pId); } if (sid > 0) { Delete(sid); } logHelper.logInfo("添加学生失败!操作员ID:" + operatModel.Uname + " 失败原因:" + ex.Message); throw ex; } return(1); }
//添加 protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { Entity.StudentEntity studentEntity = new Entity.StudentEntity(); Entity.UserEntity parent = new Entity.UserEntity(); Entity.ContactEntity contactEnitty = new Entity.ContactEntity(); if (Request["schClassgcid"] == null || string.IsNullOrEmpty(Request["schClassgcid"].ToString())) { FinalMessage("班级无效!", "Student_Add.aspx?id=" + q("id"), 0); return; } //学生实体相关信息保存 studentEntity.Gname = ""; studentEntity.Gid = int.Parse(Request["schClassgcid"]); studentEntity.Snumber = this.Snumber.Text; studentEntity.Sname = this.Sname.Text; studentEntity.Sbirthday = Convert.ToDateTime(this.Sbirthday.Text); //家长实体相关信息保存 parent.Uname = studentEntity.Snumber; string pwd = studentEntity.Sbirthday.ToString("yy") + studentEntity.Sbirthday.ToString("MM") + studentEntity.Sbirthday.ToString("dd"); parent.Upwd = Daiv_OA.Utils.MD5.Lower32(pwd); parent.Pid = 4; parent.Did = 0; parent.Position = "家长"; parent.Mphone = ""; Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(parent.Pid); parent.Setting = powerEntity.Setting; //联系电话实体相关信息保存 //contactEnitty.Cphone = this.Cphone.Text; //contactEnitty.Cphone2 = this.Cphone2.Text; //contactEnitty.Cphone3 = this.Cphone3.Text; //contactEnitty.Cphone4 = this.Cphone4.Text; List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>(); string[] contactpArr = Request.Form["contactPhone"].Split(','); string[] contactnArr = Request.Form["contactName"].Split(','); for (int i = 0; i < contactpArr.Length; i++) { if (string.IsNullOrEmpty(contactpArr[i]) || string.IsNullOrEmpty(contactnArr[i])) { continue; } contactList.Add(new Entity.ContactEntity() { Cphone = contactpArr[i], CPhoneName = contactnArr[i] }); } //当前操作人对象 Entity.UserEntity opera = new Daiv_OA.BLL.UserBLL().GetEntity(UserId); //保存数据 try { new Daiv_OA.BLL.StudentBLL().Add(studentEntity, parent, contactList, opera); } catch (Exception ex) { FinalMessage("操作失败!" + ex.Message, "Student_List.aspx?cid=" + classId, 1); return; } FinalMessage("操作成功", "Student_List.aspx?cid=" + classId, 0); ////验证学生序号是否存在 //bool exixt = new Daiv_OA.BLL.StudentBLL().Exists(studentEntity.Snumber); //if (exixt) //{ // FinalMessage("相同的学生学号已经存在", "", 1); // return; //} //int pId = 0; //int sid = 0; //try //{ // //添加家长信息 // pId = new Daiv_OA.BLL.UserBLL().Add(parent); // if (pId > 0) // { // studentEntity.Uid = pId; // //添加设置人员 // studentEntity.MechID = UserId; // } // else // { // throw new Exception("添加家长账号失败,请重新添加!"); // } // sid = new Daiv_OA.BLL.StudentBLL().Add(studentEntity); // if (sid > 0) // { // //联系电话实体添加 // contactEnitty.Sid = sid; // new Daiv_OA.BLL.ContactBLL().Add(contactEnitty); // } // else if (sid == 0) // { // throw new Exception("相同的学生已经存在"); // } // else if (sid == -1) // { // throw new Exception("相同的年级已经存在"); // } //} //catch (Exception ex) //{ // if (!ex.Message.Contains("正在中止线程")) // { // try // { // if (pId > 0) // { // new Daiv_OA.BLL.UserBLL().Delete(pId); // } // if (sid > 0) // { // new Daiv_OA.BLL.StudentBLL().Delete(sid); // } // } // catch (Exception) // { // } // logHelper.logInfo("添加学生失败!操作员ID:" + UserId + " 失败原因:" + ex.Message); // FinalMessage("添加失败,请重试!", "", 1); // return; // } //} }
//数据绑定 void Bind() { int uid = Str2Int(q("id"), 0); department(); roless(); Daiv_OA.Entity.UserEntity model = new Daiv_OA.Entity.UserEntity(); model = new Daiv_OA.BLL.UserBLL().GetEntity(uid); this.txtUname.Text = model.Uname; this.txtUname.ReadOnly = true; // this.txtPosition.Text = model.Position; //职位 this.txtIpaddress.Text = model.Uipaddress; //this.UClassID.Text = model.UClassID.ToString(); this.ULongName.Text = model.ULongName; //this.UClassName.Text = model.UClassName ; this.Mphone.Text = model.Mphone; string user_setting = ""; string[,] menu = null; if (pidtxt.Text != "") { Entity.PowerEntity powerEntity = new BLL.PowerBLL().GetEntity(Convert.ToInt32(pidtxt.Text.Trim())); user_setting = powerEntity.Setting; int pid = Convert.ToInt32(pidtxt.Text); if (depid.Text != "") { DropDownList1.SelectedValue = depid.Text.ToString(); } else { DropDownList1.SelectedValue = model.Did.ToString(); } DropDownList2.SelectedValue = pid.ToString(); if (pid == 1) { menu = powerMenu1(); } if (pid == 2) { menu = powerMenu2(); } else if (pid == 3) { menu = powerMenu3(); } else if (pid == 4) { menu = powerMenu4(); } } else { DropDownList1.SelectedValue = model.Did.ToString(); DropDownList2.SelectedValue = model.Pid.ToString(); user_setting = model.Setting; if (model.Pid == 1) { menu = powerMenu1(); } if (model.Pid == 2) { menu = powerMenu2(); } else if (model.Pid == 3) { menu = powerMenu3(); } else if (model.Pid == 4) { menu = powerMenu4(); } } //绑定班级 Daiv_OA.BLL.GradeBLL dp = new Daiv_OA.BLL.GradeBLL(); DataSet ds = dp.GetList(""); for (int j = 0; j < ds.Tables[0].Rows.Count; j++) { ListItem listItem = new ListItem(); listItem.Text = ds.Tables[0].Rows[j]["Gname"].ToString(); listItem.Value = ds.Tables[0].Rows[j]["Gid"].ToString(); this.ddlGid.Items.Add(listItem); } this.ddlGid.SelectedValue = model.UClassID.ToString(); ds.Clear(); StringBuilder sb = new StringBuilder(); sb.Append("<table cellspacing=\"0\" width=\"100%\" cellpadding=\"0\" align=\"center\">"); for (int i = 0; i < menu.GetLength(0); i++) { sb.Append("<tr><td width=\"260\" align=\"right\"><strong>" + menu[i, 0] + "</strong></td>"); sb.Append("<td width=\"*\">"); for (int j = 1; j < menu.GetLength(1); j++) { if (menu[i, j] == null) { break; } string[] _split = menu[i, j].Split('|'); sb.Append("<span style='float:left;height:30px;margin-left:10px;padding-top:5px;' scope='col'><input id=\"user_setting_" + i + "_" + j + "\" type=checkbox class='checkbox' name=\"user_setting\" value=\""); string tPower = _split[1]; sb.Append(tPower + "\""); if (_split.Length > 2 && _split[2] == "1") { sb.Append(" onclick='if(!this.checked){this.checked=true;}else{this.checked=false;}'"); } if (user_setting.Contains("," + tPower + ",")) { sb.Append(" checked"); } sb.Append("><label for=\"user_setting_" + i + "_" + j + "\">" + _split[0] + "</label>"); sb.Append("</span>\r\n"); } sb.Append("</td></tr>"); } sb.Append("</td></tr>"); sb.Append("</table>"); this.ltMasterSetting.Text = sb.ToString(); }
/// <summary> /// 修改联系电话 /// </summary> /// <param name="context"></param> /// <returns></returns> private ResponeDataEntity SetContact(HttpContext context, JObject ob) { string snumber = ob["sNumber"].ToString(); string password = ob["password"].ToString(); string cPhone = ob["cPhone"].ToString(); string cPhoneName = ob["cPhoneName"].ToString(); string cPhone2 = ob["cPhone2"].ToString(); string cPhone3 = ob["cPhone3"].ToString(); string cPhone4 = ob["cPhone4"].ToString(); ResponeDataEntity resultEntity = new ResponeDataEntity(); logHelper.logInfo(" SetContact params:sNumber:" + snumber + " cPhone:" + cPhone + " cPhone2:" + cPhone2 + "cPhone3:" + cPhone3 + " cPhone4:" + cPhone4); //获取学生对象 Daiv_OA.Entity.StudentEntity stuEntity = stubll.GetEntityByNumber(snumber); if (stuEntity == null) { return new ResponeDataEntity() { Status = 0, Msg = snumber + "学生学号无效!" } } ; string uid = new Daiv_OA.BLL.UserBLL().Existslongin(snumber, Daiv_OA.Utils.MD5.Lower32(password)); if (string.IsNullOrEmpty(uid)) { return(new ResponeDataEntity() { Status = 0, Msg = snumber + "输入密码无效!" }); } //Daiv_OA.Entity.ContactEntity ctEntity = ctbll.GetEntityBySid(stuEntity.Sid); //电话号码验证 //if (!string.IsNullOrEmpty(cPhone) && !Validator.IsMobileNum(cPhone)) { resultEntity.Msg = cPhone+"电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone2) && !Validator.IsMobileNum(cPhone2)) { resultEntity.Msg = cPhone2 + "电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone3) && !Validator.IsMobileNum(cPhone3)) { resultEntity.Msg = cPhone3 + "电话号码无效!"; return resultEntity; }; //if (!string.IsNullOrEmpty(cPhone4) && !Validator.IsMobileNum(cPhone4)) { resultEntity.Msg = cPhone4 + "电话号码无效!"; return resultEntity; }; ////保存数据 //if (ctEntity == null) //{ // ctEntity = new ContactEntity() { Sid = stuEntity.Sid }; // ctEntity.Cphone = cPhone; // ctEntity.Cphone2 = cPhone2; // ctEntity.Cphone3 = cPhone3; // ctEntity.Cphone4 = cPhone4; // ctbll.Add(ctEntity); // return new ResponeDataEntity() { Status = 1, Msg = snumber + "修改成功!" }; //} //ctEntity.Cphone = cPhone; //ctEntity.Cphone2 = cPhone2; //ctEntity.Cphone3 = cPhone3; //ctEntity.Cphone4 = cPhone4; //ctbll.Update(ctEntity); string[] cPhoneArr = cPhone.Split(','); string[] cPhonenArr = cPhoneName.Split(','); List <Entity.ContactEntity> contactList = new List <Entity.ContactEntity>(); for (int i = 0; i < cPhoneArr.Length; i++) { if (string.IsNullOrEmpty(cPhoneArr[i]) || string.IsNullOrEmpty(cPhoneArr[i])) { continue; } //验证电话号码 if (!string.IsNullOrEmpty(cPhoneArr[i]) && !Validator.IsMobileNum(cPhoneArr[i])) { resultEntity.Msg = cPhoneArr[i] + "电话号码无效!"; return(resultEntity); } ; contactList.Add(new Entity.ContactEntity() { Cphone = cPhoneArr[i], CPhoneName = cPhonenArr[i] }); } //ctbll.DeleteBySid(stuEntity.Sid); ////联系电话实体添加 //foreach (var item in contactList) //{ // item.Sid = stuEntity.Sid; // ctbll.Add(item); //} ctbll.AddBatch(contactList, stuEntity.Sid); return(new ResponeDataEntity() { Status = 1, Msg = snumber + "修改成功!" }); }