示例#1
0
        private void AddNew()
        {
            try
            {
                string        vMaKhoa = MaSo;
                Class_Subject sj      = new Class_Subject
                {
                    MaMon  = txtSubjectID.Text.Trim(),
                    TenMon = txtSubjectName.Text.Trim(),
                    Khoa   = txtKhoa.Text.Trim()
                };

                int result = da.ExecuteData(sj.ToInsertQuery(), sj.ToParameters());
                if (result > 0)
                {
                    MessageBox.Show("Success");
                    ButtonClick = "";
                    ViewMode();
                    LoadData();
                }
                else
                {
                    MessageBox.Show("Failed");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error! " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
 private void EditData()
 {
     try
     {
         Class_Subject sj = new Class_Subject
         {
             MaMon  = txtSubjectID.Text,
             TenMon = txtSubjectName.Text,
             Khoa   = txtKhoa.Text
         };
         int result = da.ExecuteData(sj.ToUpdateQuery(), sj.ToParameters());
         if (result > 0)
         {
             MessageBox.Show("Success");
             ButtonClick = "";
             ViewMode();
             LoadData();
         }
         else
         {
             MessageBox.Show("Failed");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi! " + ex.Message, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#3
0
        public static List <KeyValuePair <string, object> > ToParameters(this Class_Subject sj)
        {
            var parameters = new List <KeyValuePair <string, object> >();

            parameters.Add(new KeyValuePair <string, object>("MaMon", sj.MaMon));
            parameters.Add(new KeyValuePair <string, object>("TenMon", sj.TenMon));
            parameters.Add(new KeyValuePair <string, object>("Khoa", sj.Khoa));
            //parameters.Add(new KeyValuePair<string, object>("NhanVienCoiThi", sj.NhanVienCoiThi));

            return(parameters);
        }
示例#4
0
 public static string ToUpdateQuery(this Class_Subject sj)
 {
     return(@"UPDATE DANHSACHMONTHI
             SET TenMon = @TenMon, Khoa = @Khoa WHERE MaMon = @MaMon");
 }
示例#5
0
 public static string ToInsertQuery(this Class_Subject sj)
 {
     return(@"INSERT INTO DANHSACHMONTHI(MaMon, TenMon, Khoa) VALUES (@MaMon, @TenMon, @Khoa)");
 }