Ejemplo n.º 1
0
        private void BtnSave_Click(object sender, System.EventArgs e)
        {
            if (FieldFName.Text == "")
            {
                MessageBox.Show("Please fill first name.", "Information",
                    MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            CustomerService.CustomerInformation custInfo;
            if (selectedCust != null)
                custInfo = selectedCust;
            else
            {
                custInfo = new CustomerService.CustomerInformation();
                custInfo.CustID = 0;
            }
            custInfo.Telephone = FieldPhone.Text;
            custInfo.FirstName = FieldFName.Text;
            custInfo.MiddleName = FieldMName.Text;
            custInfo.LastName = FieldLName.Text;
            custInfo.Address = FieldAddress.Text;
            custInfo.Description = FieldMemo.Text;

            CustomerService.CustomerService service = new CustomerService.CustomerService();
            string result = service.SetCustomer(custInfo);
            if (result != null)
            {
                MessageBox.Show(result);
                return;
            }
            BtnCustSearch_Click(null, null);
        }
Ejemplo n.º 2
0
 private void BtnDelete_Click(object sender, System.EventArgs e)
 {
     if (selectedCust == null)
     {
         MessageBox.Show("Please select from customer list first.", "Information",
             MessageBoxButtons.OK, MessageBoxIcon.Information);
         return;
     }
     CustomerService.CustomerService service = new CustomerService.CustomerService();
     string result = service.DeleteCustomer(selectedCust.CustID);
     if (result != null)
     {
         MessageBox.Show(result);
         return;
     }
     ClearCustomer();
     BtnCustList_Click(null, null);
 }
Ejemplo n.º 3
0
        private void BtnCustSearch_Click(object sender, System.EventArgs e)
        {
            if (FieldPhone.Text == "" && FieldFName.Text == "" &&
                FieldMName.Text == "" && FieldLName.Text == "")
            {
                MessageBox.Show("Please fill phone number, first name, middle name, or last name.",
                    "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            CustomerService.CustomerService service = new CustomerService.CustomerService();
            custList = service.SearchCustomers(FieldPhone.Text, FieldFName.Text, FieldMName.Text, FieldLName.Text);
            if (custList != null && custList.Length == 1)
            {
                selectedCust = custList[0];
                UpdateCustomerField();
            }
            UpdateCustomerList();
        }
Ejemplo n.º 4
0
 private void BtnCustList_Click(object sender, System.EventArgs e)
 {
     CustomerService.CustomerService service = new CustomerService.CustomerService();
     custList = service.GetCustomers();
     if (selectedCust != null)
     {
         for (int i = 0;i < custList.Length;i++)
             if (custList[i].CustID == selectedCust.CustID)
             {
                 selectedCust = custList[i];
                 break;
             }
     }
     UpdateCustomerList();
 }
Ejemplo n.º 5
0
 private void BtnSave_Click(object sender, EventArgs e)
 {
     if (this.FieldFName.Text == "")
     {
         MessageBox.Show("Please fill first name.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         CustomerInformation selectedCust;
         if (this.selectedCust != null)
         {
             selectedCust = this.selectedCust;
         }
         else
         {
             selectedCust = new CustomerInformation();
             selectedCust.CustID = 0;
         }
         selectedCust.Telephone = this.FieldPhone.Text;
         selectedCust.FirstName = this.FieldFName.Text;
         selectedCust.MiddleName = this.FieldMName.Text;
         selectedCust.LastName = this.FieldLName.Text;
         selectedCust.Address = this.FieldAddress.Text;
         selectedCust.Description = this.FieldMemo.Text;
         string text = new smartRestaurant.CustomerService.CustomerService().SetCustomer(selectedCust);
         if (text != null)
         {
             MessageBox.Show(text);
         }
         else
         {
             this.BtnCustSearch_Click(null, null);
         }
     }
 }
Ejemplo n.º 6
0
 private void BtnDelete_Click(object sender, EventArgs e)
 {
     if (this.selectedCust == null)
     {
         MessageBox.Show("Please select from customer list first.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     else
     {
         string text = new smartRestaurant.CustomerService.CustomerService().DeleteCustomer (this.selectedCust.CustID);
         if (text != null)
         {
             MessageBox.Show(text);
         }
         else
         {
             this.ClearCustomer();
             this.BtnCustList_Click(null, null);
         }
     }
 }