예제 #1
0
        //public ActionResult Edit([Bind(Include = "PartId,CustomerId,CustomerDivisionId,MlsDivisionId,ActivePartId,PartType,CustomerPn,MlsPn,PartDescription,PartPrice,PartCost,Weight,StdPack,Notes")] MasterPartList masterPartList)
        public ActionResult Edit(MasterPartList masterPartList, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                //New Files

                /*for (int i = 0; i < Request.Files.Count; i++)
                 * {
                 *  var file = Request.Files[i];
                 *
                 *  if (file != null && file.ContentLength > 0)
                 *  {
                 *      var fileName = Path.GetFileName(file.FileName);
                 *      FileDetail fileDetail = new FileDetail()
                 *      {
                 *          FileName = fileName,
                 *          Extension = Path.GetExtension(fileName),
                 *          Id = Guid.NewGuid(),
                 *          PartId = masterPartList.PartId
                 *      };
                 *      var path = Path.Combine(Server.MapPath("~/images/"), fileDetail.Id + fileDetail.Extension);
                 *      file.SaveAs(path);
                 *
                 *      db.Entry(fileDetail).State = EntityState.Added;
                 *  }
                 * }*/

                db.Entry(masterPartList).State = EntityState.Modified;
                db.SaveChanges();
                return(Redirect(returnUrl));
            }
            return(View());
            //return View(masterPartList);
        }
예제 #2
0
        //public ActionResult Create([Bind(Include = "PartId,CustomerId,CustomerDivisionId,MlsDivisionId,ActivePartId,PartType,CustomerPn,MlsPn,PartDescription,PartPrice,PartCost,Weight,StdPack,Notes")] MasterPartList masterPartList)
        public ActionResult Create(MasterPartList masterPartList, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                /*List<FileDetail> fileDetails = new List<FileDetail>();
                 * for (int i = 0; i < Request.Files.Count; i++)
                 * {
                 *  var file = Request.Files[i];
                 *
                 *  if (file != null && file.ContentLength > 0)
                 *  {
                 *      var fileName = Path.GetFileName(file.FileName);
                 *      FileDetail fileDetail = new FileDetail()
                 *      {
                 *          FileName = fileName,
                 *          Extension = Path.GetExtension(fileName),
                 *          Id = Guid.NewGuid()
                 *      };
                 *      fileDetails.Add(fileDetail);
                 *
                 *      var path = Path.Combine(Server.MapPath("~/images/"), fileDetail.Id + fileDetail.Extension);
                 *      file.SaveAs(path);
                 *  }
                 * }
                 * masterPartList.FileDetails = fileDetails;*/
                db.MasterPartLists.Add(masterPartList);
                db.SaveChanges();
                return(Redirect(returnUrl));
            }

            return(View());
            //return View(masterPartList);
        }
예제 #3
0
        // GET: MasterPartLists/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterPartList masterPartList = db.MasterPartLists.Find(id);

            if (masterPartList == null)
            {
                return(HttpNotFound());
            }
            return(View(masterPartList));
        }
예제 #4
0
        // GET: MasterPartLists/Delete/5
        public ActionResult Delete(int?id)
        {
            ViewBag.ReturnUrl = Request.UrlReferrer;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MasterPartList masterPartList = db.MasterPartLists.Find(id);

            if (masterPartList == null)
            {
                return(HttpNotFound());
            }
            return(View(masterPartList));
        }
예제 #5
0
        public ActionResult DeleteConfirmed(int id, string returnUrl)
        {
            MasterPartList masterPartList = db.MasterPartLists.Find(id);

            //delete files from the file system

            /*
             * foreach (var item in masterPartList.FileDetails)
             * {
             *  String path = Path.Combine(Server.MapPath("~/images/"), item.Id + item.Extension);
             *  if (System.IO.File.Exists(path))
             *  {
             *      System.IO.File.Delete(path);
             *  }
             * }
             */
            db.MasterPartLists.Remove(masterPartList);
            db.SaveChanges();
            return(Redirect(returnUrl));
        }
