Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool newCustomer = false;

            try
            {
                if (radioButton1.Checked)
                {
                    if (textBox1.Text.Length != 0)
                    {
                        IDataReader reader = _newQuery.SearchCustomer(int.Parse(textBox1.Text)).CreateDataReader();
                        reader.Read();
                        _currentCustomer = new Customer(int.Parse(reader["CustID"].ToString()), reader["CustFirstName"].ToString(), reader["CustLastName"].ToString(), Int64.Parse(reader["CustPhoneNumber"].ToString()), reader["CustStreetAddress"].ToString(), reader["CustCity"].ToString(), reader["CustState"].ToString(), int.Parse(reader["CustAreaCode"].ToString()));
                    }
                    else if ((textBox10.Text.Length != 0) && (textBox9.Text.Length != 0))
                    {
                        IDataReader reader = _newQuery.SearchCustomer(textBox10.Text, textBox9.Text).CreateDataReader();
                        reader.Read();
                        _currentCustomer = new Customer(int.Parse(reader["CustID"].ToString()), reader["CustFirstName"].ToString(), reader["CustLastName"].ToString(), Int64.Parse(reader["CustPhoneNumber"].ToString()), reader["CustStreetAddress"].ToString(), reader["CustCity"].ToString(), reader["CustState"].ToString(), int.Parse(reader["CustAreaCode"].ToString()));
                    }
                }
                if (radioButton2.Checked)
                {
                    _currentCustomer = new Customer((int.Parse(_newQuery.GetLastEnteredID("Customer", "CustID"))) + 1, textBox2.Text, textBox3.Text, Int64.Parse(textBox4.Text), textBox5.Text, textBox6.Text, textBox7.Text, int.Parse(textBox8.Text));
                    newCustomer      = true;
                }
                if (newCustomer)
                {
                    _currentCustomer.Add();                 // if customer is new then adds to the database
                }
                _newOrder = new Order(int.Parse(_newQuery.GetLastEnteredID("Orders", "OrdID") + 1), _orderDate, _shippedDate, _currentCustomer.ID, int.Parse(_servingEmployee));
                _newOrder.Add();
                foreach (Product p in _orderProducts)
                {
                    _newOrder.AddItem(p);
                }
                _newOrder.AddOrderItems();

                SalesForm newForm = new SalesForm(_servingEmployee);
                MessageBox.Show("Transaction Successful");
                newForm.Show();
                newForm.SetDesktopLocation(325, 100);
                this.Hide();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var      timezone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time");
            string   time     = TimeZoneInfo.ConvertTime(DateTime.Now, timezone).ToString("HH:mm:ss");
            DateTime today    = DateTime.Today;
            string   date     = today.ToString("MM/dd/yyyy");

            try
            {
                int temp = _newQuery.LoginEmployee(int.Parse(textBox1.Text), textBox2.Text);
                if (temp == 1)
                {
                    _newQuery.AddWorkLog((int.Parse(_newQuery.GetLastEnteredID("EmployeeWorkLog", "LogID"))) + 1, int.Parse(textBox1.Text), date, time);
                    SalesForm _newSalesForm = new SalesForm(textBox1.Text);
                    _newSalesForm.Show();
                    _newSalesForm.SetDesktopLocation(325, 100);
                    this.Hide();
                }

                else if (temp == 2)
                {
                    _newQuery.AddWorkLog((int.Parse(_newQuery.GetLastEnteredID("EmployeeWorkLog", "LogID"))) + 1, int.Parse(textBox1.Text), date, time);
                    ManageMainForm _newManageMainForm = new ManageMainForm(textBox1.Text);
                    _newManageMainForm.Show();
                    this.Hide();
                }
                else if (temp == 0)
                {
                    MessageBox.Show("Either Your User ID or Password is invalid!");
                    textBox1.Clear();
                    textBox2.Clear();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please Enter the Correct Login Details!");
                textBox1.Clear();
                textBox2.Clear();
            }
        }