protected void CheckUser_Click(object sender, EventArgs e) { bool flag = bll.CheckUserByUID(NewUserName.Text); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('用户名已存在!');</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('恭喜用户名可用');</script>"); } }
protected void Add_Click(object sender, EventArgs e) { EmployeeBLL bll = new EmployeeBLL(); EmployeeModel employee = new EmployeeModel(); UserModel addUser = new UserModel(); UsersBLL userbll = new UsersBLL(); employee.EmlpoyeeName = txtName.Text.Trim(); employee.Sex = Convert.ToInt32(RBLSex.SelectedValue); employee.Arrage = txtArrage.Text.Trim(); employee.Address = txtAddress.Text.Trim(); employee.Tel = txtTel.Text.Trim(); employee.Mobile = txtMobile.Text.Trim(); employee.CardID = txtID.Text.Trim(); if (path == "") { employee.PhotoPath = @"~\Admin\UserHeadImages\Default.jpg"; } else { employee.PhotoPath = path; } if (txtUID.Text.Trim() == "") { addUser.UID = txtID.Text.Trim(); } else { addUser.UID = txtUID.Text.Trim(); } if (txtPassword.Text.Trim() == "") { addUser.Password = txtID.Text.Trim(); } else { addUser.Password = txtPassword.Text.Trim(); } addUser.UserType = 1; addUser.SubID = bll.GetMaxID() + 1; if (userbll.CheckUserByUID(addUser.UID)) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('用户名已存在!');</script>"); return; } else { bool flag = bll.InsertEmployee(employee, addUser); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加成功');location.href='EmployeeInfo.aspx';</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加失败');</script>"); } } }
protected void Save_Click(object sender, EventArgs e) { HomeHoldBLL homebll = new HomeHoldBLL(); HomeHoldModel homeHold = new HomeHoldModel(); UserModel addUser = new UserModel(); UsersBLL userbll = new UsersBLL(); homeHold.Code = DDLRoomID.SelectedValue; homeHold.UserName = txtName.Text.Trim(); homeHold.Tel = txtTelephone.Text.Trim(); homeHold.Contact = txtAddress.Text.Trim(); homeHold.Mobile = txtMobile.Text.Trim(); homeHold.Email = txtEmail.Text.Trim(); homeHold.CardID = txtID.Text.Trim(); homeHold.OwnerID = txtOwnerID.Text.Trim(); homeHold.Unit = txtUnit.Text.Trim(); homeHold.Memo = txtMemo.Text.Trim(); if (txtUID.Text.Trim() == "") { addUser.UID = txtID.Text.Trim(); } else { addUser.UID = txtUID.Text.Trim(); } if (txtPassword.Text.Trim() == "") { addUser.Password = txtID.Text.Trim(); } else { addUser.Password = txtPassword.Text.Trim(); } addUser.UserType = 0; addUser.SubID = homebll.GetMaxID() + 1; if (userbll.CheckUserByUID(addUser.UID)) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('用户名已存在!');</script>"); return; } else { bool flag = homebll.InsertHomeHold(homeHold, addUser, DDLRoomID.SelectedValue, 1); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加成功');location.href='HomeHoldInfo.aspx';</script>"); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加失败');</script>"); } } }