예제 #6
0
        // GET: MasterPartLists/Edit/5
        public ActionResult Edit(int?id)
        {
            ViewBag.ReturnUrl = Request.UrlReferrer;
            var masterpartlists = db.MasterPartLists.SingleOrDefault(c => c.PartId == id);

            var customers         = db.Customers.ToList();
            var customerdivisions = db.CustomerDivisions.ToList();
            var mlsdivisions      = db.MlsDivisions.ToList();
            var parttypes         = db.PartTypes.ToList();
            var activeparts       = db.ActiveParts.ToList();

            var viewModel = new SaveMasterViewModel()
            {
                MasterPartList    = masterpartlists,
                Customers         = customers,
                CustomerDivisions = customerdivisions,
                MlsDivisions      = mlsdivisions,
                PartTypes         = parttypes,
                ActiveParts       = activeparts
            };

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Support support = db.Supports.Include(s => s.FileDetails).SingleOrDefault(x => x.SupportId == id);
            //MasterPartList masterPartList = db.MasterPartLists.Include(s => s.FileDetails).SingleOrDefault(x => x.PartId == id);
            MasterPartList masterPartList = db.MasterPartLists.Find(id);

            if (masterPartList == null)
            {
                return(HttpNotFound());
            }
            return(View("Edit", viewModel));
            //return View(masterPartList);
        }
예제 #7
0
        public void LoadData(int iDisplayLength, int iDisplayStart, int iSortCol_0, string sSortDir_0, string sSearch)
        {
            int    displayLength = iDisplayLength;
            int    displayStart  = iDisplayStart;
            int    sortCol       = iSortCol_0;
            string sortDir       = sSortDir_0;
            string search        = sSearch;

            string cs = ConfigurationManager.ConnectionStrings["mls_dataConnectionString"].ConnectionString;
            List <MasterPartList> listMasterPartLists = new List <MasterPartList>();
            int filteredCount = 0;

            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("spLoadData", con);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter paramDisplayLength = new SqlParameter()
                {
                    ParameterName = "@DisplayLength",
                    Value         = displayLength
                };
                cmd.Parameters.Add(paramDisplayLength);

                SqlParameter paramDisplayStart = new SqlParameter()
                {
                    ParameterName = "@DisplayStart",
                    Value         = displayStart
                };
                cmd.Parameters.Add(paramDisplayStart);

                SqlParameter paramSortCol = new SqlParameter()
                {
                    ParameterName = "@SortCol",
                    Value         = sortCol
                };
                cmd.Parameters.Add(paramSortCol);

                SqlParameter paramSorDir = new SqlParameter()
                {
                    ParameterName = "@SortDir",
                    Value         = sortDir
                };
                cmd.Parameters.Add(paramSorDir);

                SqlParameter paramSearchString = new SqlParameter()
                {
                    ParameterName = "@Search",
                    Value         = string.IsNullOrEmpty(search) ? null : search
                };
                cmd.Parameters.Add(paramSearchString);

                con.Open();
                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    filteredCount = Convert.ToInt32(rdr["TotalCount"]);
                    MasterPartList masterpartlist = new MasterPartList();
                    masterpartlist.CustomerPn      = rdr["CustomerPn"].ToString();
                    masterpartlist.PartDescription = rdr["PartDescription"].ToString();
                    masterpartlist.PartPrice       = Convert.ToDecimal(rdr["PartPrice"]);
                    masterpartlist.PartCost        = Convert.ToDecimal(rdr["PartCost"]);
                    masterpartlist.Weight          = Convert.ToDecimal(rdr["Weight"]);
                    masterpartlist.StdPack         = Convert.ToInt32(rdr["StdPack"]);
                    masterpartlist.Location        = rdr["Location"].ToString();
                    masterpartlist.HtsCode         = rdr["HtsCode"].ToString();
                    masterpartlist.Notes           = rdr["Notes"].ToString();
                    listMasterPartLists.Add(masterpartlist);
                }
            }
            var result = new
            {
                iTotalRecords        = LoadDataTotalCount(),
                iTotalDisplayRecords = filteredCount,
                aaData = listMasterPartLists
            };

            JavaScriptSerializer js = new JavaScriptSerializer();

            Context.Response.Write(js.Serialize(result));
        }