Example #1
0
        private void mainForm_Load(object sender, EventArgs e)
        {
            //using (dbemployeeEntities db = new dbemployeeEntities())
            //{
            //    db.Database.ExecuteSqlCommand("UPDATE employee_info SET lastname = 'SQLTEST' WHERE empID = 19");
            //}

            employeeinfoBindingSource.DataSource = EmployeeInfoServices.GetAll();
        }
Example #2
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     using (EmpAddEditForm frm = new EmpAddEditForm(null))
     {
         if (frm.ShowDialog() == DialogResult.OK)
         {
             employeeinfoBindingSource.DataSource = EmployeeInfoServices.GetAll();
         }
     }
 }
Example #3
0
        private void EmpAddEditForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (DialogResult == DialogResult.OK)
            {
                employee_info ei = employeeinfoBindingSource.Current as employee_info;

                if (string.IsNullOrEmpty(textBoxFirstName.Text))
                {
                    MessageBox.Show("Please Enter First Name!", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    textBoxFirstName.Focus();
                    e.Cancel = true;
                    return;
                }

                if (string.IsNullOrEmpty(textBoxLastName.Text))
                {
                    MessageBox.Show("Please Enter Last Name!");
                    textBoxLastName.Focus();
                    e.Cancel = true;
                    return;
                }

                if ((string.IsNullOrEmpty(textBoxContactNumber.Text)) || (textBoxContactNumber.Text.Length != 11))
                {
                    MessageBox.Show("Please Enter Contact Number!");
                    textBoxContactNumber.Focus();
                    e.Cancel = true;
                    return;
                }

                if ((string.IsNullOrEmpty(dateTimePickerDOB.Text)))
                {
                    MessageBox.Show("Please Enter your Birth Date!");
                    dateTimePickerDOB.Focus();
                    e.Cancel = true;
                    return;
                }
                else
                {
                    ei.birthdate = Convert.ToDateTime(dateTimePickerDOB.Text);
                }

                if (IsNew)
                {
                    EmployeeInfoServices.Insert(ei);
                    MessageBox.Show("Added!");
                }
                else
                {
                    EmployeeInfoServices.Update(employeeinfoBindingSource.Current as employee_info);
                    MessageBox.Show("Saved!");
                }
            }
        }
Example #4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (employeeinfoBindingSource.Current == null)
            {
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete this?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                EmployeeInfoServices.Delete(employeeinfoBindingSource.Current as employee_info);
                employeeinfoBindingSource.RemoveCurrent();
            }
        }
Example #5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (employeeinfoBindingSource.Current == null)
            {
                return;
            }

            using (EmpAddEditForm frm = new EmpAddEditForm(employeeinfoBindingSource.Current as employee_info))
            {
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    employeeinfoBindingSource.DataSource = EmployeeInfoServices.GetAll();
                }
            }
        }