Exemplo n.º 1
0
        private void btnAdd_clicked(object sender, RoutedEventArgs e)
        {
            if (txtName.Text.Count() == 0 || txtEmail.Text.Count() == 0 || txtPhone.Text.Count() == 0 || txtAddress.Text.Count() == 0)
            {
                lblNotice.Content    = "Please fill all information.";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }


            int  temp;
            bool isNumeric = Int32.TryParse(txtPhone.Text, out temp);

            if (!isNumeric)
            {
                lblNotice.Content    = "Phone isn't number!";
                lblNotice.Visibility = Visibility.Visible;
                return;
            }



            CustomerBUS bus    = new CustomerBUS();
            CustomerDTO result = new CustomerDTO();

            result.Name    = txtName.Text;
            result.Email   = txtEmail.Text;
            result.Phone   = txtPhone.Text;
            result.CoopDay = lblCoopday.Content.ToString();
            result.Address = txtAddress.Text;
            result.Paid    = 0;
            bus.AddNewCustomer(result);
            this.Close();
        }
        private void btnAccept_Click(object sender, EventArgs e)
        {
            if (checkAdd())
            {
                //Assign New CustomerInfo
                customerInfo.CustomerID    = int.Parse(txtCustomerID.Text);
                customerInfo.Name          = txtName.Text;
                customerInfo.Contact       = txtContact.Text;
                customerInfo.PhoneNumber   = txtPhone.Text;
                customerInfo.Email         = txtmail.Text;
                customerInfo.Fax           = txtFax.Text;
                customerInfo.Tax           = txtTax.Text;
                customerInfo.Address       = txtAddress.Text;
                customerInfo.Website       = txtWebsite.Text;
                customerInfo.AccountNumber = txtaccnum.Text;



                //Add new Customer
                customerBUS.AddNewCustomer(customerInfo);
                MessageBox.Show("Create Successful!!!", "Succes", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.Close();
            }
            else
            {
                if (txtName.Text == "")
                {
                    MessageBox.Show("User can't be blank!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (txtName.Text == "")
                {
                    MessageBox.Show("Email can't be blank!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }