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 (txtPassword.Text == "") { er++; ep.SetError(txtPassword, "Required"); } if (txtNumber.Text == "") { er++; ep.SetError(txtNumber, "Required"); } if (cmbRole.Text == "") { er++; ep.SetError(cmbRole, "Required"); } if (er > 0) { return; } DAL.User user = new DAL.User(); DAL.Info info = new DAL.Info(); user.Name = txtName.Text; user.Address = txtAddress.Text; user.PhoneNumber = txtNumber.Text; user.Image = MyControls.FileImage.ImageToByte(user_pic.Image); user.Insert(); info.Password = txtPassword.Text; info.Role = cmbRole.Text; user.GetMaxId(); info.UserId = user.Id; if (info.Insert()) { MessageBox.Show("Data Saved"); //Button btn = (Button)(Myparent.Controls.Find("search", false).First()); //btn.PerformClick(); RefreshGrid(); MyControls.Helper.Clear(this); user_pic.Image = null; txtName.Focus(); } else { MessageBox.Show(user.Error + info.Error); } }