コード例 #1
0
        public ActionResult DeleteCheck(long ma)
        {
            bool status = false;

            status = new CheckDao().Delete(ma);
            return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult DetailCheck(long ma, int id)
        {
            CheckModel model = new CheckModel();

            model = new CheckDao().detail(ma, id);
            if (!model.CO.HasValue)
            {
                model.CO = false;
            }
            if (!model.CQ.HasValue)
            {
                model.CO = false;
            }
            if (!model.MTR.HasValue)
            {
                model.MTR = false;
            }
            if (!model.SN.HasValue)
            {
                model.SN = false;
            }
            if (!model.PN.HasValue)
            {
                model.PN = false;
            }
            if (!model.Other.HasValue)
            {
                model.Other = false;
            }
            if (!model.Result.HasValue)
            {
                model.Result = false;
            }
            return(PartialView("_DetailApproval", model));
        }
コード例 #3
0
        public void ExportExcel(int ma)
        {
            using (FileStream template = System.IO.File.OpenRead(Server.MapPath("/Reports/PhieuKiemTra.xlsx")))
            {
                using (ExcelPackage package = new ExcelPackage(template))
                {
                    ExcelWorksheet sheet    = package.Workbook.Worksheets["Sheet1"];
                    var            tbl      = new CheckDao().load(ma);
                    int            rowindex = 10;
                    int            count    = 1;
                    if (tbl.Count > 0)
                    {
                        sheet.InsertRow(rowindex + 1, tbl.Count);

                        //sheet.Cells["B10:AU10"].Copy(sheet.Cells["B11:AU" + (tbl.Count + rowindex + 1)]);
                        sheet.Cells[5, 9].Value  = tbl[0].Ten_BP.ToString();
                        sheet.Cells[6, 9].Value  = tbl[0].DiaDiem.ToString();
                        sheet.Cells[6, 26].Value = string.IsNullOrEmpty(tbl[0].Date.ToString()) ? null : string.Format("{0:dd/MM/yyyy}", tbl[0].Date);
                        foreach (var item in tbl)
                        {
                            sheet.Cells[rowindex, 2, rowindex, 47].Copy(sheet.Cells[rowindex + 1, 2, rowindex + 1, 47]);
                            sheet.Cells[rowindex, 2].Value  = count.ToString();
                            sheet.Cells[rowindex, 4].Value  = item.DeXuat;
                            sheet.Cells[rowindex, 7].Value  = item.HopDong;
                            sheet.Cells[rowindex, 9].Value  = item.Ten_NCC;
                            sheet.Cells[rowindex, 12].Value = item.Ten_TB;
                            sheet.Cells[rowindex, 18].Value = item.YC_KT;
                            sheet.Cells[rowindex, 22].Value = item.TT_KT;
                            sheet.Cells[rowindex, 26].Value = item.YC_SL.ToString();
                            sheet.Cells[rowindex, 28].Value = item.TT_SL.ToString();
                            sheet.Cells[rowindex, 30].Value = item.DonVi;
                            sheet.Cells[rowindex, 32].Value = item.CO.ToString() == "True" ? "Có" : "Không";
                            sheet.Cells[rowindex, 34].Value = item.CQ.ToString() == "True" ? "Có" : "Không";
                            sheet.Cells[rowindex, 36].Value = item.MTR.ToString() == "True" ? "Có" : "Không";
                            sheet.Cells[rowindex, 38].Value = item.SN.ToString() == "True" ? "Có" : "Không";
                            sheet.Cells[rowindex, 40].Value = item.PN.ToString() == "True" ? "Có" : "Không";
                            sheet.Cells[rowindex, 42].Value = string.IsNullOrEmpty(item.Note_Other) ? "Không Có" : "Có";
                            sheet.Cells[rowindex, 44].Value = string.IsNullOrEmpty(item.Reason) ? "Đạt" : "Không Đạt";

                            rowindex++;
                            count++;
                        }
                    }
                    Response.ClearContent();
                    Response.BinaryWrite(package.GetAsByteArray());
                    Response.AddHeader("content-disposition",
                                       "attachment;filename=results.xlsx");
                    Response.ContentType = "application/excel";
                    Response.Flush();
                    Response.End();
                }
            }
        }
コード例 #4
0
        public ActionResult DetailCheck(long ma, int id)
        {
            if (new Commom().CheckPermission(id))
            {
                return(Json("Error", JsonRequestBehavior.AllowGet));
            }
            ViewBag.Provider = new SelectList(new ProviderDao().load(), "Ma_NCC", "Ten_NCC");
            ViewBag.Equip    = new SelectList(new EquipmentDao().load(), "Ma_TB", "Ten_TB");
            CheckModel model = new CheckModel();

            model.RequestId = id;
            if (ma > 0)
            {
                model = new CheckDao().detail(ma, id);
            }

            return(PartialView("_DetailCheck", model));
        }
コード例 #5
0
        public ActionResult SendEmail()
        {
            int                ma   = int.Parse(Request.Form["ma"]);
            string             code = Request.Form["code"];
            HttpPostedFileBase file = null;

            if (Request.Files.Count > 0)
            {
                file = Request.Files[0];
                string extension = Path.GetExtension(file.FileName);
                string filename  = ma.ToString() + extension;
                if (System.IO.File.Exists(Server.MapPath("/Files/FilesReponse/" + filename)))
                {
                    System.IO.File.Delete(Server.MapPath("/Files/FilesReponse/" + filename));
                }
                file.SaveAs(Server.MapPath("/Files/FilesReponse/" + filename));
            }

            var check = new CheckDao().load(ma);

            if (!check.Any(m => m.Result == null))
            {
                new CheckDao().SaveAutho(ma, code);
                bool result = false;
                //lấy thông tin  email
                string template = System.IO.File.ReadAllText(HttpContext.Server.MapPath("~/Files/Templates/Reponse.html"));
                var    tbl      = new Commom().respone(ma);
                tbl.Date_Autho = DateTime.Now.ToString("dd/MM/yyyy");
                tbl.Url        = Request.Url.GetLeftPart(UriPartial.Authority) + "/Requests/CheckList?ma=" + tbl.Id;
                tbl.UrlFile    = Request.Url.GetLeftPart(UriPartial.Authority) + "/Files/FilesReponse/" + ma.ToString() + ".pdf";
                var    email = new UserDao().load().Where(m => m.UserName.Equals(tbl.User_Nhap)).FirstOrDefault();
                string body  = Engine.Razor.RunCompile(template, "templatekey", null, tbl);
                // gửi email
                result = new Commom().SendEmail(email.Email, "Mail Phản Hồi Thông Báo Kiểm Tra - " + tbl.Hang_Muc, body);
                return(Json(new { status = result }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { status = "Error" }, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #6
0
 public ActionResult SaveCheck(CheckModel data)
 {
     if (ModelState.IsValid)
     {
         data.User_Nhap = HttpContext.User.Identity.Name;
         bool status;
         if (data.Id > 0)
         {
             status = new CheckDao().Update(data);
             return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
         }
         else
         {
             status = new CheckDao().Save(data);
             return(Json(new { status = status }, JsonRequestBehavior.AllowGet));
         }
     }
     ViewBag.Provider = new SelectList(new ProviderDao().load(), "Ma_NCC", "Ten_NCC");
     ViewBag.Equip    = new SelectList(new EquipmentDao().load(), "Ma_TB", "Ten_TB");
     return(PartialView("_DetailCheck", data));
 }
コード例 #7
0
        public ActionResult LoadCheck(int id)
        {
            var model = new CheckDao().load(id);

            return(Json(new { data = model }, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public ActionResult LoadNote(long ma)
        {
            string reason = new CheckDao().LoadReason(ma).Note_Other;

            return(Json(new { reason = reason }, JsonRequestBehavior.AllowGet));
        }