Ejemplo n.º 1
0
        public static string UpdateCustomer(int ID, string FirstName, string LastName, string Phone, string City)
        {
            try
            {
                DataGateWay access = new DataGateWay(connectionName);

                string sql = @"use InlandMarina
                           UPDATE Customer
                           SET FirstName = @FirstName,
                               LastName = @LastName,
                               Phone = @Phone,
                               City = @City
                           WHERE ID = @Id";

                IDataParameter IdPar = access.CreateParameter;
                IdPar.ParameterName = "@Id";
                IdPar.DbType        = DbType.Int32;
                IdPar.Value         = ID;

                IDataParameter firstnamePar = access.CreateParameter;
                firstnamePar.ParameterName = "@FirstName";
                firstnamePar.DbType        = DbType.String;
                firstnamePar.Value         = FirstName;

                IDataParameter lastnamePar = access.CreateParameter;
                lastnamePar.ParameterName = "@LastName";
                lastnamePar.DbType        = DbType.String;
                lastnamePar.Value         = LastName;

                IDataParameter PhonePar = access.CreateParameter;
                PhonePar.ParameterName = "@Phone";
                PhonePar.DbType        = DbType.String;
                PhonePar.Value         = Phone;

                IDataParameter CityPar = access.CreateParameter;
                CityPar.ParameterName = "@City";
                CityPar.DbType        = DbType.String;
                CityPar.Value         = City;

                IDataParameter[] pars =
                    new IDataParameter[] { IdPar, firstnamePar, lastnamePar, PhonePar, CityPar };

                access.ExecuteNonQuery(sql, pars, CommandType.Text);

                return("Success");
            }
            catch
            {
                return("Update failed ! Please contact Administrator !");
            }
        }
Ejemplo n.º 2
0
        public static string UpdateBoat(int ID, string RegistrationNumber, string Manufacturer, int ModelYear, int Length)
        {
            try
            {
                DataGateWay access = new DataGateWay(connectionName);

                string sql = @"use InlandMarina
                           UPDATE Boat
                           SET RegistrationNumber = @RegistrationNumber,
                               Manufacturer = @LastName,
                               ModelYear = @Phone,
                               Length = @City
                           WHERE ID = @ID";

                IDataParameter RegisterNoPar = access.CreateParameter;
                RegisterNoPar.ParameterName = "@RegistrationNumber";
                RegisterNoPar.DbType        = DbType.String;
                RegisterNoPar.Value         = RegistrationNumber;

                IDataParameter ManufacturerPar = access.CreateParameter;
                ManufacturerPar.ParameterName = "@Manufacturer";
                ManufacturerPar.DbType        = DbType.String;
                ManufacturerPar.Value         = Manufacturer;

                IDataParameter YearPar = access.CreateParameter;
                YearPar.ParameterName = "@ModelYear";
                YearPar.DbType        = DbType.Int32;
                YearPar.Value         = ModelYear;

                IDataParameter LengthPar = access.CreateParameter;
                LengthPar.ParameterName = "@Length";
                LengthPar.DbType        = DbType.Int32;
                LengthPar.Value         = Length;

                IDataParameter CustIDPar = access.CreateParameter;
                CustIDPar.ParameterName = "@ID";
                CustIDPar.DbType        = DbType.Int32;
                CustIDPar.Value         = ID;

                IDataParameter[] pars =
                    new IDataParameter[] { RegisterNoPar, ManufacturerPar, YearPar, LengthPar, CustIDPar };

                access.ExecuteNonQuery(sql, pars, CommandType.Text);
                return("Success");
            }
            catch
            {
                return("Failed to update record ! Please contact Administrator !");
            }
        }
