Exemplo n.º 1
0
        public ActionResult Insert(FormCollection form, HttpPostedFileBase[] txtFile)
        {
            tblConsignment con = new tblConsignment();

            con.DispatchDate = Convert.ToDateTime(form["txtDate"]);
            //con.ProfilePic = name.ToString();
            con.UnitType  = form["unittype"];
            con.UnitValue = Convert.ToInt32(form["txtValue"]);
            con.UserId    = Convert.ToInt32(Session["LogID"]);
            string val = form["chkflame"];

            if (form["chkflame"] == "on")
            {
                con.IsFlamable = true;
            }
            if (form["chkdelicate"] == "on")
            {
                con.IsDelicate = true;
            }
            if (form["chkrefregerated"] == "on")
            {
                con.IsRefregreted = true;
            }
            con.Distance = form["txtDistance"];
            dc.tblConsignments.Add(con);
            dc.SaveChanges();
            int LastID = (from ob in dc.tblConsignments orderby ob.ConsignmentId descending select ob).Take(1).SingleOrDefault().ConsignmentId;

            Session["LastID"] = LastID;
            string name = "txtFile";

            if (txtFile != null)
            {
                foreach (HttpPostedFileBase file in txtFile)
                {
                    int size      = (int)file.ContentLength / 1024;
                    var extention = System.IO.Path.GetExtension(file.FileName);
                    if (size <= 1024 && (extention.ToLower().Equals(".jpg") || extention.ToLower().Equals(".jpeg") || extention.ToLower().Equals(".png")))
                    {
                        name = code() + "" + extention;
                        string path = Server.MapPath("~/Images/");
                        file.SaveAs(path + "" + name);
                        tblConSignmentImage img = new tblConSignmentImage();
                        img.ConsignmentID = LastID;
                        img.ImageURL      = name;
                        img.IsActive      = true;
                        dc.tblConSignmentImages.Add(img);
                    }
                }
                dc.SaveChanges();
            }

            return(RedirectToAction("Insert2", "ClientConsignment"));
        }
Exemplo n.º 2
0
        public JsonResult Active(int id)
        {
            tblConSignmentImage consignment = dc.tblConSignmentImages.SingleOrDefault(ob => ob.ConsignmentImageId == id);

            if (consignment.IsActive == true)
            {
                consignment.IsActive = false;
            }
            else
            {
                consignment.IsActive = true;
            }
            dc.SaveChanges();
            return(Json(consignment.IsActive, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Detail(int id)
        {
            tblConSignmentImage consignment = dc.tblConSignmentImages.SingleOrDefault(ob => ob.ConsignmentImageId == id);

            return(View(consignment));
        }