public int UpdateData(DEUser user, DataTable dt_Permission) { int int_Result = 0; DALUserPermission obj_DALUserPermission = new DALUserPermission(); DEUserPermission userPermission = new DEUserPermission(); userPermission.UserId = user.UserId; SqlConnection SqlCon = new SqlConnection(SqlConjunction.DataConn); try { if (SqlCon.State != ConnectionState.Open) { SqlCon.Open(); } } catch (SqlException ex) { Console.WriteLine(ex); } SqlTransaction tn = SqlCon.BeginTransaction(); { try { this.UpdateData(user, SqlCon, tn); obj_DALUserPermission.DeleteData(userPermission, SqlCon, tn); for (int i = 0; i < dt_Permission.Rows.Count; i++) { userPermission.PermissionId = Convert.ToInt32(dt_Permission.Rows[i][0].ToString()); obj_DALUserPermission.InsertData(userPermission, SqlCon, tn); } tn.Commit(); int_Result = 1; } catch (Exception ex) { tn.Rollback(); int_Result = 0; throw (ex); } finally { obj_DALUserPermission = null; SqlCon.Close(); tn.Dispose(); } return(int_Result); } }
private void DisplayData(DEUser user) { txt_Name.Text = user.Name; txt_LoginName.Text = user.LoginName; txt_Password.Text = user.Password; txt_ConfirmPassword.Text = user.Password; }
private void saveNewUser() { user.UserId = Guid.NewGuid(); BLLUser obj_BLLUser = new BLLUser(); try { int int_Result = obj_BLLUser.InsertData(user, dt_UserPermission); if (int_Result > 0) { MessageBox.Show(UIConstantMessage.Const_strSaveSuccessfully); BindDataGridView(); clearScreen(); } } catch (Exception ex) { throw ex; } finally { user = new DEUser(); obj_BLLUser = null; } }
public int UpdateData(DEUser user, DataTable dt_Permission) { DALUser obj_DALUser = new DALUser(); int int_Result = obj_DALUser.UpdateData(user, dt_Permission); obj_DALUser = null; return(int_Result); }
public Boolean LoadUserByLoginNameAndPassword(DEUser User) { DALUser obj_DALUser = new DALUser(); Boolean bool_HasRow = obj_DALUser.LoadUserByLoginNameAndPassword(User); obj_DALUser = null; return(bool_HasRow); }
public DataTable LoadUserPermissionTableForAllDataByUserId(DEUser user) { DALUser obj_DALUser = new DALUser(); DataTable dt_User = obj_DALUser.LoadUserPermissionTableForAllDataByUserId(user); obj_DALUser = null; return(dt_User); }
public Boolean LoadUserRow(DEUser user) { DALUser obj_DALUser = new DALUser(); Boolean bool_HasRow = obj_DALUser.LoadUserRow(user); obj_DALUser = null; return(bool_HasRow); }
private Boolean checkUserExistedOrNot(String str_LoginName) { DEUser user = new DEUser(); user.LoginName = str_LoginName; DALUser obj_DALUser = new DALUser(); Boolean bool_HasRow = obj_DALUser.LoadUserRowByLoginName(user); return(bool_HasRow); }
private SqlCommand DeclareSqlCmdParameter(SqlCommand SqlCmd, DEUser user) { SqlCmd.Parameters.AddWithValue("@UserId", user.UserId); SqlCmd.Parameters.AddWithValue("@Name", user.Name); SqlCmd.Parameters.AddWithValue("@LoginName", user.LoginName); SqlCmd.Parameters.AddWithValue("@Password", user.Password); SqlCmd.Parameters.AddWithValue("@Active", user.Active); SqlCmd.Parameters.AddWithValue("@ModifiedBy", user.ModifiedBy); SqlCmd.Parameters.AddWithValue("@ModifiedDate", user.ModifiedDate); return(SqlCmd); }
public DataTable LoadUserPermissionTableForAllDataByUserId(DEUser user) { DataTable dt_UserPermission; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "SELECT P.PermissionId as 'No',P.Description as 'Permission' FROM tbl_Permission P LEFT JOIN tbl_UserPermission UP on P.PermissionId = UP.PermissionId where UP.UserId = @UserId"; sqlCmd = DeclareSqlCmdParameter(sqlCmd, user); dt_UserPermission = SqlConjunction.GetSQLDataTable(sqlCmd); sqlCmd = null; return(dt_UserPermission); }
public int UpdateData(DEUser user, SqlConnection SqlCon, SqlTransaction tn) { int int_Result; SqlCommand sqlCmd = new SqlCommand(" ", SqlCon, tn); sqlCmd.CommandText = "UPDATE tbl_User SET UserId = @UserId, Name = @Name, LoginName = @LoginName, Password = @Password, Active = @Active , ModifiedBy = @ModifiedBy, ModifiedDate = @ModifiedDate where UserId = @UserId"; DeclareSqlCmdParameter(sqlCmd, user); int_Result = SqlConjunction.GetSQLTransVoid(sqlCmd); sqlCmd = null; return(int_Result); }
public int InsertData(DEUser user, SqlConnection SqlCon, SqlTransaction tn) { int int_Result; SqlCommand sqlCmd = new SqlCommand(" ", SqlCon, tn); sqlCmd.CommandText = "INSERT tbl_User VALUES(@UserId,@Name,@LoginName,@Password,@Active,@ModifiedBy,@ModifiedDate)"; DeclareSqlCmdParameter(sqlCmd, user); int_Result = SqlConjunction.GetSQLTransVoid(sqlCmd); sqlCmd = null; return(int_Result); }
public Boolean LoadUserRow(DEUser user) { Boolean bool_HasRows = false; SqlCommand sqlCmd = new SqlCommand(); sqlCmd.CommandText = "SELECT UserId,Name,LoginName,Password,Active,ModifiedBy,ModifiedDate FROM tbl_User Where UserId=@UserId"; sqlCmd = DeclareSqlCmdParameter(sqlCmd, user); SqlConnection con = new SqlConnection(SqlConjunction.DataConn); SqlDataReader sqlDataReader = SqlConjunction.GetSQLExecuteReader(sqlCmd, con); while (sqlDataReader.Read()) { user.UserId = sqlDataReader.GetGuid(0); user.Name = sqlDataReader.GetString(1); user.LoginName = sqlDataReader.GetString(2); user.Password = sqlDataReader.GetString(3); user.Active = sqlDataReader.GetBoolean(4); user.ModifiedBy = sqlDataReader.GetString(5); user.ModifiedDate = sqlDataReader.GetDateTime(6); } if (sqlDataReader.HasRows) { bool_HasRows = true; } else { bool_HasRows = false; } con.Close(); sqlCmd = null; return(bool_HasRows); }
private void Login() { if (true)//checkExpire()) ///////////////////////// Expiration Check ///////////////// { DEUser User = new DEUser(); BLLUser obj_BLLUser = new BLLUser(); try { if (txt_LoginName.Text.Trim().Length == 0) { MessageBox.Show("Enter Login Name"); } else { bool bool_Result; User.LoginName = txt_LoginName.Text; User.Password = txt_Password.Text; bool_Result = obj_BLLUser.LoadUserByLoginNameAndPassword(User); if (bool_Result == true) { DEGlobal.str_UserName = User.LoginName; DEGlobal.dt_UserPermission = obj_BLLUser.LoadUserPermissionTableForAllDataByUserId(User); for (int i = 0; i < DEGlobal.dt_UserPermission.Rows.Count; i++) { if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 1) { DEGlobal.bool_ProductManagement = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 2) { DEGlobal.bool_CatagoryManagement = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 3) { DEGlobal.bool_CustomerManagement = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 4) { DEGlobal.bool_CreateCash = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 5) { DEGlobal.bool_CreateCredit = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 6) { DEGlobal.bool_CreateConsign = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 7) { DEGlobal.bool_EditCash = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 8) { DEGlobal.bool_EditCredit = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 9) { DEGlobal.bool_EditConsign = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 10) { DEGlobal.bool_NewArrival = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 11) { DEGlobal.bool_EditArrival = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 12) { DEGlobal.bool_UserManagement = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 13) { DEGlobal.bool_DataBaseBackup = true; } else if (Convert.ToInt32(DEGlobal.dt_UserPermission.Rows[i][0].ToString()) == 14) { DEGlobal.bool_CancelInvoice = true; } } this.Close(); } else { MessageBox.Show("Invalid Login name and password."); txt_LoginName.Text = string.Empty; txt_Password.Text = string.Empty; txt_LoginName.Focus(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); this.Close(); } finally { User = null; obj_BLLUser = null; } } else { MessageBox.Show("Software is Trial Version and has been expired,\nPlease Contact 09-400494659, Zar Ni Minn, Software Developer,\nLogicForce Software Development Team.", "Expiration Alert"); } }