public ActionResult SaveRegist(gov_testscore item)
        {
            if (Session.getCurrentUser() == null)
                return Redirect("/admin/account/logon");
            if (!SercurityServices.HasPermission((int)TypeModule.MODULE_DIEMTHI, Session.getCurrentUser().username, TypeAudit.Addnew))
            {
                return Redirect("/admin/error/error403");
            }
            if (Request.Files.Count > 0)
            {
                // Add file in App_data
                var fileName = string.Empty;
                var file = Request.Files[0];
                var bytes = new byte[file.ContentLength];
                if (bytes.Length > 0)
                {
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    fileName = (file.FileName.IndexOf('\\') != -1 ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1) : file.FileName);
                    fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + fileName;

                    var fileDir = FileRepository.RootStorage;
                    if (!System.IO.Directory.Exists(fileDir))
                        System.IO.Directory.CreateDirectory(fileDir);
                    var filePath = fileDir + "\\" + fileName;
                    System.IO.File.WriteAllBytes(filePath, bytes);
                    
                    //Add file in Upload
                    var fileDirChirld = FileRepository.ChirldStorage;
                    if (!System.IO.Directory.Exists(fileDirChirld))
                        System.IO.Directory.CreateDirectory(fileDirChirld);
                    var filePathChirld = fileDirChirld + "\\" + fileName;
                    System.IO.File.WriteAllBytes(filePathChirld, bytes);

                    String fileFormat = fileName.Substring(fileName.LastIndexOf("."));
                    item.file_format = fileFormat;
                    item.attach_file_name = fileName;
                }
            }
            item.entry_datetime = DateTime.Now;
            item.entry_username = Session.getCurrentUser().username;
            item.update_datetime = DateTime.Now;
            item.update_username = Session.getCurrentUser().username;
            try
            {
                _cnttDB.gov_testscore.Add(item);
                int rs = _cnttDB.SaveChanges();
                if (rs > 0)
                {
                    insertHistory(AccessType.themMoiDiemThi, Constant.THEM(Constant.ITEM_DIEMTHI, Constant.ID, item.id.ToString()));
                    TempData["message"] = "Thêm mới thông tin thành công!";
                }
                else
                {
                    TempData["err"] = "Đã có lỗi xảy ra. Thêm mới thông tin thất bại!";
                }
            }
            catch (Exception ex)
            {
                TempData["err"] = "Đã có lỗi xảy ra. Thêm mới thông tin thất bại!";
            }
            return Redirect("Index");
        }
        public ActionResult SaveEdit(gov_testscore item)
        {
            if (Session.getCurrentUser() == null)
                return Redirect("/admin/account/logon");
            if (!SercurityServices.HasPermission((int)TypeModule.MODULE_DIEMTHI, Session.getCurrentUser().username, TypeAudit.Edit))
            {
                return Redirect("/admin/error/error403");
            }
            gov_testscore testscoreInfo = _cnttDB.gov_testscore.Find(item.id);
            if (Request.Files.Count > 0)
            {
                var fileName = string.Empty;
                var file = Request.Files[0];
                var bytes = new byte[file.ContentLength];
                if (bytes.Length > 0)
                {
                    //Delete file App_data
                    var filePathDelete = FileRepository.RootStorage + "\\" + testscoreInfo.attach_file_name;
                    if (System.IO.File.Exists(filePathDelete))
                    {
                        System.IO.File.Delete(filePathDelete);
                    }

                    //Delete file Upaload
                    filePathDelete = FileRepository.ChirldStorage + "\\" + testscoreInfo.attach_file_name;
                    if (System.IO.File.Exists(filePathDelete))
                    {
                        System.IO.File.Delete(filePathDelete);
                    }

                    // App_data
                    file.InputStream.Read(bytes, 0, file.ContentLength);
                    fileName = (file.FileName.IndexOf('\\') != -1 ? file.FileName.Substring(file.FileName.LastIndexOf('\\') + 1) : file.FileName);
                    fileName = DateTime.Now.ToString("yyyyMMddHHmmss") + fileName;

                    var fileDir = FileRepository.RootStorage;
                    if (!System.IO.Directory.Exists(fileDir))
                        System.IO.Directory.CreateDirectory(fileDir);
                    var filePath = fileDir + "\\" + fileName;
                    System.IO.File.WriteAllBytes(filePath, bytes);

                    //Add file in Upload
                    var fileDirChirld = FileRepository.ChirldStorage;
                    if (!System.IO.Directory.Exists(fileDirChirld))
                        System.IO.Directory.CreateDirectory(fileDirChirld);
                    var filePathChirld = fileDirChirld + "\\" + fileName;
                    System.IO.File.WriteAllBytes(filePathChirld, bytes);

                    String fileFormat = fileName.Substring(fileName.LastIndexOf("."));
                    testscoreInfo.file_format = fileFormat;
                    testscoreInfo.attach_file_name = fileName;
                }
            }
            testscoreInfo.test_class = item.test_class;
            testscoreInfo.namhoc = item.namhoc;
            testscoreInfo.test_name = item.test_name;
            testscoreInfo.kythi = item.kythi;
            testscoreInfo.update_datetime = DateTime.Now;
            testscoreInfo.update_username = Session.getCurrentUser().username;
            try
            {
                int rs = _cnttDB.SaveChanges();
                if (rs > 0)
                {
                    insertHistory(AccessType.chinhSuaDiemThi, Constant.CHINHSUA(Constant.ITEM_DIEMTHI, Constant.ID, item.id.ToString()));
                    TempData["message"] = "Cập nhật thông tin thành công!";
                }
                else
                {
                    TempData["err"] = "Đã có lỗi xảy ra. Cập nhật thông tin thất bại!";
                }
            }
            catch (Exception ex)
            {
                TempData["err"] = "Đã có lỗi xảy ra. Cập nhật thông tin thất bại!";
            }
            return Redirect("Index");
        }