示例#1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            CustomerResource customer = new CustomerResource();
            customer.CustomerId = this.customer.CustomerId;
            customer.Title = TitleComboBox.Text;
            customer.FirstName = FirstNameTextBox.Text;
            customer.MiddleName = MiddleNameTextBox.Text;
            customer.LastName = LastNameTextBox.Text;
            customer.Address = AddressTextBox.Text;
            customer.Address2 = Address2TextBox.Text;
            customer.City = CityTextBox.Text;
            customer.State = StateTextBox.Text;
            customer.Zip = ZipTextBox.Text;
            customer.Telephone = PhoneTextBox.Text;
            customer.Email = EmailTextBox.Text;

            CustomerRepository repo = new CustomerRepository();
            try
            {
                repo.UpdateCustomer(customer);
                if (alterationFormCallback != null)
                {
                    alterationFormCallback(customer);
                }
                this.Close();
            }
            catch
            {
                MessageBox.Show("There was an error saving the customer. Please check the fields and try again");
            }
        }
示例#2
0
        public AlterationForm(CustomerResource customer)
        {
            Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            ConfigurationRepository configRepo = new ConfigurationRepository();
            maxAlterations = Convert.ToDouble(configRepo.GetConfigrationSettings().Where(x => x.Setting == "maxAlterations").Select(x => x.Value).DefaultIfEmpty("").First());
            TicketRepository ticketRepo = new TicketRepository();
            alterationToatalForDays = ticketRepo.GetAlterationToatalForDays();
            SetupForm();
            this.customer = customer;
            customerId = customer.CustomerId;
            isNewAlteration = true;
            TicketNumberLabel.Hide();
            DateInPicker.Value = DateTime.Today;
            var readyDate = GetNextValidDateNotOverMaxAlterations(DateTime.Today.AddDays(7));
            DateReadyPicker.Value = readyDate;
            previousStatus = "a";
            NewTicketWithCustomerBttn.Enabled = false;

            TitleComboBox.Text = customer.Title;
            FirstNameTextBox.Text = customer.FirstName;
            MiddleNameTextBox.Text = customer.MiddleName;
            LastNameTextBox.Text = customer.LastName;
            AddressTextBox.Text = customer.Address;
            CityTextBox.Text = customer.City;
            StateTextBox.Text = customer.State;
            ZipTextBox.Text = customer.Zip;
            PhoneTextBox.Text = customer.Telephone;
            EmailTextBox.Text = customer.Email;
        }
示例#3
0
        private void AddCustomerButton_Click(object sender, EventArgs e)
        {
            if (!validateForm())
            {
                return;
            }
            CustomerResource customer = new CustomerResource();
            customer.Title = TitleComboBox.Text ?? "";
            customer.FirstName = FirstNameTextBox.Text ?? "";
            customer.MiddleName = MiddleNameTextBox.Text ?? "";
            customer.LastName = LastNameTextBox.Text ?? "";
            customer.Address = AddressTextBox.Text ?? "";
            customer.Address2 = Address2TextBox.Text ?? "";
            customer.City = CityTextBox.Text ?? "";
            customer.State = StateTextBox.Text ?? "";
            customer.Zip = ZipTextBox.Text;
            customer.Telephone = PhoneTextBox.Text ?? "";
            customer.Email = EmailTextBox.Text ?? "";

            CustomerRepository repo = new CustomerRepository();
            try
            {
                int custId = repo.InsertCustomer(customer);
                customer.CustomerId = custId;
                CustomerProfile profile = new CustomerProfile(customer);
                profile.Show();
                this.Close();
            }
            catch
            {
                MessageBox.Show("There was an error saving the customer. Please check the fields and try again");
            }
        }
示例#4
0
 public CustomerProfile(CustomerResource customer)
 {
     InitializeComponent();
     this.customer = customer;
     TitleComboBox.Text = customer.Title;
     FirstNameTextBox.Text = customer.FirstName;
     MiddleNameTextBox.Text = customer.MiddleName;
     LastNameTextBox.Text = customer.LastName;
     AddressTextBox.Text = customer.Address;
     Address2TextBox.Text = customer.Address2;
     CityTextBox.Text = customer.City;
     StateTextBox.Text = customer.State;
     ZipTextBox.Text = customer.Zip;
     PhoneTextBox.Text = customer.Telephone;
     EmailTextBox.Text = customer.Email;
 }
示例#5
0
 public ChooseMeasurementModal(CustomerResource customer)
 {
     this.customer = customer;
     InitializeComponent();
 }
示例#6
0
 private void CustomerProfileFinishedEditing(CustomerResource customerResource)
 {
     TitleComboBox.Text = customerResource.Title;
     FirstNameTextBox.Text = customerResource.FirstName;
     MiddleNameTextBox.Text = customerResource.MiddleName;
     LastNameTextBox.Text = customerResource.LastName;
     AddressTextBox.Text = customerResource.Address;
     CityTextBox.Text = customerResource.City;
     StateTextBox.Text = customerResource.State;
     ZipTextBox.Text = customerResource.Zip;
     PhoneTextBox.Text = customerResource.Telephone;
     EmailTextBox.Text = customerResource.Email;
 }
 public CustomerFinishMeasurementsForm(CustomerResource customer)
 {
     this.customer = customer;
     InitializeComponent();
 }
示例#8
0
        public CustomerMeasurementsForm(CustomerResource customer)
        {
            InitializeComponent();
            this.customer = customer;

            Dictionary<String, String> measurements = new Dictionary<String, String>(); //web request for measurements
            string result;

            measurements.TryGetValue("body_chest", out result);
            ChestTextBox.Text = result ?? "";
            measurements.TryGetValue("body_waist", out result);
            WaistTextBox.Text = result ?? "";
            measurements.TryGetValue("body_hips", out result);
            HipsTextBox.Text = result ?? "";
            measurements.TryGetValue("body_shoulders", out result);
            ShouldersTextBox.Text = result ?? "";
            measurements.TryGetValue("body_seat", out result);
            SeatTextBox.Text = result ?? "";
            measurements.TryGetValue("body_crotch", out result);
            CrotchTextBox.Text = result ?? "";
            measurements.TryGetValue("body_actual_thigh", out result);
            ActualThighTextBox.Text = result ?? "";
            measurements.TryGetValue("body_outseam", out result);
            OutseamTextBox.Text = result ?? "";
            measurements.TryGetValue("body_inseam", out result);
            InseamTextBox.Text = result ?? "";
            measurements.TryGetValue("body_sleeve_length", out result);
            SleeveLengthTextBox.Text = result ?? "";
            measurements.TryGetValue("body_shirt_length", out result);
            LengthOfShirtTextBox.Text = result ?? "";
            measurements.TryGetValue("body_wrist", out result);
            WristTextBox.Text = result ?? "";
            measurements.TryGetValue("body_neck", out result);
            NeckSizeTextBox.Text = result ?? "";
            measurements.TryGetValue("body_jacket_length", out result);
            LengthOfJacketTextBox.Text = result ?? "";
            measurements.TryGetValue("body_bicep", out result);
            BicepTextBox.Text = result ?? "";
            measurements.TryGetValue("body_arm_hole", out result);
            ArmHoleTextBox.Text = result ?? "";
            measurements.TryGetValue("body_belly", out result);
            BellyTextBox.Text = result ?? "";

            measurements.TryGetValue("shirt_chest", out result);
            ShirtChestTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_waist", out result);
            ShirtWaistTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_hips", out result);
            ShirtHipsTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_shoulders", out result);
            ShirtShouldersTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_sleeve_length", out result);
            ShirtSleeveLengthTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_shirt_length", out result);
            ShirtLengthOfShirtTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_cuff", out result);
            ShirtCuffTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_neck", out result);
            ShirtNeckTextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_sleeve_6_below", out result);
            ShirtWidth6TextBox.Text = result ?? "";
            measurements.TryGetValue("shirt_sleeve_12_below", out result);
            ShirtWidth12TextBox.Text = result ?? "";

            measurements.TryGetValue("pants_waist", out result);
            PantsWaistTextBox.Text = result ?? "";
            measurements.TryGetValue("pants_seat", out result);
            PantsSeatTextBox.Text = result ?? "";
            measurements.TryGetValue("pants_crotch", out result);
            PantsCrotchTextBox.Text = result ?? "";
            measurements.TryGetValue("pants_1623_below", out result);
            Pants1623TextBox.Text = result ?? "";
            measurements.TryGetValue("pants_bottom_cuff", out result);
            PantsBottomCuffTextBox.Text = result ?? "";
            measurements.TryGetValue("pants_inseam", out result);
            PantsInseamTextBox.Text = result ?? "";
            measurements.TryGetValue("pants_outseam", out result);
            PantsOutseamTextBox.Text = result ?? "";

            measurements.TryGetValue("jacket_chest", out result);
            JacketChestTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_waist", out result);
            JacketWaistTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_hips", out result);
            JacketHipsTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_shoulders", out result);
            JacketShouldersTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_sleeve_length", out result);
            JacketSleeveLengthTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_jacket_length", out result);
            JacketLengthOfJacketTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_half_shoulder", out result);
            JacketHalfShoulderTextBox.Text = result ?? "";
            measurements.TryGetValue("jacket_sleeve_width", out result);
            JacketSleeveWidthTextBox.Text = result ?? "";

            measurements.TryGetValue("vest_front_length", out result);
            VestFrontTextBox.Text = result ?? "";
            measurements.TryGetValue("vest_back_length", out result);
            VestBackTextBox.Text = result ?? "";
        }
示例#9
0
 public CustomerProfile(CustomerResource customer, AlterationForm.CustomerProfileDidFinishEditing alterationCallback)
     : this(customer)
 {
     alterationFormCallback = alterationCallback;
 }
示例#10
0
        private CustomerResource ConvertSQLReaderRowToTicketResource(MySqlDataReader reader)
        {
            CustomerResource customer = new CustomerResource();
            customer.CustomerId = reader["id"] is DBNull ? 0 : Convert.ToInt32(reader["id"]);
            customer.Title = reader["title"] is DBNull ? "" : (String)reader["title"] ?? "";
            customer.FirstName = reader["first_name"] is DBNull ? "" : (String)reader["first_name"] ?? "";
            customer.MiddleName = reader["middle_name"] is DBNull ? "" : (String)reader["middle_name"] ?? "";
            customer.LastName= reader["last_name"] is DBNull ? "" : (String)reader["last_name"] ?? "";
            customer.Address = reader["address"] is DBNull ? "" : (String)reader["address"] ?? "";
            customer.Address2 = reader["address2"] is DBNull ? "" : (String)reader["address2"] ?? "";
            customer.City = reader["city"] is DBNull ? "" : (String)reader["city"] ?? "";
            customer.State = reader["state"] is DBNull ? "" : (String)reader["state"] ?? "";
            customer.Zip = reader["zip"] is DBNull ? "" : Convert.ToString(reader["zip"] ?? "");
            customer.Telephone = reader["phone"] is DBNull ? "" : (String)reader["phone"] ?? "";
            customer.Email = reader["email"] is DBNull ? "" : (String)reader["email"] ?? "";

            return customer;
        }
示例#11
0
        public void UpdateCustomer(CustomerResource customerResource)
        {
            DBConnector connector = new DBConnector();
            MySqlCommand insertCommand = new MySqlCommand();
            insertCommand.Connection = connector.connection;
            insertCommand.CommandText = @"UPDATE Customer SET title = @title, first_name = @first_name, middle_name = @middle_name, last_name = @last_name, address = @address, address2 = @address2, city = @city, state = @state, zip = @zip, phone = @phone, email = @email where id = @customerId";
            insertCommand.Parameters.AddWithValue("@title", customerResource.Title);
            insertCommand.Parameters.AddWithValue("@first_name", customerResource.FirstName);
            insertCommand.Parameters.AddWithValue("@middle_name", customerResource.MiddleName);
            insertCommand.Parameters.AddWithValue("@last_name", customerResource.LastName);
            insertCommand.Parameters.AddWithValue("@address", customerResource.Address);
            insertCommand.Parameters.AddWithValue("@address2", customerResource.Address2);
            insertCommand.Parameters.AddWithValue("@city", customerResource.City);
            insertCommand.Parameters.AddWithValue("@state", customerResource.State);
            insertCommand.Parameters.AddWithValue("@zip", customerResource.Zip);
            insertCommand.Parameters.AddWithValue("@phone", customerResource.Telephone);
            insertCommand.Parameters.AddWithValue("@email", customerResource.Email);
            insertCommand.Parameters.AddWithValue("@customerId", customerResource.CustomerId);

            try
            {
                insertCommand.ExecuteNonQuery();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("There was an error. Contact Jay with this message: " + ex.Message + " error code: " + ex.Number);
            }

            connector.CloseConnection();
        }
示例#12
0
        public int InsertCustomer(CustomerResource customerResource)
        {
            DBConnector connector = new DBConnector();

            int orderIndex = 0;

            MySqlCommand insertCommand = new MySqlCommand();
            insertCommand.Connection = connector.connection;
            insertCommand.CommandText = @"INSERT into Customer (title, first_name, middle_name, last_name, address, address2, city, state, zip, phone, email) values (@title, @first_name, @middle_name, @last_name, @address, @address2, @city, @state, @zip, @phone, @email)";
            insertCommand.Parameters.AddWithValue("@title", customerResource.Title);
            insertCommand.Parameters.AddWithValue("@first_name", customerResource.FirstName);
            insertCommand.Parameters.AddWithValue("@middle_name", customerResource.MiddleName);
            insertCommand.Parameters.AddWithValue("@last_name", customerResource.LastName);
            insertCommand.Parameters.AddWithValue("@address", customerResource.Address);
            insertCommand.Parameters.AddWithValue("@address2", customerResource.Address2);
            insertCommand.Parameters.AddWithValue("@city", customerResource.City);
            insertCommand.Parameters.AddWithValue("@state", customerResource.State);
            insertCommand.Parameters.AddWithValue("@zip", customerResource.Zip);
            insertCommand.Parameters.AddWithValue("@phone", customerResource.Telephone);
            insertCommand.Parameters.AddWithValue("@email", customerResource.Email);
            orderIndex++;

            MySqlCommand getLastRowCommand = new MySqlCommand();
            getLastRowCommand.Connection = connector.connection;
            getLastRowCommand.CommandText = "SELECT id FROM Customer ORDER BY id DESC LIMIT 1;";

            try
            {
                insertCommand.ExecuteNonQuery();
                MySqlDataReader reader = getLastRowCommand.ExecuteReader();
                int customerId = 0;
                while (reader.Read())
                {
                    customerId = Convert.ToInt32(reader["id"]);
                }
                reader.Close();
                connector.CloseConnection();
                return customerId;
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("There was an error. Contact Jay with this message: " + ex.Message + " error code: " + ex.Number);
            }
            return -1;
        }