//SAVE SURVEYOR DATA private void UserDataSave() { try { if (//CHECK TEXBOXES NOT NULL OR EMPTY String.IsNullOrWhiteSpace(txtEmpRegNo.Text) || String.IsNullOrWhiteSpace(txtName.Text) || String.IsNullOrWhiteSpace(cbxSurveyorType.Text) || String.IsNullOrWhiteSpace(txtMobile.Text) || String.IsNullOrWhiteSpace(txtEmail.Text) ) { MessageBox.Show("You must be filling all field!.", "Surveyor Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (objClassBLL.ExistSurveyor(_division, txtEmpRegNo.Text) == false) { //PROPERTIES FOR DATA ADD objClassBLL = new SurveyorClassBLL() { date = DateTime.Today, emp_reg_no = txtEmpRegNo.Text, initail_name = txtName.Text, surveyor_type = cbxSurveyorType.Text.ToString(), mobile = txtMobile.Text, email = txtEmail.Text, division = _division, username = _username }; //INSERT DATA TO DATABASE objClassBLL.AddNewSurveyor(); MessageBox.Show("Surveyor registration successfully!", "Surveyor Registration", MessageBoxButtons.OK, MessageBoxIcon.Information); //CLEAR ALL TEXBOX AND COMBOBOX ClearTextBoxces(); //LOAD USER DATA LoadDataDgv(); //SET TO BUTTON TEXT Add btnAdd.Text = "Add"; txtEmpRegNo.Enabled = true; } else { MessageBox.Show("Already exist this surveyor!", "Surveyor Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "USER ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
//UPDATE SURVEYOR DATA private void SurveyorDataUpadate() { try { if (//CHECK TEXBOXES NOT NULL OR EMPTY String.IsNullOrWhiteSpace(txtEmpRegNo.Text) || String.IsNullOrWhiteSpace(txtName.Text) || String.IsNullOrWhiteSpace(cbxSurveyorType.Text) || String.IsNullOrWhiteSpace(txtMobile.Text) || String.IsNullOrWhiteSpace(txtEmail.Text) ) { MessageBox.Show("You must be filling all field!.", "Surveyor Registration", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { objClassBLL = new SurveyorClassBLL() { date = DateTime.Today, emp_reg_no = txtEmpRegNo.Text, initail_name = txtName.Text, surveyor_type = cbxSurveyorType.Text.ToString(), mobile = txtMobile.Text, email = txtEmail.Text, division = _division, username = _username }; //UPDATE USER DATA objClassBLL.UpdateSurveyor(); MessageBox.Show("Surveyor Update successfully!", "Surveyor Update", MessageBoxButtons.OK, MessageBoxIcon.Information); //CLEAR ALL TEXBOX AND COMBOBOX ClearTextBoxces(); //LOAD USER DATA LoadDataDgv(); //SET TO BUTTON TEXT Add btnAdd.Text = "Add"; txtEmpRegNo.Enabled = true; } } catch (Exception ex) { MessageBox.Show(ex.Message, "SURVEYOR ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void ucSurveyor_Load(object sender, EventArgs e) { lblDate.Text = DateTime.Today.ToString("dd/MM/yyyy"); btnAdd.Text = "Add";//TEXTBOX DEFAULT TEXT SET AFTER DATAGRIDVIEW ROW DOUBLE CLICK txtEmpRegNo.Enabled = true; LoadDataDgv(); //LOAD USER DATA DataGrdViewDesign(); //DATAGRIDVIEW DESIGN //LOAD DIVISION DATA TO COMBO BOX objClassBLL = new SurveyorClassBLL(); cbxSurveyorType.DataSource = objClassBLL.LoadSurveyorType(); cbxSearchSurType.DataSource = objClassBLL.LoadSurveyorType(); //CLEAR ALL COMBOBOX DEFAULT SELECT VALUE ClearTextBoxces(); }
//LOAD SURVEYOR DATA private void LoadDataDgv() { objClassBLL = new SurveyorClassBLL(); dgvSurveyor.DataSource = objClassBLL.LoadSurveyor(); }