예제 #1
0
        private void Update_Click(object sender, EventArgs e)
        {
            if (Fname.Text == "" || Lname.Text == "" || ID.Text == "" || (string)Type.SelectedItem == "" || Type.SelectedItem == null || OwnID.SelectedItem == null || (MgrID.SelectedItem == null && HasMGR.Checked == true))
            {
                MessageBox.Show("Please enter all fields.");
                return;
            }

            string FN, LN;

            FN = Fname.Text;
            LN = Lname.Text;

            if (FN.Any(char.IsDigit))
            {
                MessageBox.Show("No digits are allowed in first name field!");
                return;
            }
            if (LN.Any(char.IsDigit))
            {
                MessageBox.Show("No digits are allowed in last name field!");
                return;
            }
            int x;

            if (!(Int32.TryParse(ID.Text, out x)))
            {
                MessageBox.Show("Please enter a number in the ID number field.");
                return;
            }
            int?MGR = null;

            if (HasMGR.Checked == true)
            {
                MGR = (int)MgrID.SelectedItem;
            }
            int r = contobj.UpdateEmployee(Convert.ToInt32(ID.Text), Fname.Text, Lname.Text, (int)SSN.Value, (float)OSSalary.Value, (float)Salary.Value, Hdate.Value, (string)Type.SelectedItem, (int?)MGR, (int)OwnID.SelectedItem, (int)ContID.SelectedItem);

            if (r > 0)
            {
                MessageBox.Show("The Employee is Updated successfully! :) ");
            }
            else
            {
                MessageBox.Show("Employee Not Updated, Check your input again. ");
            }
            dataGridView1.Refresh();
            SH_ALL_Click(sender, e);
            return;
        }