Exemple #1
0
 public static List<MonHoc> LoadListFromReader(IDataReader reader)
 {
     List<MonHoc> items = new List<MonHoc>();
     try
     {
         while (reader.Read())
         {
             MonHoc item = new MonHoc();
             try { item.MonHocGuid = new Guid(reader["MonHocGuid"].ToString()); }
             catch { }
             item.MonHocName = reader["MonHocName"].ToString();
             item.MonHocID = reader["MonHocID"].ToString();
             try { item.Userid = Convert.ToInt32(reader["Userid"].ToString()); }
             catch { }
             items.Add(item);
         }
     }
     catch
     { }
     finally
     {
         reader.Close();
     }
     return items;
 }
Exemple #2
0
 /// <summary>
 /// Inserts a row in the gv_MonHoc table. Returns rows affected count.
 /// </summary>
 /// <returns>int</returns>
 public int Create(MonHoc item)
 {
     SqlParameterHelper sph = new SqlParameterHelper(ConnectionStringStatic.GetWriteConnectionString(), "gv_MonHoc_Chuongtv31072015_Insert", 5);
     sph.DefineSqlParameter("@MonHocGuid", SqlDbType.UniqueIdentifier, ParameterDirection.Input, item.MonHocGuid);
     sph.DefineSqlParameter("@MonHocName", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.MonHocName);
     sph.DefineSqlParameter("@MonHocID", SqlDbType.NVarChar, 256, ParameterDirection.Input, item.MonHocID);
     sph.DefineSqlParameter("@Userid", SqlDbType.Int, ParameterDirection.Input, item.Userid);
     sph.DefineSqlParameter("@SoBuoiGiangDay", SqlDbType.Int, ParameterDirection.Input, item.SoBuoiGiangDay);
     int rowsAffected = sph.ExecuteNonQuery();
     return rowsAffected;
 }
 public ActionResult CreateChuongTrinhGiangDay(MonHoc item)
 {
     var flagCreate = false;
     if (item.MonHocGuid == null || item.MonHocGuid == Guid.Empty)
     {
         item.MonHocGuid = Guid.Empty;
         flagCreate = true;
     }
     Guid trangThai = itemBAL.Save(item);
     if (trangThai != Guid.Empty)
         if (flagCreate)
             return JavaScript("ClosePopupAndLoadDataChuong('#modalCreateMon','#thongtindanhsachmonhoc','Thực hiện thành công')");
         else
             return JavaScript("ClosePopupAndLoadDataEditChuong('#modalEditMon','#thongtindanhsachmonhoc','Thực hiện thành công')");
     return View();
 }
Exemple #4
0
        public static MonHoc PopulateFromReader(IDataReader reader)
        {
            MonHoc item = new MonHoc();
            if (reader.Read())
            {
                try { item.MonHocGuid = new Guid(reader["MonHocGuid"].ToString()); }
                catch { }
                item.MonHocName = reader["MonHocName"].ToString();
                item.MonHocID = reader["MonHocID"].ToString();
                try { item.Userid = Convert.ToInt32(reader["Userid"].ToString()); }
                catch { }
                try
                {
                    item.SoBuoiGiangDay = Convert.ToInt32(reader["SoBuoiGiangDay"].ToString());

                }
                catch { }
            }

            return item;
        }
