private void add_Click(object sender, EventArgs e)
        {
            Resource resource = new Resource();

            if (Rname.Text.Trim().Length == 0)
            {
                MessageBox.Show("Invalid Name");
                return;
            }
            resource.resName           = Rname.Text.Trim();
            resource.resTypeIdFK       = type.SelectedIndex + 1;
            resource.remainingQuantity = (int)numericUpDown1.Value;


            db.Resources.Add(resource);

            try
            {
                db.SaveChanges();

                if (numericUpDown1.Value != 0)
                {
                    foreach (var item in checkedListBox1.CheckedItems)
                    {
                        Resource_Allocation resource_Allocation = new Resource_Allocation();
                        resource_Allocation.resIdFK = resource.resId;
                        var q3 = db.Skills.Where(x => x.skillName == item.ToString()).FirstOrDefault();
                        if (q3 != null)
                        {
                            resource_Allocation.skillIdFK = q3.skillId;
                        }
                        db.Resource_Allocation.Add(resource_Allocation);
                    }
                    try
                    {
                        db.SaveChanges();
                        MessageBox.Show("Sucess!");
                    }
                    catch (Exception es)
                    {
                        MessageBox.Show(es.ToString());
                    }
                }
                else
                {
                    MessageBox.Show("Sucess!");
                }
            }
            catch (Exception es)
            {
                MessageBox.Show(es.ToString());
            }
        }
        private void update_Click(object sender, EventArgs e)
        {
            var get1 = db.Resources.Where(x => x.resId == IDs).FirstOrDefault();

            if (get1 != null)
            {
                get1.remainingQuantity = (int)numericUpDown1.Value;
            }

            if (numericUpDown1.Value != 0)
            {
                var q4 = db.Resource_Allocation.Where(x => x.resIdFK == IDs).ToList();
                foreach (var item in q4)
                {
                    db.Resource_Allocation.Remove(item);
                }
                foreach (var item in checkedListBox1.CheckedItems)
                {
                    Resource_Allocation resource_Allocation = new Resource_Allocation();
                    resource_Allocation.resIdFK = IDs;
                    var q3 = db.Skills.Where(x => x.skillName == item.ToString()).FirstOrDefault();
                    if (q3 != null)
                    {
                        resource_Allocation.skillIdFK = q3.skillId;
                    }
                    db.Resource_Allocation.Add(resource_Allocation);
                }
                try
                {
                    db.SaveChanges();
                    MessageBox.Show("Sucess!");
                    this.Hide();
                    Resourcemanagement lol1 = new Resourcemanagement();
                    lol1.Show();
                }
                catch (Exception es)
                {
                    MessageBox.Show(es.ToString());
                }
            }
            else
            {
                MessageBox.Show("Sucess!");
                this.Hide();
                Resourcemanagement lol1 = new Resourcemanagement();
                lol1.Show();
            }
        }