コード例 #1
0
        private void AddBooks_Click(object sender, EventArgs e)
        {
            if (UserType == "Manager")
            {
                if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || comboBox1.Text == "")//validation part
                {
                    MessageBox.Show("Please, insert all values");
                }
                else
                {
                    int x = EmC.InsertUs(textBox3.Text, textBox4.Text, "Employee");
                    if (x == 0)
                    {
                        MessageBox.Show("Your Request is Invalid");
                    }
                    else
                    {
                        int r = EmC.InsertEmployee(id, textBox1.Text, textBox7.Text, textBox2.Text, textBox6.Text, comboBox1.Text, Convert.ToInt32(textBox5.Text), BranchID, ManagerID, textBox3.Text);
                        if (r == 0)
                        {
                            MessageBox.Show("Your Request is Invalid");
                        }

                        else
                        {
                            MessageBox.Show("New Employee is Added!");
                        }
                    }
                }
            }
            else
            {
                if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "" || textBox4.Text == "" || textBox5.Text == "" || textBox6.Text == "" || comboBox1.Text == "" || comboBox2.Text == "")//validation part
                {
                    MessageBox.Show("Please, insert all values");
                }
                else
                {
                    int x = EmC.InsertUs(textBox3.Text, textBox4.Text, comboBox2.Text);
                    if (x == 0)
                    {
                        MessageBox.Show("Your Request is Invalid");
                    }
                    else
                    {
                        int r = EmC.InsertEmployee(id, textBox1.Text, textBox7.Text, textBox2.Text, textBox6.Text, comboBox1.Text, Convert.ToInt32(textBox5.Text), BranchID, ManagerID, textBox3.Text);
                        if (r == 0)
                        {
                            MessageBox.Show("Your Request is Invalid");
                        }

                        else
                        {
                            MessageBox.Show("New " + comboBox2.Text + " is Added!");
                        }
                    }
                }
            }
        }