private void button4_Click(object sender, EventArgs e)
        {
            Add_Department obj = new Add_Department(userName);

            obj.Show();
            this.Close();
        }
示例#2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var data = _con.Departments.SingleOrDefault(c => c.name == txt_department.Text.ToUpper());

            if (data == null)
            {
                var datas = new tbl_department
                {
                    name = txt_department.Text.ToUpper()
                };
                _con.Departments.Add(datas);
                _con.SaveChanges();
                MessageBox.Show("Saved Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Department Already Exist!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (MessageBox.Show("Want to Add more department?", "Information", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                Add_Department obj = new Add_Department(userName);
                obj.Show();
                this.Close();
            }
            else
            {
                FirstPage obj = new FirstPage(userName);
                obj.Show();
                this.Close();
            }
        }