Пример #1
0
        //get customer by customer first name
        private void but_GetCustomer_Click(object sender, EventArgs e)
        {
            if (e_custName.Text == string.Empty)
            {
                listcostomer = CustomerLAO.GetAllCustomers();
            }
            else
            {
                listcostomer = CustomerLAO.GetCustomerByName(e_custName.Text);
            }

            cb_cusId.Items.Clear();
            cb_cusId.Enabled = true;
            cb_cusId.Visible = true;

            if (listcostomer.Count > 0)
            {
                string[] customerIdlist = new string[listcostomer.Count];
                for (int i = 0; i < listcostomer.Count; i++)
                {
                    customerIdlist[i] = ((Customer)(listcostomer[i])).CustomerId.ToString();
                }

                this.cb_cusId.Items.AddRange(customerIdlist);
                this.cb_cusId.SelectedIndex = 0;

                Customer aCusotomer = new Customer();
                aCusotomer = listcostomer[0];
                SetCustomerInformation(aCusotomer);
            }
        }
Пример #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     currentStatus = currentStatusEnum.addingStatus;
     InitAllComponetsStatus(true);
     txt_id.Enabled = false;
     CleanAllTheComponest();
     txt_id.Text = CustomerLAO.getCustomerCurrentVal().ToString();
 }
Пример #3
0
        private void button2_Click(object sender, EventArgs e)
        {
            CustomerLAO dao = new CustomerLAO();
            Customer    cus = new Customer();

            cus = dao.getCustoemerById(1);
            this.label3.Text = cus.CustomerId.ToString();
            Console.WriteLine(cus.CustomerId);
        }
Пример #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            switch (currentStatus)
            {
            case currentStatusEnum.addingStatus:
            {
                if (!chk_ship.Checked)
                {
                    if (m_address.Text != string.Empty &&
                        m_city.Text != string.Empty &&
                        m_first.Text != string.Empty &&
                        m_last.Text != string.Empty &&
                        m_Phone.Text != string.Empty &&
                        m_postcode.Text != string.Empty &&
                        m_state.Text != string.Empty)
                    {
                        Customer insertCustomer = GetAllCustomerFromComponents();
                        CustomerLAO.addNewCustomer(insertCustomer);
                    }
                    else
                    {
                        MessageBox.Show("Address Error", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    Customer insertCustomer = GetAllCustomerFromComponents();
                    CustomerLAO.addNewCustomer(insertCustomer);
                }

                listCustomer             = CustomerLAO.GetAllCustomers();
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = listCustomer;
            }
            break;

            case currentStatusEnum.editingStatus:
            {
                Customer updateCustomer = GetAllCustomerFromComponents();
                CustomerLAO.UpdateCustomer(updateCustomer);

                listCustomer             = CustomerLAO.GetAllCustomers();
                dataGridView1.DataSource = null;
                dataGridView1.DataSource = listCustomer;
            }
            break;

            case currentStatusEnum.nonStatus:
            { }
            break;

            default:
                break;
            }
            InitCustomerList();
        }
Пример #5
0
        /// <summary>
        /// add order
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdd_Click(object sender, EventArgs e)
        {
            showProdut.Clear();
            currentStatus = FormStatus.adding;
            CleanAllComponets();
            but_GetCustomer.Enabled = true;
            cb_cusId.Enabled        = true;
            cb_cusId.Visible        = true;
            btn_add.Enabled         = true;
            btn_delete.Enabled      = true;
            e_custName.Enabled      = true;
            comb_prod.Items.Clear();
            comb_prod.Text      = string.Empty;
            e_custName.Enabled  = true;
            e_custName.ReadOnly = false;
            extenstions.ClearControls(Controls);
            o_number.Enabled = false;
            o_number.Text    = OrderLAO.getOrderNextValue().ToString();
            if (listProduct.Count > 0)
            {
                this.comb_prod.Items.Clear();
                string[] productNameString = new string[listProduct.Count];
                for (int i = 0; i < listProduct.Count; i++)
                {
                    productNameString[i] = listProduct[i].ProductName;
                }

                this.comb_prod.Items.AddRange(productNameString);

                this.comb_prod.SelectedIndex = 0;
            }
            listcostomer = CustomerLAO.GetAllCustomers();
            if (listcostomer.Count > 0)
            {
                string[] customerIdlist = new string[listcostomer.Count];
                for (int i = 0; i < listcostomer.Count; i++)
                {
                    customerIdlist[i] = ((Customer)(listcostomer[i])).CustomerId.ToString();
                }

                this.cb_cusId.Items.AddRange(customerIdlist);
                this.cb_cusId.SelectedIndex = 0;
                Customer aCusotomer = new Customer();
                aCusotomer = listcostomer[0];
                SetCustomerInformation(aCusotomer);
            }
            setAddressEnable(true);
        }
Пример #6
0
 private void btnQuery_Click(object sender, EventArgs e)
 {
     customer.Clear();
     dataGridView1.DataSource = null;
     if (textBox_code.Text != string.Empty)
     {
         int restult = 0;
         if (Int32.TryParse(textBox_code.Text, out restult))
         {
             cust = CustomerLAO.getCustoemerById(Int32.Parse(textBox_code.Text));
         }
         if (cust != null)
         {
             customer.Add(cust);
         }
     }
     else
     {
         customer = CustomerLAO.GetAllCustomers();
     }
     dataGridView1.DataSource = customer;
 }
Пример #7
0
 private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (currentStatus == FormStatus.editing || currentStatus == FormStatus.nonstatus)
     {
         int   selectIndex = dataGridView1.CurrentRow.Index;
         Order aOrder      = new Order();
         aOrder = listOrder[selectIndex];
         SetOrderInformation(aOrder);
         Customer cusotmerInformation = new Customer();
         cusotmerInformation = CustomerLAO.getCustoemerById(aOrder.customerId);
         SetCustomerInformation(cusotmerInformation);
         orderLine = new List <OrderLines>();
         orderLine = OrderLAO.GetLinesByOrderId(aOrder.OrderId);
         SetAllProductInformation();
         currentStatus = FormStatus.editing;
         UpdateBottomInformation();
     }
     if (currentStatus == FormStatus.adding)
     {
         selectIndexOfProduct = dataGridView1.CurrentRow.Index;
     }
 }
Пример #8
0
 private void InitCustomerList()
 {
     listCustomer             = CustomerLAO.GetAllCustomers();
     dataGridView1.DataSource = listCustomer;
 }