Ejemplo n.º 3
0
        public static string AddLease(DateTime startDate, DateTime endDate, int slipID, int customerID, int leaseTypeID)
        {
            try
            {
                DataGateWay access = new DataGateWay(connectionName);

                string sql = @"use InlandMarina
                           INSERT INTO Lease(StartDate,EndDate,SlipID,CustomerID,LeaseTypeID)
                           VALUES(@StartDate,@EndDate,@SlipID,@CustomerID,@LeaseTypeID)";

                IDataParameter StartDatePar = access.CreateParameter;
                StartDatePar.ParameterName = "@StartDate";
                StartDatePar.DbType        = DbType.DateTime;
                StartDatePar.Value         = startDate;

                IDataParameter EndDatePar = access.CreateParameter;
                EndDatePar.ParameterName = "@EndDate";
                EndDatePar.DbType        = DbType.DateTime;
                EndDatePar.Value         = endDate;

                IDataParameter SlipPar = access.CreateParameter;
                SlipPar.ParameterName = "@SlipID";
                SlipPar.DbType        = DbType.Int32;
                SlipPar.Value         = slipID;

                IDataParameter CustomerIDPar = access.CreateParameter;
                CustomerIDPar.ParameterName = "@CustomerID";
                CustomerIDPar.DbType        = DbType.Int32;
                CustomerIDPar.Value         = customerID;

                IDataParameter LeaseTypePar = access.CreateParameter;
                LeaseTypePar.ParameterName = "@LeaseTypeID";
                LeaseTypePar.DbType        = DbType.Int32;
                LeaseTypePar.Value         = leaseTypeID;

                IDataParameter[] pars =
                    new IDataParameter[] { StartDatePar, EndDatePar, SlipPar, CustomerIDPar, LeaseTypePar };

                access.ExecuteNonQuery(sql, pars, CommandType.Text);
                return("Success");
            }
            catch
            {
                return("Failed to add record ! Please contact Administrator !");
            }
        }
Ejemplo n.º 4
0
        public static string AddBoat(string registerNumber, string manufacturer, int modelYear, int length, int customerID)
        {
            try
            {
                DataGateWay access = new DataGateWay(connectionName);

                string sql = @"use InlandMarina
                               INSERT INTO Boat(RegistrationNumber,Manufacturer,ModelYear,Length,CustomerID)
                               VALUES(@RegistrationNumber,@Manufacturer,@ModelYear,@Length,@CustomerID)";

                IDataParameter RegisterNoPar = access.CreateParameter;
                RegisterNoPar.ParameterName = "@RegistrationNumber";
                RegisterNoPar.DbType        = DbType.String;
                RegisterNoPar.Value         = registerNumber;

                IDataParameter ManufacturerPar = access.CreateParameter;
                ManufacturerPar.ParameterName = "@Manufacturer";
                ManufacturerPar.DbType        = DbType.String;
                ManufacturerPar.Value         = manufacturer;

                IDataParameter YearPar = access.CreateParameter;
                YearPar.ParameterName = "@ModelYear";
                YearPar.DbType        = DbType.Int32;
                YearPar.Value         = modelYear;

                IDataParameter LengthPar = access.CreateParameter;
                LengthPar.ParameterName = "@Length";
                LengthPar.DbType        = DbType.Int32;
                LengthPar.Value         = length;

                IDataParameter CustIDPar = access.CreateParameter;
                CustIDPar.ParameterName = "@CustomerID";
                CustIDPar.DbType        = DbType.Int32;
                CustIDPar.Value         = customerID;

                IDataParameter[] pars =
                    new IDataParameter[] { RegisterNoPar, ManufacturerPar, YearPar, LengthPar, CustIDPar };

                access.ExecuteNonQuery(sql, pars, CommandType.Text);
                return("Success");
            }
            catch
            {
                return("Failed to add record ! Please contact Administrator !");
            }
        }
Ejemplo n.º 5
0
        public static string UpdateAuthorize(string username, string password, int CustomerID)
        {
            try
            {
                DataGateWay access = new DataGateWay(connectionName);

                string sql = @"use InlandMarina
                           UPDATE Authorize
                           SET UserName = @UserName,
                               Password = @Password
                           WHERE CustomerID = @CustomerID";

                IDataParameter UserNamePar = access.CreateParameter;
                UserNamePar.ParameterName = "@UserName";
                UserNamePar.DbType        = DbType.String;
                UserNamePar.Value         = username;

                IDataParameter PasswordPar = access.CreateParameter;
                PasswordPar.ParameterName = "@Password";
                PasswordPar.DbType        = DbType.String;
                PasswordPar.Value         = password;

                IDataParameter CustomerPar = access.CreateParameter;
                CustomerPar.ParameterName = "@CustomerID";
                CustomerPar.DbType        = DbType.Int32;
                CustomerPar.Value         = CustomerID;

                IDataParameter[] pars =
                    new IDataParameter[] { UserNamePar, PasswordPar, CustomerPar };

                access.ExecuteNonQuery(sql, pars, CommandType.Text);
                return("Success");
            }
            catch
            {
                return("Failed to update record ! Please contact Administrator !");
            }
        }