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"); } } }
internal static int DeleteProfile(lop l) { SqlParameter[] para = new SqlParameter[] { new SqlParameter("@ma", l.malh), }; return(DataProvider.ExecuteNonQuery("xoalophoc", para)); }
public DialogController(Response <Int32> res, int code, lop l) { listKhoa = new KhoaSerivice().getDsKhoa(); this.response = res; InitializeComponent(); setViewControl(code); mCode = code; mLop = l; }
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(); }
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)); }
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); }
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); }
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); }
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)); }
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"); } }
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")); }
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); }
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); }
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")); }
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")); }
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); }
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); }
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); }
public bool insertLop(lop lp) { return(lop_dal.insertLop(lp)); }
public static int UpdateProfile(lop l) { return(Dao.UpdateProfile(l)); }
public DataTable laydanhsachtentatcalop(lop lp) { return(lop_dal.laydanhsachtentatcalop(lp)); }
public DataTable getTenloptheotenKhoa(lop lp) { return(lop_dal.getTenloptheotenKhoa(lp)); }
public bool deleteLop(lop lp) { return(lop_dal.deleteLop(lp)); }
public bool suaLop(lop lop) { return(new LopController().UpdateLop(lop)); }
public static int InsertProfile(lop l) { return(Dao.InsertProfile(l)); }
public static int DeleteProfile(lop l) { return(Dao.DeleteProfile(l)); }
public bool themLop(lop lop) { return(new LopController().insertLop(lop)); }
public bool updateLop(lop lp) { return(lop_dal.updateLop(lp)); }
public bool xoaLop(lop lop) { return(new LopController().deleteLop(lop)); }
public int Update(lop obj) { return(dao.Update(obj)); }