//them public bool addXEPHANG(DTO_XEPHANG d) { try { connect.Open(); string sql = "INSERT INTO XEPHANG(MaGiai,MaDoi,TongDiem,HieuSo,ViThu) VALUES (@MAG,@MAD,@SUM,@SUB,@RANK)"; SqlCommand cmd = new SqlCommand(sql, connect); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@MAG", d.MaGiai)); cmd.Parameters.Add(new SqlParameter("@MAD", d.MaDoi)); cmd.Parameters.Add(new SqlParameter("@SUM", (object)d.TongDiem ?? DBNull.Value)); cmd.Parameters.Add(new SqlParameter("@SUB", (object)d.HieuSo ?? DBNull.Value)); cmd.Parameters.Add(new SqlParameter("@RANK", (object)d.ViThu ?? DBNull.Value)); //kiem tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { //close connect connect.Close(); } return(false); }
//sua public bool upXEPHANG(DTO_XEPHANG d) { try { connect.Open(); string sql = "UPDATE XEPHANG SET ViThu=@RANK WHERE MaGiai=@MAG AND MaDoi=@MAD AND TongDiem=@SUM AND HieuSo=@SUB"; SqlCommand cmd = new SqlCommand(sql, connect); cmd.CommandType = CommandType.Text; cmd.Parameters.Add(new SqlParameter("@MAG", d.MaGiai)); cmd.Parameters.Add(new SqlParameter("@MAD", d.MaDoi)); cmd.Parameters.Add(new SqlParameter("@SUM", (object)d.TongDiem ?? DBNull.Value)); cmd.Parameters.Add(new SqlParameter("@SUB", (object)d.HieuSo ?? DBNull.Value)); cmd.Parameters.Add(new SqlParameter("@RANK", (object)d.ViThu ?? DBNull.Value)); //kiem tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { connect.Close(); } return(false); }
public void addRank(int loai, string mag) { DataTable t = new DataTable(); if (loai == 1) { t = SortwithHieu(mag); for (int i = 0; i < t.Rows.Count; i++) { string mad = t.Rows[i].Field <string>(1); object o = t.Rows[i].Field <int?>(2); int? tong = o == DBNull.Value ? null : (int?)o; o = t.Rows[i].Field <int?>(3); int? hieu = o == DBNull.Value ? null : (int?)o; int? vithu = i + 1; DTO_XEPHANG dtox = new DTO_XEPHANG(mag, mad, tong, hieu, vithu); upXEPHANG(dtox); } } else { t = SortwithTong(mag); for (int i = 0; i < t.Rows.Count; i++) { string mad = t.Rows[i].Field <string>(1); object o = t.Rows[i].Field <int?>(2); int? tong = o == DBNull.Value ? null : (int?)o; o = t.Rows[i].Field <int?>(3); int? hieu = o == DBNull.Value ? null : (int?)o; int? vithu = i + 1; DTO_XEPHANG dtox = new DTO_XEPHANG(mag, mad, tong, hieu, vithu); upXEPHANG(dtox); } } }
public void ListRank(string mag) { BUS_DOI d = new BUS_DOI(); DataTable diem = getSoDiem(mag); DataTable hieu = getHieuSo(mag); for (int i = 0; i < diem.Rows.Count; i++) { string ten = diem.Rows[i].Field <string>(0); string mad = d.getMa(ten); int tong = diem.Rows[i].Field <int>(1); int h = hieu.Rows[i].Field <int>(1); DTO_XEPHANG dtox = new DTO_XEPHANG(mag, mad, tong, h, null); if (CheckTrung(mag, mad)) { addXEPHANG(dtox); } } }
//xoa public bool delXEPHANG(DTO_XEPHANG d) { try { connect.Open(); string sql = string.Format("DELETE FROM XEPHANG WHERE MaGiai='{0}'", d.MaGiai); SqlCommand cmd = new SqlCommand(sql, connect); //kiem tra if (cmd.ExecuteNonQuery() > 0) { return(true); } } catch (Exception e) { } finally { connect.Close(); } return(false); }
public bool delXEPHANG(DTO_XEPHANG g) { return(dalXEPHANG.delXEPHANG(g)); }
public bool upXEPHANG(DTO_XEPHANG g) { return(dalXEPHANG.upXEPHANG(g)); }
public bool addXEPHANG(DTO_XEPHANG g) { return(dalXEPHANG.addXEPHANG(g)); }