/// <summary> /// 修改 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEnter_Click(object sender, EventArgs e) { try { Song.Entities.User obj; if (id == 0) { obj = new Song.Entities.User(); } else { obj = Business.Do <IUser>().GetUserSingle(id); //先清除与用户组的关联 Business.Do <IEmpGroup>().DelRelation4Emplyee(id); } //帐号 obj.User_AccName = this.tbAccName.Text.Trim(); //员工名称 obj.User_Name = this.tbName.Text; //员工登录密码,为空 if (tbPw1.Text != "") { string md5 = WeiSha.Common.Request.Controls[tbPw1].MD5; obj.User_Pw = md5; } //邮箱 obj.User_Email = this.tbEmail.Text; //是否在职 obj.User_IsUse = this.cbIsUse.Checked; //性别 obj.User_Sex = Convert.ToInt16(rbSex.SelectedValue); //所属组 obj.UGrp_Id = Convert.ToInt32(ddlGroup.SelectedItem.Value); obj.UGrp_Name = ddlGroup.SelectedItem.Text; //联系方式 obj.User_Tel = tbTel.Text; obj.User_MobileTel = tbMobleTel.Text; obj.User_QQ = tbQQ.Text; obj.User_Msn = tbMsn.Text; if (id == 0) { id = Business.Do <IUser>().AddUser(obj); } else { Business.Do <IUser>().SaveUser(obj); } Master.AlertCloseAndRefresh("操作成功!"); } catch (Exception ex) { Message.ExceptionShow(ex); } }
private void fill() { try { Song.Entities.User ea; if (id != 0) { ea = Business.Do <IUser>().GetUserSingle(id); //所属的组 Song.Entities.UserGroup egs = Business.Do <IUser>().GetGroup4User(id); ListItem li = this.ddlGroup.Items.FindByValue(egs.UGrp_Id.ToString()); if (li != null) { li.Selected = true; } //性别 string sex = ea.User_Sex.ToString().ToLower(); ListItem liSex = rbSex.Items.FindByValue(sex); if (liSex != null) { liSex.Selected = true; } } else { ea = new Song.Entities.User(); ea.User_RegTime = DateTime.Now; ea.User_IsUse = true; } //员工帐号 this.tbAccName.Text = ea.User_AccName; //员工名称 this.tbName.Text = ea.User_Name; //员工登录密码,为空 //邮箱 this.tbEmail.Text = ea.User_Email; //是否在职 this.cbIsUse.Checked = ea.User_IsUse; //联系方式 tbTel.Text = ea.User_Tel; tbMobleTel.Text = ea.User_MobileTel; tbQQ.Text = ea.User_QQ; tbMsn.Text = ea.User_Msn; } catch (Exception ex) { Message.ExceptionShow(ex); } }
/// <summary> /// 修改是否显示的状态 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void sbShow_Click(object sender, EventArgs e) { try { StateButton ub = (StateButton)sender; int index = ((GridViewRow)(ub.Parent.Parent)).RowIndex; int id = int.Parse(this.GridView1.DataKeys[index].Value.ToString()); // Song.Entities.User entity = Business.Do <IUser>().GetUserSingle(id); entity.User_IsUse = !entity.User_IsUse; Business.Do <IUser>().SaveUser(entity); BindData(null, null); } catch (Exception ex) { Message.ExceptionShow(ex); } }