예제 #1
0
        public ActionResult LodgeComplain([Bind(Include = "SecurityGuardDetailID,SecurityGuardID,Description,Tdate,Path,UploadedFile")] SecurityDets detail)
        {
            SecurityGuardDetail res = new SecurityGuardDetail()
            {
                Description = detail.Description,

                SecurityGuardDetailID = detail.SecurityGuardDetailID,
                SecurityGuardID       = detail.SecurityGuardID,
                Tdate = DateTime.Now,
            };

            if (detail.UploadedFile != null)
            {
                string fn = detail.UploadedFile.FileName.Substring(detail.UploadedFile.FileName.LastIndexOf('\\') + 1);
                fn = detail.SecurityGuardID + "_" + fn;
                string SavePath = System.IO.Path.Combine(Server.MapPath("~/Images"), fn);
                detail.UploadedFile.SaveAs(SavePath);

                //System.Drawing.Bitmap upimg = new System.Drawing.Bitmap(siteTransaction.UploadedFile.InputStream);
                //System.Drawing.Bitmap svimg = MyExtensions.CropUnwantedBackground(upimg);
                //svimg.Save(System.IO.Path.Combine(Server.MapPath("~/Images"), fn));

                res.Path = fn;
            }
            else
            {
                res.Path = detail.Path;
            }
            base.BaseSave <SecurityGuardDetail>(res, detail.SecurityGuardDetailID > 0);
            return(RedirectToAction("LodgeComplain", new { id = detail.SecurityGuardID }));
        }
예제 #2
0
        public ActionResult LodgeComplain(int?Eid, int?id)
        {
            ViewBag.SecGuard = db.FirstOrDefault <SecurityGuard>("Select * From SecurityGuard Where SecurityGuardID = @0", id);
            ViewBag.Dets     = db.Fetch <SecurityGuardDetail>("Select * from SecurityGuardDetails where SecurityGuardID = @0", id);
            var rec = base.BaseCreateEdit <SecurityGuardDetail>(Eid, "SecurityGuardDetailID");

            if (Eid != null)
            {
                SecurityDets ci = new SecurityDets()
                {
                    Description           = rec.Description,
                    Path                  = rec.Path,
                    SecurityGuardDetailID = rec.SecurityGuardDetailID,
                    SecurityGuardID       = (int)rec.SecurityGuardID,
                    Tdate                 = (DateTime)rec.Tdate,
                }; return(View(ci));
            }
            else
            {
                SecurityDets ci = new SecurityDets()
                {
                };
                return(View(ci));
            }
        }