예제 #1
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            bool result = false;

            foreach (var item in ListCtmEdit)
            {
                if (customerBLL.EditCustomer(item) == false)
                {
                    MessageBox.Show("Cannot save. Please try again");
                    break;
                }
                else
                {
                    result = true;
                }
            }
            if (result == true)
            {
                DialogResult dialog = MessageBox.Show("Saved successfully", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                if (dialog == DialogResult.OK)
                {
                    mainform.loadUCCustomer();
                }
            }
            //dgvCustomer.DataSource = customerBLL.LoadRecord(pageNumber, numberRecord);
        }
예제 #2
0
        private void btnSave_Click_1(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtCMND.Text) || cbGender.Text == "-select-" ||
                String.IsNullOrEmpty(txtPhone.Text) || String.IsNullOrEmpty(txtName.Text))

            {
                MessageBox.Show("Please insert information fully !", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (lbErrorCMND.Visible == true || lbErrorGender.Visible == true ||
                    lbErrorName.Visible == true || lbErrorPhone.Visible == true)
                {
                    MessageBox.Show("Please correct your mistakes before save changes");
                }
                else
                {
                    Customer ctm  = new Customer();
                    string   Name = txtName.Text;
                    while (Name.IndexOf("  ") != -1)
                    {
                        Name = Name.Replace("   ", " ");
                    }
                    Name            = Name.Trim();
                    ctm.Name        = Name;
                    ctm.CMND        = txtCMND.Text;
                    ctm.PhoneNumber = txtPhone.Text;
                    ctm.Status      = 1;
                    ctm.IsFemale    = (cbGender.SelectedItem.ToString() == "Female") ? true : false;
                    if (customerBLL.AddCustomer(ctm) == true)
                    {
                        DialogResult dialog = MessageBox.Show("Saved successfully", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (dialog == DialogResult.OK)
                        {
                            mainform.loadUCCustomer();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Can't save !!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }