Example #1
0
        private void butsua_Click(object sender, EventArgs e)
        {
            if (txtma.Text == "" || cbxmagv.Text == "")
            {
                MessageBox.Show("Chưa nhập đủ thông tin!");
                return;
            }

            lop l = new lop();

            l.malh       = txtma.Text;
            l.magvcn     = cbxmagv.Text;
            l.siso       = txtsiso.Text;
            l.namnhaphoc = datenh.Value;
            l.namketthuc = datekt.Value;
            l.tenban     = cbxbh.Text;

            if (MessageBox.Show(string.Format("Bạn có muốn sửa lớp học này không?"),
                                "", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (Bus.UpdateProfile(l) > 0)
                {
                    MessageBox.Show("sửa thành công lớp học !");
                    lophoc_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("sửa bị Lỗi");
                }
            }
        }
Example #2
0
 internal static int DeleteProfile(lop l)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", l.malh),
     };
     return(DataProvider.ExecuteNonQuery("xoalophoc", para));
 }
Example #3
0
 public DialogController(Response <Int32> res, int code, lop l)
 {
     listKhoa      = new KhoaSerivice().getDsKhoa();
     this.response = res;
     InitializeComponent();
     setViewControl(code);
     mCode = code;
     mLop  = l;
 }
Example #4
0
        private void gridLop_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (user.Quyen == Constants.CODE_QUYEN_SV)
            {
                return;
            }
            lop item = (lop)gridLop.CurrentRow.DataBoundItem;

            new DialogController(this, DialogController.CODE_UPDATE, item).Show();
        }
Example #5
0
 public int Update(lop obj)
 {
     SqlParameter[] para =
     {
         new SqlParameter("IDLop",  obj.IDLop),
         new SqlParameter("TenLop", obj.TenLop),
         new SqlParameter("IDKhoi", obj.IDKhoi),
     };
     return(base.ExecuteSQL("Lop_Update", para));
 }
Example #6
0
        public DataTable laydanhsachtentatcalop(lop lp)
        {
            string        sqlLaydanhsachtenlop = "SELECT Tenlop FROM Lop WHERE Tenlop='" + lp.TENLOP + "'";
            SqlConnection con = dc.getConnection();

            adt = new SqlDataAdapter(sqlLaydanhsachtenlop, con);
            DataTable dt = new DataTable();

            adt.Fill(dt);
            return(dt);
        }
Example #7
0
        public DataTable getTenloptheotenKhoa(lop lp)
        {
            string        sqlGettenlop = "SELECT Malop,Tenlop  FROM Lop WHERE Makhoa ='" + lp.MAKHOA + "'";
            SqlConnection con          = dc.getConnection();

            adt = new SqlDataAdapter(sqlGettenlop, con);
            DataTable dt = new DataTable();

            adt.Fill(dt);
            return(dt);
        }
Example #8
0
        private lop getDataFromView()
        {
            String tenLop = txtTenLop.Text;
            String maLop  = txtMaLop.Text;
            String maKhoa = listKhoa[cbbKhoa.SelectedIndex].makhoa;
            lop    lop    = new lop();

            lop.tenlop = tenLop;
            lop.makhoa = maKhoa;
            lop.malop  = maLop;
            return(lop);
        }
Example #9
0
 public static int UpdateProfile(lop l)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@ma", l.malh),
         new SqlParameter("@magv", l.magvcn),
         new SqlParameter("@siso", l.siso),
         new SqlParameter("@nh", l.namnhaphoc),
         new SqlParameter("@kt", l.namketthuc),
         new SqlParameter("@tb", l.tenban)
     };
     return(DataProvider.ExecuteNonQuery("sualophoc", para));
 }
Example #10
0
        private void lollipopButton1_Click(object sender, EventArgs e)
        {
            lop  lop    = getDataFromView();
            bool result = new LopSerivice().themLop(lop);

            if (result)
            {
                this.Hide();
                //refresh list
                response.onResponse(Constants.CODE_LOP);
            }
            else
            {
                MessageBox.Show("Khong the them vao danh sach");
            }
        }
Example #11
0
        public ActionResult DeleteClass(int id)
        {
            try
            {
                lop l = db.lops.SingleOrDefault(m => m.Malop == id);
                db.lops.DeleteOnSubmit(l);
                db.SubmitChanges();
                TempData["message"] = "success";
            }
            catch (Exception ex)
            {
                TempData["message"] = "fail";
            }

            TempData["message2"] = "delete";
            return(RedirectToAction("Classes"));
        }
Example #12
0
        public bool deleteLop(lop lp)
        {
            string        sqlDeleteLop = "DELETE FROM Lop WHERE id =@ID";
            SqlConnection con          = dc.getConnection();

            cm = new SqlCommand(sqlDeleteLop, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@ID", SqlDbType.Int).Value = lp.ID;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Example #13
0
        public int Laytongsosinhvientrongmotlop(lop lp)
        {
            string        sqlLaytongsosinhvientrongmotlop = @"SELECT  COUNT(sv.id) AS tongsv
                                                        FROM    dbo.SinhVien sv
                                                                INNER JOIN dbo.Lop lp ON lp.Malop = sv.Malop
                                                        WHERE   lp.Malop =  '" + lp.MALOP + "'";
            SqlConnection con = dc.getConnection();

            con.Open();
            cm = new SqlCommand(sqlLaytongsosinhvientrongmotlop, con);
            SqlDataReader reader       = cm.ExecuteReader();
            int           Tongsinhvien = 0;

            while (reader.Read())
            {
                Tongsinhvien = Convert.ToInt32(reader["tongsv"].ToString());
            }
            return(Tongsinhvien);
        }
Example #14
0
        public ActionResult AddClass(lop l)
        {
            if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "")
            {
                return(RedirectToAction("Login", "Admin"));
            }
            try
            {
                db.lops.InsertOnSubmit(l);
                db.SubmitChanges();
                TempData["message"] = "success";
            }
            catch (Exception ex)
            {
                TempData["message"] = "fail";
            }

            TempData["message2"] = "add";
            return(RedirectToAction("Classes"));
        }
Example #15
0
 public ActionResult EditClass(lop l)
 {
     if (Session["LoggedAD"] == null || Session["LoggedAD"].ToString() == "")
     {
         return(RedirectToAction("Login", "Admin"));
     }
     try
     {
         lop ll = db.lops.SingleOrDefault(n => n.Malop == l.Malop);
         ll.Tenlop = l.Tenlop == null ? ll.Tenlop : l.Tenlop;
         ll.Makhoa = l.Makhoa;
         db.SubmitChanges();
         TempData["message"] = "success";
     }
     catch (Exception e)
     {
         TempData["message"] = "fail";
     }
     TempData["message2"] = "edit";
     return(RedirectToAction("Classes"));
 }
Example #16
0
        public bool insertLop(lop lp)
        {
            string        sqlInsertLop = "INSERT INTO Lop(Malop,Tenlop,Makhoa) VALUES(@MALOP,@TENLOP,@MAKHOA)";
            SqlConnection con          = dc.getConnection();

            cm = new SqlCommand(sqlInsertLop, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value  = lp.MALOP;
                cm.Parameters.Add("@TENLOP", SqlDbType.NVarChar).Value = lp.TENLOP;
                cm.Parameters.Add("@MAKHOA", SqlDbType.NVarChar).Value = lp.MAKHOA;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Example #17
0
        public bool updateLop(lop lp)
        {
            string        sqlupdateLop = "UPDATE Lop SET Malop=@MALOP ,Tenlop=@TENLOP ,Makhoa=@MAKHOA WHERE id =@ID";
            SqlConnection con          = dc.getConnection();

            cm = new SqlCommand(sqlupdateLop, con);
            try
            {
                con.Open();
                cm.Parameters.Add("@MALOP", SqlDbType.NVarChar).Value  = lp.MALOP;
                cm.Parameters.Add("@TENLOP", SqlDbType.NVarChar).Value = lp.TENLOP;
                cm.Parameters.Add("@MAKHOA", SqlDbType.NVarChar).Value = lp.MAKHOA;
                cm.Parameters.Add("@ID", SqlDbType.Int).Value          = lp.ID;
                cm.ExecuteNonQuery();
                con.Close();
            }
            catch (Exception e)
            {
                return(false);
            }
            return(true);
        }
Example #18
0
        public DataTable Laytatcasinhvientheotunglop(lop lp)
        {
            string        Laytatcasinhvientheotunglop = @"SELECT  sv.id ,
                                                            sv.Masv ,
                                                            sv.Tensv ,
                                                            kh.Tenkhoa ,
                                                            lp.Tenlop ,
                                                            ( CASE sv.Gioitinh
                                                                WHEN 1 THEN N'Nam'
                                                                ELSE N'Nữ'
                                                              END ) AS Gioitinh ,
                                                            sv.Diachi,sv.Image
                                                    FROM    dbo.SinhVien sv
                                                            INNER JOIN dbo.Lop lp ON lp.Malop = sv.Malop
                                                            INNER JOIN dbo.Khoa kh ON kh.Makhoa = lp.Makhoa
                                                    WHERE   lp.Malop = '" + lp.MALOP + "'";
            SqlConnection con = dc.getConnection();

            adt = new SqlDataAdapter(Laytatcasinhvientheotunglop, con);
            DataTable dt = new DataTable();

            adt.Fill(dt);
            return(dt);
        }
Example #19
0
 public bool insertLop(lop lp)
 {
     return(lop_dal.insertLop(lp));
 }
Example #20
0
 public static int UpdateProfile(lop l)
 {
     return(Dao.UpdateProfile(l));
 }
Example #21
0
 public DataTable laydanhsachtentatcalop(lop lp)
 {
     return(lop_dal.laydanhsachtentatcalop(lp));
 }
Example #22
0
 public DataTable getTenloptheotenKhoa(lop lp)
 {
     return(lop_dal.getTenloptheotenKhoa(lp));
 }
Example #23
0
 public bool deleteLop(lop lp)
 {
     return(lop_dal.deleteLop(lp));
 }
Example #24
0
 public bool suaLop(lop lop)
 {
     return(new LopController().UpdateLop(lop));
 }
Example #25
0
 public static int InsertProfile(lop l)
 {
     return(Dao.InsertProfile(l));
 }
Example #26
0
 public static int DeleteProfile(lop l)
 {
     return(Dao.DeleteProfile(l));
 }
Example #27
0
 public bool themLop(lop lop)
 {
     return(new LopController().insertLop(lop));
 }
Example #28
0
 public bool updateLop(lop lp)
 {
     return(lop_dal.updateLop(lp));
 }
Example #29
0
 public bool xoaLop(lop lop)
 {
     return(new LopController().deleteLop(lop));
 }
Example #30
0
 public int Update(lop obj)
 {
     return(dao.Update(obj));
 }