private void Save(string MaLichTrinhChon, LichTrinh lichTrinh, ref bool allowInsert)
 {
     try
     {
         //insert
         if (allowInsert)
         {
             ATINChamCongEntities context = new ATINChamCongEntities();
             context.spInsertLichTrinh(
                 lichTrinh.MaLichTrinh,
                 lichTrinh.TenLichTrinh,
                 lichTrinh.LoaiChuKy
                 );
             if (checkBox1.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC1");
             }
             if (checkBox2.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC2");
             }
             if (checkBox3.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC3");
             }
             if (checkBox4.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC4");
             }
             if (checkBox5.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC5");
             }
         }
         //update
         else
         {
             ATINChamCongEntities context = new ATINChamCongEntities();
             context.spUpdateLichTrinh(
                 MaLichTrinhChon,
                 lichTrinh.MaLichTrinh,
                 lichTrinh.TenLichTrinh,
                 lichTrinh.LoaiChuKy
                 );
             if (checkBox1.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC1");
             }
             else
             {
                 context.spDeleteMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC1");
             }
             if (checkBox2.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC2");
             }
             else
             {
                 context.spDeleteMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC2");
             }
             if (checkBox3.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC3");
             }
             else
             {
                 context.spDeleteMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC3");
             }
             if (checkBox4.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC4");
             }
             else
             {
                 context.spDeleteMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC4");
             }
             if (checkBox5.Checked)
             {
                 context.spInsertMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC5");
             }
             else
             {
                 context.spDeleteMapLichTrinhNangCao(lichTrinh.MaLichTrinh, "NC5");
             }
         }
     }
     catch (Exception e)
     {
         MessageBox.Show(e.Message);
     }
 }