示例#1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int er = 0;

            ep.Clear();
            if (txtName.Text == "")
            {
                er++;
                ep.SetError(txtName, "Required");
            }
            if (txtAddress.Text == "")
            {
                er++;
                ep.SetError(txtAddress, "Required");
            }
            if (txtPhoneNumber.Text == "")
            {
                er++;
                ep.SetError(txtPhoneNumber, "Required");
            }
            if (txtPassword.Text == "")
            {
                er++;
                ep.SetError(txtPassword, "Required");
            }

            if (er > 0)
            {
                return;
            }

            DAL.User user = new DAL.User();
            user.Id          = Id;
            user.Name        = txtName.Text;
            user.PhoneNumber = txtPhoneNumber.Text;
            user.Address     = txtAddress.Text;
            user.Password    = txtPassword.Text;
            user.Image       = MyControls.FileImage.ImageToByte(user_pic.Image);

            if (user.Update_All())
            {
                Name = user.Name;
                MessageBox.Show("Information Updated!");
            }
            else
            {
                MessageBox.Show(user.Error);
            }
        }