public void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (!PageValidate.IsDateTime(txtBirthday.Text)) { strErr += "生日格式错误!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } int Id = int.Parse(this.lblId.Text); string Name = this.lblName.Text; String Password = this.txtPassword.Text; String TrueName = this.txtTrueName.Text; String Sex = this.ddlSex.SelectedValue; String Phone = this.txtPhone.Text; string path = Server.MapPath("~/"); string Photo = ""; string filename = ""; string contentType = fuPhoto.PostedFile.ContentType; if (contentType == "image/pjpeg" || contentType == "image/bmp" || contentType == "image/gif") { string format = fuPhoto.FileName.Split('.')[1]; Photo = "Upload/" + Guid.NewGuid() + "." + format; filename = path + Photo; fuPhoto.PostedFile.SaveAs(filename); } else { Maticsoft.Common.MessageBox.Show(this, "请上传图片文件!"); return; } String Email = this.txtEmail.Text; DateTime Birthday = DateTime.Parse(this.txtBirthday.Text); bool IsActivity = this.chkIsActivity.Checked; int Fk_Roles_Id = int.Parse(this.ddlFk_Roles_Id.SelectedValue); Maticsoft.Model.Users model = new Maticsoft.Model.Users(); model.Id = Id; model.Name = Name; model.Password = Password; model.TrueName = TrueName; model.Sex = Sex; model.Phone = Phone; model.Photo = Photo; model.Email = Email; model.Birthday = Birthday; model.IsActivity = IsActivity; model.Fk_Roles_Id = Fk_Roles_Id; Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); bll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "usercenter.aspx"); }
private void ShowInfo(int Id) { Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); Maticsoft.Model.Users model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblName.Text = model.Name; this.txtPassword.Text = model.Password; this.txtTrueName.Text = model.TrueName; this.ddlSex.SelectedValue = model.Sex; this.txtPhone.Text = model.Phone; //this.txtPhoto.Text=model.Photo; this.txtEmail.Text = model.Email; this.txtBirthday.Text = model.Birthday.ToString(); this.chkIsActivity.Checked = model.IsActivity; this.ddlFk_Roles_Id.SelectedValue = model.Fk_Roles_Id.ToString(); }
private void ShowInfo(int Id) { Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); Maticsoft.Model.Users model = bll.GetModel(Id); this.lblId.Text = model.Id.ToString(); this.lblName.Text = model.Name; this.lblTrueName.Text = model.TrueName; this.lblSex.Text = model.Sex; this.lblPhone.Text = model.Phone; this.iPhoto.ImageUrl = "~/" + model.Photo; this.lblEmail.Text = model.Email; this.lblBirthday.Text = model.Birthday.ToString(); BLL.Roles BLLRoles = new BLL.Roles(); Model.Roles ModelRoles = BLLRoles.GetModel((int)model.Fk_Roles_Id); this.lblFk_Roles_Id.Text = ModelRoles.Name; }
private void ShowInfo(string UserID) { Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); Maticsoft.Model.Users model = bll.GetModel(UserID); this.lblUserID.Text = model.UserID; this.txtUsername.Text = model.Username; this.txtUserPassword.Text = model.UserPassword; this.txtUserRealName.Text = model.UserRealName; this.txtUserSex.Text = model.UserSex; this.txtUserEmail.Text = model.UserEmail; this.txtUserGrade.Text = model.UserGrade; this.txtUserScore.Text = model.UserScore.ToString(); this.txtProvince.Text = model.Province; this.txtCity.Text = model.City; this.txtAddress1.Text = model.Address1; this.txtUserIdentity.Text = model.UserIdentity; this.txtRegistTime.Text = model.RegistTime.ToString(); this.txtPhone.Text = model.Phone; }
protected void btnSave_Click(object sender, EventArgs e) { string strErr = ""; if (this.txtUserID.Text.Trim().Length == 0) { strErr += "UserID不能为空!\\n"; } if (this.txtUsername.Text.Trim().Length == 0) { strErr += "Username不能为空!\\n"; } if (this.txtUserPassword.Text.Trim().Length == 0) { strErr += "UserPassword不能为空!\\n"; } if (this.txtUserRealName.Text.Trim().Length == 0) { strErr += "UserRealName不能为空!\\n"; } if (this.txtUserSex.Text.Trim().Length == 0) { strErr += "UserSex不能为空!\\n"; } if (this.txtUserEmail.Text.Trim().Length == 0) { strErr += "UserEmail不能为空!\\n"; } if (this.txtUserGrade.Text.Trim().Length == 0) { strErr += "UserGrade不能为空!\\n"; } if (!PageValidate.IsNumber(txtUserScore.Text)) { strErr += "UserScore格式错误!\\n"; } if (this.txtProvince.Text.Trim().Length == 0) { strErr += "Province不能为空!\\n"; } if (this.txtCity.Text.Trim().Length == 0) { strErr += "City不能为空!\\n"; } if (this.txtAddress1.Text.Trim().Length == 0) { strErr += "Address1不能为空!\\n"; } if (this.txtUserIdentity.Text.Trim().Length == 0) { strErr += "UserIdentity不能为空!\\n"; } if (!PageValidate.IsDateTime(txtRegistTime.Text)) { strErr += "RegistTime格式错误!\\n"; } if (this.txtPhone.Text.Trim().Length == 0) { strErr += "Phone不能为空!\\n"; } if (strErr != "") { MessageBox.Show(this, strErr); return; } string UserID = this.txtUserID.Text; string Username = this.txtUsername.Text; string UserPassword = this.txtUserPassword.Text; string UserRealName = this.txtUserRealName.Text; string UserSex = this.txtUserSex.Text; string UserEmail = this.txtUserEmail.Text; string UserGrade = this.txtUserGrade.Text; int UserScore = int.Parse(this.txtUserScore.Text); string Province = this.txtProvince.Text; string City = this.txtCity.Text; string Address1 = this.txtAddress1.Text; string UserIdentity = this.txtUserIdentity.Text; DateTime RegistTime = DateTime.Parse(this.txtRegistTime.Text); string Phone = this.txtPhone.Text; Maticsoft.Model.Users model = new Maticsoft.Model.Users(); model.UserID = UserID; model.Username = Username; model.UserPassword = UserPassword; model.UserRealName = UserRealName; model.UserSex = UserSex; model.UserEmail = UserEmail; model.UserGrade = UserGrade; model.UserScore = UserScore; model.Province = Province; model.City = City; model.Address1 = Address1; model.UserIdentity = UserIdentity; model.RegistTime = RegistTime; model.Phone = Phone; Maticsoft.BLL.Users bll = new Maticsoft.BLL.Users(); bll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx"); }