protected void btnSave_Click(object sender, EventArgs e) { string message = ""; try { if (hdfId.Value == null || hdfId.Value == "")//them moi { message = checkInput(); } else { message = checkPassword(); } int status = 0; if (message == "") { ulBus = new UserLoginBUS(); UserLoginDTO ulDto = new UserLoginDTO(); ulDto.Username = txtUsername.Text; ulDto.Password = Common.GetMd5Hash(txtPassword.Text); ulDto.DepartmentId = int.Parse(this.dropTypeUser.SelectedItem.Value.ToString()); DataTable dtLogin = ulBus.GetByUserType(ulDto.DepartmentId); ulDto.UserType =int.Parse(dtLogin.Rows[0]["UserType"].ToString()); ulDto.Is_Block = this.chkBlock.Checked; ulDto.Deleted = 0; ConnectionData.OpenMyConnection(); if (hdfId.Value == null || hdfId.Value == "")//them moi { ulBus.tblUserLogin_insert(ulDto); status = 1; } else { ulDto.UserId = int.Parse(hdfId.Value); ulBus.tblUserLogin_Update(ulDto); status = 2; } ConnectionData.CloseMyConnection(); pnSuccess.Visible = true; pnError.Visible = false; LoadData(); if (status == 1) { lblSuccess.Text = "Thêm thành công !"; } else if (status == 2) { lblSuccess.Text = "Bạn vừa cập nhật thành công chức năng !"; txtUsername.Enabled = true; } } else { pnSuccess.Visible = false; pnError.Visible = true; lblError.Text = message; } } catch (Exception ex) { logs.Error(userLogin.Username + "-Client - btnSave_Click", ex); pnSuccess.Visible = false; pnError.Visible = true; lblError.Text = "Kiểm tra lại dữ liệu nhập vào !"; } }