Exemple #5
0
        internal static List<MonHoc> LoadListFromReaderForList(IDataReader reader)
        {
            List<MonHoc> items = new List<MonHoc>();
            try
            {
                while (reader.Read())
                {
                    MonHoc item = new MonHoc();
                    try { item.MonHocGuid = new Guid(reader["MonHocGuid"].ToString()); }
                    catch { }
                    item.MonHocName = reader["MonHocName"].ToString();
                    item.MonHocID = reader["MonHocID"].ToString();
                    try { item.Userid = Convert.ToInt32(reader["Userid"].ToString()); }
                    catch { }
                    try { item.BuoiGiangGuid = new Guid(reader["BuoiGiangGuid"].ToString()); }
                    catch { }
                    item.BuoiGiangID = reader["BuoiGiangID"].ToString();
                    item.BuoiGiangName = reader["BuoiGiangName"].ToString();
                    item.ClientFileName = reader["ClientFileName"].ToString();
                    item.ServerFileName = reader["ServerFileName"].ToString();
                    item.FileSize = reader["FileSize"].ToString();
                    try { item.FileSystemGuid = new Guid(reader["FileSystemGuid"].ToString()); }
                    catch { }
                    items.Add(item);
                }
            }
            catch
            { }
            finally
            {
                reader.Close();
            }
            List<MonHoc> Returnitems = new List<MonHoc>();
            int i = 0;
            bool flag = false;
            int count = items.Count;
            if (count > 0)
            {
                MonHoc m = new MonHoc();
                BuoiGiangDay b;
                while (i < count)
                {
                    if (flag == false)
                    {
                        m = new MonHoc();
                        m.MonHocGuid = items[i].MonHocGuid;
                        m.MonHocName = items[i].MonHocName;
                        m.MonHocID = items[i].MonHocID;
                        m.DanhSachBuoiGiangDay = new List<BuoiGiangDay>();

                        b = new BuoiGiangDay();
                        b.BuoiGiangGuid = items[i].BuoiGiangGuid;
                        b.BuoiGiangID = items[i].BuoiGiangID;
                        b.BuoiGiangName = items[i].BuoiGiangName;
                        b.ClientFileName = items[i].ClientFileName;
                        b.ServerFileName = items[i].ServerFileName;
                        b.FileSize = items[i].FileSize;
                        b.FileSystemGuid = items[i].FileSystemGuid;

                        m.DanhSachBuoiGiangDay.Add(b);
                        i++;
                        if (i >= count)
                        {
                            Returnitems.Add(m);
                            break;
                        }
                    }
                    if (items[i].MonHocGuid == items[i - 1].MonHocGuid)
                    {
                        b = new BuoiGiangDay();
                        b.BuoiGiangGuid = items[i].BuoiGiangGuid;
                        b.BuoiGiangID = items[i].BuoiGiangID;
                        b.BuoiGiangName = items[i].BuoiGiangName;
                        b.ClientFileName = items[i].ClientFileName;
                        b.ServerFileName = items[i].ServerFileName;
                        b.FileSize = items[i].FileSize;
                        b.FileSystemGuid = items[i].FileSystemGuid;
                        m.DanhSachBuoiGiangDay.Add(b);
                        flag = true;
                        i++;
                        if (i >= count)
                            Returnitems.Add(m);
                    }
                    else
                    {
                        flag = false;
                    }

                    if (flag == false)
                        Returnitems.Add(m);

                }
            }
            return Returnitems;
        }
Exemple #6
0
 private Guid Create(MonHoc item)
 {
     MonHocDAL itemDAL = new MonHocDAL();
     item.MonHocGuid = Guid.NewGuid();
     int rowsAffected = itemDAL.Create(item);
     return rowsAffected > 0 ? item.MonHocGuid : Guid.Empty;
 }
Exemple #7
0
 // <summary>
 /// Saves this instance of MonHoc. Returns a new Guid on success.
 /// </summary>
 public Guid Save(MonHoc item)
 {
     if (item.MonHocGuid == Guid.Empty)
         return Create(item);
     return Update(item);
 }
Exemple #8
0
 private Guid Update(MonHoc item)
 {
     MonHocDAL itemDAL = new MonHocDAL();
     return itemDAL.Update(item) ? item.MonHocGuid : Guid.Empty;
 }
 public ActionResult CreateMon_View(int? id)
 {
     MonHoc item = new MonHoc();
     item.Userid = id == null ? 0 : Convert.ToInt32(id);
     return PartialView("_PartialThemMoiMonGiangDay", item);
 }