Exemple #1
0
        public ActionResult Create(Units_Details units_Details)
        {
            units_Details.IsActive       = true;
            units_Details.Created        = GetDate;
            units_Details.CreatedBy      = GetUserId;
            units_Details.LastModified   = GetDate;
            units_Details.LastModifiedBy = GetUserId;

            if (ModelState.IsValid)
            {
                _db.Units_Details.Add(units_Details);
                _db.SaveChanges();

                var units_Status = new Units_Status()
                {
                    FK_Units_DetailsId = units_Details.Id,
                    FK_Deal_StatusId   = (int)Status.Not_Collected,
                    IsActive           = true,
                    Created            = GetDate,
                    CreatedBy          = GetUserId,
                    LastModified       = GetDate,
                    LastModifiedBy     = GetUserId
                };

                _db.Units_Status.Add(units_Status);
                _db.SaveChanges();

                return(RedirectToAction("Details", new { id = units_Details.Id }));
            }

            ViewBag.FK_DeveloperId    = new SelectList(_db.Developers, "Id", "Name", units_Details.FK_DeveloperId);
            ViewBag.FK_Sales_PersonId = new SelectList(_db.Sales_Person, "Id", "Name", units_Details.FK_Sales_PersonId);
            return(View(units_Details));
        }
        public ActionResult Delete(int id)
        {
            Units_Details units_Details = db.Units_Details.Find(id);

            db.Units_Details.Remove(units_Details);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Units_Details units_Details = _db.Units_Details.Find(id);

            units_Details.IsActive = false;
            _db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "Unit_Id,Company_Id,Name,Date_Created,Date_Modified,Created_By,Modified_By")] Units_Details units_Details)
 {
     if (ModelState.IsValid)
     {
         db.Entry(units_Details).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(units_Details));
 }
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Units_Details units_Details = db.Units_Details.Find(id);

            if (units_Details == null)
            {
                return(HttpNotFound());
            }
            return(View(units_Details));
        }
Exemple #6
0
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Units_Details units_Details = _db.Units_Details.Find(id);

            if (units_Details == null)
            {
                return(HttpNotFound());
            }
            ViewBag.FK_DeveloperId    = new SelectList(_db.Developers, "Id", "Name", units_Details.FK_DeveloperId);
            ViewBag.FK_Sales_PersonId = new SelectList(_db.Sales_Person, "Id", "Name", units_Details.FK_Sales_PersonId);
            return(View(units_Details));
        }
Exemple #7
0
        public ActionResult Edit(Units_Details units_Details)
        {
            units_Details.IsActive       = true;
            units_Details.LastModified   = GetDate;
            units_Details.LastModifiedBy = GetUserId;

            if (ModelState.IsValid)
            {
                _db.Entry(units_Details).State = EntityState.Modified;
                _db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.FK_DeveloperId    = new SelectList(_db.Developers, "Id", "Name", units_Details.FK_DeveloperId);
            ViewBag.FK_Sales_PersonId = new SelectList(_db.Sales_Person, "Id", "Name", units_Details.FK_Sales_PersonId);
            return(View(units_Details));
        }
        // GET: Inventory/Units_Details/Details/5
        public PartialViewResult CreatePartial(int?id)
        {
            HttpCookie myCookie   = Request.Cookies["inventoryCookie"];
            string     Company_Id = string.Empty;

            if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"]))
            {
                Company_Id = myCookie.Values["Company_Id"].ToString();
            }
            Units_Details car = new Units_Details();

            if (id != null)
            {
                car = db.Units_Details.Where(c => c.Unit_Id == id).FirstOrDefault();
            }
            return(PartialView(car));
        }
        public ActionResult Create(Units_Details units_Details)
        {
            if (ModelState.IsValid)
            {
                string     Company_Id = string.Empty;
                string     UserId     = string.Empty;
                string     UserName   = string.Empty;
                HttpCookie myCookie   = Request.Cookies["inventoryCookie"];
                if (myCookie == null)
                {
                    return(Redirect("/Auth/Login/Logout"));
                }
                if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"]))
                {
                    Company_Id = myCookie.Values["Company_Id"].ToString();
                }
                if (!string.IsNullOrEmpty(myCookie.Values["UserId"]))
                {
                    UserId = myCookie.Values["UserId"].ToString();
                }
                if (!string.IsNullOrEmpty(myCookie.Values["UserName"]))
                {
                    UserName = myCookie.Values["UserName"].ToString();
                }

                Units_Details cart = new Units_Details();
                cart.Created_By   = UserName;
                cart.Date_Created = DateTime.Now;
                cart.Company_Id   = Convert.ToInt32(Company_Id);
                cart.Name         = units_Details.Name;
                db.Units_Details.Add(cart);
                db.SaveChanges();
                return(RedirectToAction("Index"));

                //db.units_details.add(units_details);
                //db.savechanges();
                //return redirecttoaction("index");
            }
            //        ViewBag.Company_Id = new SelectList(db.Company_Details, "Company_Id", "Name", units_Details.Company_Id);
            return(View(units_Details));
        }
        public string Add(string name, int Id)
        {
            string Returns = "";

            if (ModelState.IsValid)
            {
                string Company_Id = string.Empty;
                string UserId     = string.Empty;
                string UserName   = string.Empty;

                HttpCookie myCookie = Request.Cookies["inventoryCookie"];
                if (myCookie == null)
                {
                    return("Logout");
                }
                if (!string.IsNullOrEmpty(myCookie.Values["Company_Id"]))
                {
                    Company_Id = myCookie.Values["Company_Id"].ToString();
                }
                if (!string.IsNullOrEmpty(myCookie.Values["UserId"]))
                {
                    UserId = myCookie.Values["UserId"].ToString();
                }
                if (!string.IsNullOrEmpty(myCookie.Values["UserName"]))
                {
                    UserName = myCookie.Values["UserName"].ToString();
                }
                int company_Id = Convert.ToInt32(Company_Id);


                if (Id != 0)
                {
                    Units_Details units = db.Units_Details.Where(e => e.Unit_Id == Id).FirstOrDefault();
                    units.Company_Id      = company_Id;
                    units.Created_By      = UserName;
                    units.Date_Created    = DateTime.Now;
                    units.Name            = name;
                    db.Entry(units).State = EntityState.Modified;
                    db.SaveChanges();
                    return("Unit Updated Successfully");
                }
                else
                {
                    Units_Details units = db.Units_Details.Where(e => e.Name == name && e.Company_Id == company_Id).FirstOrDefault();
                    if (units == null)
                    {
                        Units_Details units_Details = new Units_Details();
                        units_Details.Company_Id    = company_Id;
                        units_Details.Created_By    = UserName;
                        units_Details.Date_Created  = DateTime.Now;
                        units_Details.Date_Modified = DateTime.Now;
                        units_Details.Name          = name;
                        db.Units_Details.Add(units_Details);
                        db.SaveChanges();
                        return("Unit Added Successfully");
                    }
                    else
                    {
                        return("Unit Already Exist");
                    }
                }
            }
            return(Returns);
        }