public static void updatePassword(int USERID, string PASSWORD) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "Password", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, DataTransformer.PasswordHash(PASSWORD).ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Users SET Password = @Password WHERE UserID = @UserID"; SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@Password", DataTransformer.PasswordHash(PASSWORD)), new SqlParameter("@UserID", USERID)); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Users GetPODetailsFromMSID(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static void DisableDockSpot(int SPOTID) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "TruckDockSpots", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'true'", null, "SpotID", SPOTID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.TruckDockSpots SET isDisabled = 'true' WHERE SpotID = @SpotID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SpotID", SPOTID)); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_DockSpots DisableDockSpot(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static void UpdateDockSpot(int SPOTID, string SPOTDESCRIPTION, string SPOTTYPE, string HOURSINTIMEBLOCK) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; SqlParameter paramSpotID = new SqlParameter("@SpotID", SqlDbType.Int); SqlParameter paramSpotType = new SqlParameter("@SpotType", SqlDbType.NVarChar); SqlParameter paramSpotDescription = new SqlParameter("@SpotDescription", SqlDbType.NVarChar); SqlParameter paramHoursInTimeBlock = new SqlParameter("@HoursInTimeBlock", SqlDbType.Float); paramSpotID.Value = SPOTID; paramSpotType.Value = SPOTTYPE; paramSpotDescription.Value = SPOTDESCRIPTION; paramHoursInTimeBlock.Value = HOURSINTIMEBLOCK; sqlCmdText = "SELECT COUNT(SpotID) FROM dbo.TruckDockSpots WHERE (isDisabled = 'false') AND (SpotDescription = @SpotDescription) AND SpotID != @SpotID"; int hasRows = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SpotDescription", SPOTDESCRIPTION), new SqlParameter("@SpotID", SPOTID))); if (hasRows == 0) { ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "TruckDockSpots", "SpotDescription", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, SPOTDESCRIPTION.ToString(), null, "SpotID", SPOTID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "TruckDockSpots", "SpotType", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, SPOTTYPE.ToString(), null, "SpotID", SPOTID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "TruckDockSpots", "HoursInTimeBlock", now, zxpUD._uid, ChangeLog.ChangeLogDataType.FLOAT, HOURSINTIMEBLOCK.ToString(), null, "SpotID", SPOTID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.TruckDockSpots SET SpotType = @SpotType, SpotDescription = @SpotDescription, HoursInTimeBlock = @HoursInTimeBlock WHERE SpotID = @SpotID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SpotType", SPOTTYPE), new SqlParameter("@SpotDescription", SPOTDESCRIPTION), new SqlParameter("@HoursInTimeBlock", HOURSINTIMEBLOCK), new SqlParameter("@SpotID", SPOTID)); } else {//if it does exist, throw exception throw new Exception("Another spot with that name already exist"); } scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_DockSpots UpdateDockSpot(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static int SetNewSpot(string SPOTDESCRIPTION, string SPOTTYPE, float HOURSINTIMENBLOCK) { Int32 SpotID = 0; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "SELECT COUNT(SpotID) FROM dbo.TruckDockSpots WHERE (isDisabled = 'false') AND (SpotDescription = @SpotDescription)"; int hasRows = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SpotDescription", SPOTDESCRIPTION))); if (hasRows == 0) { sqlCmdText = "INSERT INTO dbo.TruckDockSpots (SpotDescription, SpotType, HoursInTimeBlock, isDisabled) " + "VALUES (@SpotDescription, @SpotType, @HoursInTimeBlock, 'false'); " + "SELECT CAST(scope_identity() AS int)"; } else {//if it does exist, throw exception throw new Exception("The combination of Spot Name and Spot Type already exist"); } SpotID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@SpotDescription", SPOTDESCRIPTION), new SqlParameter("@SpotType", SPOTTYPE), new SqlParameter("@HoursInTimeBlock", HOURSINTIMENBLOCK))); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "TruckDockSpots", "SpotDescription", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, SPOTDESCRIPTION.ToString(), null, "SpotID", SpotID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "TruckDockSpots", "SpotType", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, SPOTTYPE.ToString(), null, "SpotID", SpotID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "TruckDockSpots", "HoursInTimeBlock", now, zxpUD._uid, ChangeLog.ChangeLogDataType.FLOAT, HOURSINTIMENBLOCK.ToString(), null, "SpotID", SpotID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "TruckDockSpots", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'false'", null, "SpotID", SpotID.ToString()); cl.CreateChangeLogEntryIfChanged(); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_DockSpots SetNewSpot(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(SpotID); }
public static void updatePatternAndProcessFile(int PATTERNID, string FILENAME) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); string[] newFileAndPath = TransportHelperFunctions.ProcessFileAndData(FILENAME, "PATTERN"); if (2 == newFileAndPath.Length) { using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; string filepath = ConfigurationManager.AppSettings["fileUploadPath"]; string newFilePath = string.Empty; newFilePath = filepath + ConfigurationManager.AppSettings["PATTERNPATH"]; newFilePath = newFilePath.Replace("~/", "").Replace('/', '\\'); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Patterns", "FileNameOld", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FILENAME.ToString(), null, "PatternID", PATTERNID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Patterns", "FileNameNew", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, newFileAndPath[1].ToString(), null, "PatternID", PATTERNID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Patterns", "FilePath", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, newFileAndPath[0].ToString(), null, "PatternID", PATTERNID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Patterns " + "SET FileNameOld = @FileNameOld, FileNameNew = @FileNameNew, FilePath = @FilePath " + "WHERE PatternID = @PatternID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@FileNameOld", FILENAME), new SqlParameter("@FileNameNew", newFileAndPath[1]), new SqlParameter("@FilePath", newFileAndPath[0]), new SqlParameter("@PatternID", PATTERNID)); scope.Complete(); } } else { throw new Exception("renameAndMoveFile returned null or empty string"); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Patterns updatePatternAndProcessFile(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static void updateTank(int TANKID, string TANKNAME, decimal CAPACITY, decimal CURRENTVOL) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; if (CAPACITY <= 0) { throw new Exception("Max capacity can not be 0."); } else if (CAPACITY < CURRENTVOL) { throw new Exception("Current capacity can not be a greater volume than the max capcity."); } else if (CURRENTVOL < 0) { throw new Exception("Current capacity can not be less than 0."); } sqlCmdText = "UPDATE dbo.Tanks SET TankName = @TankName, TankCapacity = @TankCapacity, CurrentTankVolume = @CurrentTankVolume WHERE TankID = @TankID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@TankName", TANKNAME), new SqlParameter("@TankCapacity", CAPACITY), new SqlParameter("@CurrentTankVolume", CURRENTVOL), new SqlParameter("@TankID", TANKID)); //No errors ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Tanks", "TankName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, TANKNAME.ToString(), null, "TankID", TANKID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Tanks", "TankCapacity", now, zxpUD._uid, ChangeLog.ChangeLogDataType.DECIMAL, CAPACITY.ToString(), null, "TankID", TANKID.ToString()); cl.CreateChangeLogEntryIfChanged(); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Tanks updateTank(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static int insertPatternToDBEntry(string FILENAMEOLD, string FILENAMENEW, string FILEPATH, string PATTERNNAME) { Int32 patternID = 0; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "INSERT INTO dbo.Patterns (FileNameOld, FileNameNew, FilePath, PatternName, isHidden) VALUES (@FileNameOld, @FileNameNew, @FilePath, @PatternName, 'false'); " + "SELECT CAST(scope_identity() AS int)"; patternID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@FileNameOld", FILENAMEOLD), new SqlParameter("@FileNameNew", FILENAMENEW), new SqlParameter("@FilePath", FILEPATH), new SqlParameter("@PatternName", PATTERNNAME))); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FileNameOld", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FILENAMEOLD.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FileNameNew", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FILENAMENEW.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FilePath", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FILEPATH.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "PatternName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, PATTERNNAME.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "isHidden", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, "'false'", null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Patterns insertPatternToDBEntry(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(patternID); }
public static void updatePatternName(int PATTERNID, string PATTERNNAME) { int rowCount; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "SELECT COUNT (*) FROM dbo.Patterns " + "WHERE PatternName = @PatternName AND isHidden = 'false' AND PatternID != @PatternID"; rowCount = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PatternName", PATTERNNAME), new SqlParameter("@PatternID", PATTERNID))); if (rowCount <= 0) { ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Patterns", "PatternName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, PATTERNNAME.ToString(), null, "PatternID", PATTERNID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Patterns SET PatternName = @PatternName WHERE PatternID = @PatternID"; SqlHelper.ExecuteNonQuery(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PatternName", PATTERNNAME), new SqlParameter("@PatternID", PATTERNID)); } else { throw new Exception("Pattern name already exist"); } scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Patterns updatePatternName(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }
public static int setNewUserAlert(int USERID, int ALERTID, int ALERTTYPE) { Int32 userAlertID = 0; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "INSERT INTO dbo.UserAlerts (UserID, AlertID, AlertType, isDisabled) VALUES (@UserID, @AlertID, @AlertType, 'false')" + "SELECT CAST(scope_identity() AS int)"; userAlertID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@UserID", USERID), new SqlParameter("@AlertID", ALERTID), new SqlParameter("@AlertType", ALERTTYPE))); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "UserAlerts", "UserID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, USERID.ToString(), null, "AlertUserID", userAlertID.ToString(), "UserID", zxpUD._uid.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "UserAlerts", "AlertID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, ALERTID.ToString(), null, "AlertUserID", userAlertID.ToString(), "UserID", zxpUD._uid.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "UserAlerts", "AlertType", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, ALERTTYPE.ToString(), null, "AlertUserID", userAlertID.ToString(), "UserID", zxpUD._uid.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "UserAlerts", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'false'", null, "AlertUserID", userAlertID.ToString(), "UserID", zxpUD._uid.ToString()); cl.CreateChangeLogEntryIfChanged(); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_UserAlerts setNewUserAlert(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(userAlertID); }
public static Object setNewPatternAndProcessFile(string PATTERNNAME, string FILENAME) { Int32 patternID = 0; List <string> data = new List <string>(); Int32 rowCount; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); string[] newFileAndPath = TransportHelperFunctions.ProcessFileAndData(FILENAME, "PATTERN"); if (2 == newFileAndPath.Length) { using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; sqlCmdText = "SELECT COUNT (*) FROM dbo.Patterns " + "WHERE PatternName = @PatternName AND isHidden = 'false'"; rowCount = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@PatternName", PATTERNNAME))); if (rowCount <= 0) { sqlCmdText = "INSERT INTO dbo.Patterns (FileNameOld, FileNameNew, FilePath, PatternName, isHidden) VALUES (@FileNameOld, @FileNameNew, @FilePath, @PatternName, 'false'); " + "SELECT CAST(scope_identity() AS int)"; patternID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@FileNameOld", FILENAME), new SqlParameter("@FileNameNew", newFileAndPath[1]), new SqlParameter("@FilePath", newFileAndPath[0]), new SqlParameter("@PatternName", PATTERNNAME))); ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "isHidden", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'false'", null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FileNameOld", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FILENAME.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FileNameNew", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, newFileAndPath[1].ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "PatternName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, PATTERNNAME.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Patterns", "FilePath", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, PATTERNNAME.ToString(), null, "PatternID", patternID.ToString()); cl.CreateChangeLogEntryIfChanged(); data.Add(patternID.ToString()); data.Add(newFileAndPath[0]); data.Add(newFileAndPath[1]); } else { throw new Exception("Pattern name already exist"); } scope.Complete(); } } else { throw new Exception("renameAndMoveFile returned null or empty string"); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Patterns setNewPatternAndProcessFile(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(data); }
public static int setNewTank(string TANKNAME, decimal CAPACITY, decimal CURRENTVOL) { Int32 tankID = 0; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { string sqlCmdText; //sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; if (CAPACITY <= 0) { throw new Exception("Max capacity can not be 0."); } else if (CAPACITY < CURRENTVOL) { throw new Exception("Current capacity can not be a greater volume than the max capcity."); } else if (CURRENTVOL < 0) { throw new Exception("Current capacity can not be less than 0."); } //checks to see if a tank with that name exsist sqlCmdText = "SELECT COUNT(*) FROM dbo.Tanks WHERE (TankName = @TankName) AND (isDisabled = 'false')"; int tankCount = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@TankName", TANKNAME))); //checks to see if tank exists if (tankCount == 0) { //if it doesnt exist, go ahead and create tank sqlCmdText = "INSERT INTO dbo.Tanks (TankName, TankCapacity, CurrentTankVolume, isDisabled) VALUES (@TankName, @TankCapacity, @CurrentVol, 'false'); " + "SELECT CAST(scope_identity() AS int)"; tankID = Convert.ToInt32(SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@TankName", TANKNAME), new SqlParameter("@TankCapacity", CAPACITY), new SqlParameter("@CurrentVol", CURRENTVOL))); } else {//if it does exist, throw exception throw new Exception("A tank by that name already exist"); } ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Tanks", "TankName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, TANKNAME.ToString(), null, "TankID", tankID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Tanks", "TankCapacity", now, zxpUD._uid, ChangeLog.ChangeLogDataType.DECIMAL, CAPACITY.ToString(), null, "TankID", tankID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Tanks", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'false'", null, "TankID", tankID.ToString()); cl.CreateChangeLogEntryIfChanged(); scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Tanks setNewTank(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } return(tankID); }
public static void updateProduct(int CUSTOMERPROUDCTID, string PRODUCTID_CMS, string CUSTOMERID_CMS) { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); int rowCount = 0; DateTime now = DateTime.Now; try { using (var scope = new TransactionScope()) { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); sqlConn = new SqlConnection(); sqlCmd = new SqlCommand(); sqlConn = new SqlConnection(sql_connStr); if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } //Connects to DB sqlCmd.Connection = sqlConn; SqlParameter paramProductID_CMS = new SqlParameter("@ProductID_CMS", SqlDbType.Char); SqlParameter paramCustomerProductID = new SqlParameter("@CustomerProductID", SqlDbType.Int); SqlParameter paramCustomerID_CMS = new SqlParameter("@CustomerID_CMS", SqlDbType.Char); paramCustomerProductID.Value = CUSTOMERPROUDCTID; paramProductID_CMS.Value = PRODUCTID_CMS; paramCustomerID_CMS.Value = CUSTOMERID_CMS; sqlCmd.Parameters.Clear(); sqlCmd.Parameters.Add(paramCustomerProductID); sqlCmd.Parameters.Add(paramProductID_CMS); sqlCmd.Parameters.Add(paramCustomerID_CMS); sqlCmd.CommandText = "SELECT COUNT(*) FROM dbo.CustomersVendorsProducts as CVP " + "WHERE (CVP.CustomerID_CMS = @CustomerID_CMS AND CVP.ProductID_CMS = @ProductID_CMS AND CVP.isDisabled = 'false')"; rowCount = (int)sqlCmd.ExecuteScalar(); if (rowCount == 0) { ///////////////////////////////David 4-20-16 ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "CustomersVendorsProducts", "PRODUCTID_CMS", now, zxpUD._uid, ChangeLog.ChangeLogDataType.CHAR, CUSTOMERID_CMS.ToString(), null, "CustomerProductID", CUSTOMERPROUDCTID.ToString()); cl.CreateChangeLogEntryIfChanged(sqlConn); ////////////////////////////////////// sqlCmd.CommandText = "UPDATE dbo.CustomersVendorsProducts SET PRODUCTID_CMS = @PRODUCTID_CMS WHERE CustomerProductID = @CustomerProductID"; sqlCmd.ExecuteNonQuery(); } else {//if it does exist, throw exception throw new Exception("This product already exist with this customer"); } scope.Complete(); } } catch (SqlException excep) { string strErr = " SQLException Error in Admin_CustomerVendorProducts updateProduct(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in Admin_CustomerVendorProducts updateProduct(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } finally { if (sqlConn != null && sqlConn.State != ConnectionState.Closed) { sqlConn.Close(); sqlConn.Dispose(); } } } //end of updateProduct(int CUSTOMERPROUDCTID, string PRODUCTID_CMS)
public static void disableCustomer(string CUSTOMERID) { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { // TransactionScope scope = new TransactionScope(); sqlConn = new SqlConnection(); sqlCmd = new SqlCommand(); sqlConn = new SqlConnection(sql_connStr); sqlConn.Open(); SqlParameter paramCustomerID_CMS = new SqlParameter("@CustomerID_CMS", SqlDbType.Char); paramCustomerID_CMS.Value = CUSTOMERID; sqlCmd.Parameters.Clear(); sqlCmd.Parameters.Add(paramCustomerID_CMS); //connects to DB sqlCmd.Connection = sqlConn; sqlCmd.CommandText = "UPDATE dbo.CustomersVendorsProducts " + "SET isDisabled = 'true' " + "WHERE CustomerID_CMS = @CustomerID_CMS"; ///////////////////////////////David 4-20-16 ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "CustomersVendorsProducts", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'true'", null, "CustomerProductID", CUSTOMERID.ToString()); cl.CreateChangeLogEntryIfChanged(sqlConn); ////////////////////////////////////// sqlCmd.ExecuteNonQuery(); scope.Complete(); } }//end of try catch (SqlException excep) { string strErr = " SQLException Error in Admin_CustomerVendorProducts disableCustomer(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in Admin_CustomerVendorProducts disableCustomer(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } finally { if (sqlConn != null && sqlConn.State != ConnectionState.Closed) { sqlConn.Close(); sqlConn.Dispose(); } } }//end of disableCustomer(string CUSTOMERID)
public static int setNewProductToCustomer(string CUSTOMERID_CMS, string PRODUCTID_CMS) { SqlConnection sqlConn = new SqlConnection(); SqlCommand sqlCmd = new SqlCommand(); Int32 CustProd_ComboID = 0; int rowCount = 0; DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); using (var scope = new TransactionScope()) { sqlConn = new SqlConnection(); sqlCmd = new SqlCommand(); sqlConn = new SqlConnection(sql_connStr); if (sqlConn.State != ConnectionState.Open) { sqlConn.Open(); } //Connects to DB sqlCmd.Connection = sqlConn; SqlParameter paramCustomerID_CMS = new SqlParameter("@CustomerID_CMS", SqlDbType.Char); SqlParameter paramProductID_CMS = new SqlParameter("@ProductID_CMS", SqlDbType.Char); paramCustomerID_CMS.Value = CUSTOMERID_CMS; paramProductID_CMS.Value = PRODUCTID_CMS; sqlCmd.Parameters.Clear(); sqlCmd.Parameters.Add(paramCustomerID_CMS); sqlCmd.Parameters.Add(paramProductID_CMS); sqlCmd.CommandText = "SELECT COUNT(*) FROM dbo.CustomersVendorsProducts as CVP " + "WHERE (CVP.CustomerID_CMS = @CustomerID_CMS AND CVP.ProductID_CMS = @ProductID_CMS AND CVP.isDisabled = 'false')"; rowCount = (int)sqlCmd.ExecuteScalar(); if (rowCount == 0) { sqlCmd.CommandText = "INSERT INTO dbo.CustomersVendorsProducts (CustomerID_CMS, ProductID_CMS, isDisabled) " + "VALUES (@CustomerID_CMS, @ProductID_CMS, 'false'); " + "SELECT CAST(scope_identity() AS int)"; CustProd_ComboID = (int)sqlCmd.ExecuteScalar(); ///////////////////////////////David 4-20-16 ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "CustomersVendorsProducts", "CustomerID_CMS", now, zxpUD._uid, ChangeLog.ChangeLogDataType.CHAR, CUSTOMERID_CMS.ToString(), null, "CustomerProductID", CustProd_ComboID.ToString()); cl.CreateChangeLogEntryIfChanged(sqlConn); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "CustomersVendorsProducts", "ProductID_CMS", now, zxpUD._uid, ChangeLog.ChangeLogDataType.CHAR, PRODUCTID_CMS.ToString(), null, "CustomerProductID", CustProd_ComboID.ToString()); cl.CreateChangeLogEntryIfChanged(sqlConn); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "CustomersVendorsProducts", "isDisabled", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, "'false'", null, "CustomerProductID", CustProd_ComboID.ToString()); cl.CreateChangeLogEntryIfChanged(sqlConn); //////////////////////////////////////////// } else { throw new Exception("This product already exist with this customer"); } scope.Complete(); } } catch (SqlException excep) { string strErr = " SQLException Error in Admin_CustomerVendorProducts setNewProductToCustomer(). Details: " + excep.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 2; ErrorLogging.sendtoErrorPage(2); } catch (Exception ex) { string strErr = " Exception Error in Admin_CustomerVendorProducts setNewProductToCustomer(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); } finally { if (sqlConn != null && sqlConn.State != ConnectionState.Closed) { sqlConn.Close(); sqlConn.Dispose(); } } return((int)CustProd_ComboID); } //end of setNewProductToCustomer(string CUSTOMERID_CMS, int PRODUCTID_CMS)
public static void updateUser(int USERID, string USERNAME, string FIRSTNAME, string LASTNAME, string EMAIL, string CELLPHONENUMBER, int?CELLPHONEPROVIDER, bool ADMIN, bool DOCKMANAGER, bool INSPECTOR, bool GUARD, bool LABPERSONEL, bool LOADER, bool YARDMULE, bool LABADMIN, bool REPORTER, bool ACCTMANAGER) { DateTime now = DateTime.Now; try { ZXPUserData zxpUD = ZXPUserData.GetZXPUserDataFromCookie(); string sql_connStr = new TruckScheduleConfigurationKeysHelper().sql_connStr; using (var scope = new TransactionScope()) { string sqlCmdText; if (CELLPHONENUMBER == null && CELLPHONEPROVIDER == null) { ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "UserName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, USERNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "FirstName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FIRSTNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "LastName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, LASTNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "EmailAddress", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, EMAIL.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isAdmin", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, ADMIN.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isDockManager", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, DOCKMANAGER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isInspector", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, INSPECTOR.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isGuard", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, GUARD.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLabPersonel", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LABPERSONEL.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLoader", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LOADER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isYardMule", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, YARDMULE.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "canViewReports", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, REPORTER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLabAdmin", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LABADMIN.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Users", "isAccountManager", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, ACCTMANAGER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "Phone", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, "NULL", null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "CellProviderID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, "NULL", null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Users SET UserName = @UserName, FirstName = @FirstName, LastName = @LastName, EmailAddress = @EmailAddress, isAdmin = @isAdmin, isDockManager = @isDockManager, isInspector = @isInspector, " + "isGuard = @isGuard, isLabPersonel = @isLabPersonel, isLoader = @isLoader, isYardMule = @isYardMule, isLabAdmin = @isLabAdmin, canViewReports = @canViewReports, isAccountManager = @isAccountManager, " + "Phone = null, CellProviderID = null WHERE UserID = @UserID"; SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@UserName", USERNAME), new SqlParameter("@FirstName", FIRSTNAME), new SqlParameter("@LastName", LASTNAME), new SqlParameter("@EmailAddress", EMAIL), new SqlParameter("@Password", DataTransformer.PasswordHash("ZXPpassword1!")), new SqlParameter("@isAdmin", ADMIN), new SqlParameter("@isDockManager", DOCKMANAGER), new SqlParameter("@isInspector", INSPECTOR), new SqlParameter("@isGuard", GUARD), new SqlParameter("@isLabPersonel", LABPERSONEL), new SqlParameter("@isLoader", LOADER), new SqlParameter("@isYardMule", YARDMULE), new SqlParameter("@canViewReports", REPORTER), new SqlParameter("@isLabAdmin", LABADMIN), new SqlParameter("@isAccountManager", ACCTMANAGER), new SqlParameter("@UserID", USERID)); } else if (CELLPHONEPROVIDER != null && CELLPHONENUMBER != null) { ChangeLog cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "UserName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, USERNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "FirstName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, FIRSTNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "LastName", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, LASTNAME.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "EmailAddress", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, EMAIL.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isAdmin", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, ADMIN.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isDockManager", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, DOCKMANAGER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isInspector", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, INSPECTOR.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isGuard", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, GUARD.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLabPersonel", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LABPERSONEL.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLoader", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LOADER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isYardMule", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, YARDMULE.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "canViewReports", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, REPORTER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "isLabAdmin", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, LABADMIN.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.INSERT, "Users", "isAccountManager", now, zxpUD._uid, ChangeLog.ChangeLogDataType.BIT, ACCTMANAGER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "Phone", now, zxpUD._uid, ChangeLog.ChangeLogDataType.NVARCHAR, CELLPHONENUMBER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); cl = new ChangeLog(ChangeLog.ChangeLogChangeType.UPDATE, "Users", "CellProviderID", now, zxpUD._uid, ChangeLog.ChangeLogDataType.INT, CELLPHONEPROVIDER.ToString(), null, "UserID", USERID.ToString()); cl.CreateChangeLogEntryIfChanged(); sqlCmdText = "UPDATE dbo.Users SET UserName = @UserName, FirstName = @FirstName, LastName = @LastName, EmailAddress = @EmailAddress, Phone = @Phone, CellProviderID = @CellProviderID, " + "isAdmin = @isAdmin, isDockManager = @isDockManager, isInspector = @isInspector, isGuard = @isGuard, isLabPersonel = @isLabPersonel, isLoader = @isLoader, isYardMule = @isYardMule, " + "isLabAdmin = @isLabAdmin, canViewReports = @canViewReports, isAccountManager = @isAccountManager WHERE UserID = @UserID"; SqlHelper.ExecuteScalar(sql_connStr, CommandType.Text, sqlCmdText, new SqlParameter("@UserName", USERNAME), new SqlParameter("@FirstName", FIRSTNAME), new SqlParameter("@LastName", LASTNAME), new SqlParameter("@EmailAddress", EMAIL), new SqlParameter("@Phone", CELLPHONENUMBER), new SqlParameter("@CellProviderID", CELLPHONEPROVIDER), new SqlParameter("@Password", DataTransformer.PasswordHash("ZXPpassword1!")), new SqlParameter("@isAdmin", ADMIN), new SqlParameter("@isDockManager", DOCKMANAGER), new SqlParameter("@isInspector", INSPECTOR), new SqlParameter("@isGuard", GUARD), new SqlParameter("@isLabPersonel", LABPERSONEL), new SqlParameter("@isLoader", LOADER), new SqlParameter("@isYardMule", YARDMULE), new SqlParameter("@canViewReports", REPORTER), new SqlParameter("@isLabAdmin", LABADMIN), new SqlParameter("@isAccountManager", ACCTMANAGER), new SqlParameter("@UserID", USERID)); } else if (CELLPHONEPROVIDER == null && CELLPHONENUMBER != null) { throw new Exception("Trying to add a cell phone provider without a cell phone number to a user."); } else if (CELLPHONEPROVIDER != null && CELLPHONENUMBER == null) { throw new Exception("Trying to add a cell phone number without a cell phone provider to a user."); } else { throw new Exception("Username already exists"); } scope.Complete(); } } catch (Exception ex) { string strErr = " Exception Error in Admin_Users updateUser(). Details: " + ex.ToString(); ErrorLogging.WriteEvent(strErr, EventLogEntryType.Error); System.Web.HttpContext.Current.Session["ErrorNum"] = 1; ErrorLogging.sendtoErrorPage(1); throw ex; } }