public bool Reserve(Customer customer, Car car) { DBConnect objDB = new DBConnect(); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "InsertCustomer"; objCommand.Parameters.AddWithValue("@firstName", customer.firstName); objCommand.Parameters.AddWithValue("@lastName", customer.lastName); objCommand.Parameters.AddWithValue("@age", customer.age); objCommand.Parameters.AddWithValue("@email", customer.email); objCommand.Parameters.AddWithValue("@address", customer.address); objCommand.Parameters.AddWithValue("@phoneNumber", customer.phoneNumber); objDB.DoUpdateUsingCmdObj(objCommand); SqlCommand objCommandReserve = new SqlCommand(); objCommandReserve.CommandType = CommandType.StoredProcedure; objCommandReserve.CommandText = "Reserve"; objCommandReserve.Parameters.AddWithValue("@carID", car.carID); int result = objDB.DoUpdateUsingCmdObj(objCommandReserve); if (!(result <= 0)) { return(true); } else { return(false); } }
public Boolean AddNewUser(int ID, string firstName, string lastName, string email, string password, string type) { newCommand.Parameters.Clear(); newCommand.CommandType = CommandType.StoredProcedure; newCommand.CommandText = "TermProjectAddNewUser"; UserParameter = new SqlParameter("@ID", ID); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.Int; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); UserParameter = new SqlParameter("@firstName", firstName); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.VarChar; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); UserParameter = new SqlParameter("@lastName", lastName); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.VarChar; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); UserParameter = new SqlParameter("@email", email); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.VarChar; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); UserParameter = new SqlParameter("@password", password); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.VarChar; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); UserParameter = new SqlParameter("@usertype", type); UserParameter.Direction = ParameterDirection.Input; UserParameter.SqlDbType = SqlDbType.VarChar; UserParameter.Size = 50; newCommand.Parameters.Add(UserParameter); int flag = myDB.DoUpdateUsingCmdObj(newCommand); if (flag == -1) { return(false); } else { return(true); } }
public bool AddUser(User newUser) { SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "AddUser"; objCommand.Parameters.AddWithValue("@firstName", newUser.firstName); objCommand.Parameters.AddWithValue("@lastName", newUser.lastName); objCommand.Parameters.AddWithValue("@email", newUser.email); int hashPass = newUser.password.GetHashCode(); objCommand.Parameters.AddWithValue("@password", hashPass.ToString()); DBConnect objDB = new DBConnect(); int result = objDB.DoUpdateUsingCmdObj(objCommand); if (!(result <= 0)) { return(true); } else { return(false); } }
public String UpdateAccount(DataSet objDS, int UserID) { String strStatus; //DataSet objDS = GetUserByLoginIDandPass(objAccount.UserLoginID, objAccount.UserPassword); Byte[] byteArray = SerializeData(objDS); // Update the account to store the serialized object (binary data) in the database objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "StoreAccount"; objCommand.Parameters.Clear(); objCommand.Parameters.AddWithValue("@UserID", UserID); objCommand.Parameters.AddWithValue("@Account", byteArray); int returnValue = objDB.DoUpdateUsingCmdObj(objCommand); // Check to see whether the update was successful if (returnValue > 0) { strStatus = "The account was successfully stored for this user."; } else { strStatus = "A problem occured in storing the account info."; } return(strStatus); }
public bool Reserve(Customer customer, Car car) { DBConnect objDB = new DBConnect(); SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "InsertCustomer"; objCommand.Parameters.AddWithValue("@firstName", customer.firstName); objCommand.Parameters.AddWithValue("@lastName", customer.lastName); objCommand.Parameters.AddWithValue("@age", customer.age); objCommand.Parameters.AddWithValue("@email", customer.email); objCommand.Parameters.AddWithValue("@address", customer.address); objCommand.Parameters.AddWithValue("@phoneNumber", customer.phoneNumber); objDB.DoUpdateUsingCmdObj(objCommand); SqlCommand objCommandReserve = new SqlCommand(); objCommandReserve.CommandType = CommandType.StoredProcedure; objCommandReserve.CommandText = "Reserve"; objCommandReserve.Parameters.AddWithValue("@carID", car.carID); int result = objDB.DoUpdateUsingCmdObj(objCommandReserve); if (!(result <= 0)) return true; else return false; }
public bool AddFile(Byte[] input, int userID, string fileName, string fileType, int fileSize) { DBConnect objDB = new DBConnect(); SqlCommand objCommand = new SqlCommand(); bool result = false; // Serialize the input file (input) BinaryFormatter serializer = new BinaryFormatter(); MemoryStream memStream = new MemoryStream(); Byte[] byteArray; serializer.Serialize(memStream, input); byteArray = memStream.ToArray(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "AddFile"; objCommand.Parameters.Clear(); objCommand.Parameters.AddWithValue("@inputData", input); SqlParameter inputParameter = new SqlParameter("@userID", userID); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.Int; inputParameter.Size = 100; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@fileName", fileName); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; inputParameter.Size = 8000; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@fileType", fileType); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; inputParameter.Size = 8000; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@fileSize", fileSize); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.Int; inputParameter.Size = 8000; objCommand.Parameters.Add(inputParameter); int returnValue = objDB.DoUpdateUsingCmdObj(objCommand); if (returnValue != -1) { result = true; return(result); } else { return(result); } }
public Boolean Reserve(Agency objAgency, Car objCar, Customer objCustomer, int TravelSiteID, string TravelSitePassword) { int ID = 456789; string Password = "******"; if (ID == TravelSiteID && Password == TravelSitePassword) { objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "Reserve"; SqlParameter inputParameter = new SqlParameter("@AgencyID", objAgency.ID); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.Int; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@AgencyName", objAgency.Name); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@CarID", objCar.ID); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.Int; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@CarName", objCar.Name); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@CustomerID", objCustomer.ID); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@CustomerName", objCustomer.Name); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter); inputParameter = new SqlParameter("@PhoneNumber", objCustomer.PhoneNumber); inputParameter.Direction = ParameterDirection.Input; inputParameter.SqlDbType = SqlDbType.VarChar; objCommand.Parameters.Add(inputParameter); objDB.DoUpdateUsingCmdObj(objCommand); return(true); } else { return(false); } }
public bool AddUser(User newUser) { SqlCommand objCommand = new SqlCommand(); objCommand.CommandType = CommandType.StoredProcedure; objCommand.CommandText = "AddUser"; objCommand.Parameters.AddWithValue("@firstName", newUser.firstName); objCommand.Parameters.AddWithValue("@lastName", newUser.lastName); objCommand.Parameters.AddWithValue("@email", newUser.email); int hashPass = newUser.password.GetHashCode(); objCommand.Parameters.AddWithValue("@password", hashPass.ToString()); DBConnect objDB = new DBConnect(); int result = objDB.DoUpdateUsingCmdObj(objCommand); if (!(result <= 0)) return true; else return false; }