public ActionResult Create([Bind(Include = "DetailID,PieceCount,FKSubPieceID")] Detail detail)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);


            if (ModelState.IsValid)
            {
                ViewBag.FKSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", detail.FKSubPieceID);
                db.Detail.Add(new Detail
                {
                    PieceCount   = detail.PieceCount,
                    CreatedDate  = DateTime.Now,
                    FKSubPieceID = detail.FKSubPieceID,
                    FKUserID     = ID
                });

                db.SaveChanges();
            }


            return(RedirectToAction("Index"));



            //ViewBag.FKUserID = new SelectList(db.User, "UserID", "UserName", detail.);
        }
Example #2
0
        public ActionResult Create([Bind(Include = "SubPieceID,SubPieceName,ToolLife,Now,FKPieceID,FKUserID,Type")] SubPiece subPiece)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);

            if (ModelState.IsValid)
            {
                db.SubPiece.Add(new SubPiece()
                {
                    SubPieceName = subPiece.SubPieceName,
                    ToolLife     = subPiece.ToolLife,
                    FKPieceID    = subPiece.FKPieceID,
                    Type         = subPiece.Type,
                    FKUserID     = ID
                });
                //db.SubPiece.Add(subPiece);
                db.SaveChanges();

                return(RedirectToAction("TakimOmru", "Home"));
            }

            ViewBag.FKPieceID = new SelectList(db.Piece, "PieceID", "PieceName", subPiece.FKPieceID);
            ViewBag.FKUserID  = new SelectList(db.User, "UserID", "UserName", subPiece.FKUserID);
            return(View(subPiece));
        }
        public ActionResult CreateNoteTakim(FormCollection form, [Bind(Include = "NoteID,NoteHeader,NoteDescription,CreatedDate,FkPieceID,FkSubPieceID,FkUserID")] Note note)
        {
            var takimid   = Convert.ToInt32(form["nottakimid"]);
            var typetakim = Convert.ToBoolean(form["typetakim"]);

            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);

            if (ModelState.IsValid)
            {
                db.Notes.Add(new Note()
                {
                    NoteHeader      = note.NoteHeader,
                    NoteDescription = note.NoteDescription,
                    CreatedDate     = note.CreatedDate.GetValueOrDefault(DateTime.Now),
                    FkPieceID       = takimid,
                    FkSubPieceID    = note.FkSubPieceID,
                    FkUserID        = ID,
                    Type            = typetakim
                });
                db.SaveChanges();
                return(RedirectToAction("TakimOmru", "Home"));
            }

            ViewBag.FkPieceID    = new SelectList(db.Piece, "PieceID", "PieceName", note.FkPieceID);
            ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", note.FkSubPieceID);
            ViewBag.FkUserID     = new SelectList(db.User, "UserID", "UserName", note.FkUserID);
            return(View(note));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "NotificationID,Notification_Description,Count,Notification_Date,FKUserId")] Notification notification)
        {
            if (ModelState.IsValid)
            {
                db.Notification.Add(notification);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.FKUserId = new SelectList(db.User, "UserID", "UserName", notification.FKUserId);
            return(View(notification));
        }
        public ActionResult UserEdit([Bind(Include = "UserID,UserName,Password,FirstName,LastName,Company,CompanyLogo,Email")] User user)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            if (ModelState.IsValid)
            {
                if (Request.Files.Count > 0)
                {
                    //Guid nesnesini benzersiz dosya adı oluşturmak için tanımladık ve Replace ile aradaki “-” işaretini atıp yan yana yazma işlemi yaptık.
                    string DosyaAdi = Guid.NewGuid().ToString().Replace("-", "");
                    //Kaydetceğimiz resmin uzantısını aldık.
                    string uzanti     = System.IO.Path.GetExtension(Request.Files[0].FileName);
                    string TamYolYeri = "/Images/" + DosyaAdi + uzanti;
                    //Eklediğimiz Resni Server.MapPath methodu ile Dosya Adıyla birlikte kaydettik.
                    Request.Files[0].SaveAs(Server.MapPath(TamYolYeri));
                    //Ve veritabanına kayıt için dosya adımızı değişkene aktarıyoruz.
                    user.CompanyLogo = DosyaAdi + uzanti;
                }
                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Profil", "Home"));
            }

            return(View(user));
        }
        public ActionResult DeletePiece(int?id)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();
            Piece piece            = db.Piece.Find(id);

            db.Piece.Remove(piece);
            db.SaveChanges();
            return(RedirectToAction("Indexx"));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();
            Note note = db.Notes.Find(id);

            db.Notes.Remove(note);
            db.SaveChanges();
            return(RedirectToAction("Note"));
        }
        public ActionResult ParcaSil(FormCollection form)
        {
            var id = Convert.ToInt32(form["parcaid"]);

            using (var ctx = new TakimOmruDBEntities())
            {
                SubPiece sub = ctx.SubPiece.Find(id);
                ctx.SubPiece.Remove(sub);
                ctx.SaveChanges();
            }
            return(RedirectToAction("TakimOmru", "Home"));
        }
Example #9
0
        public ActionResult Upload(FormCollection formCollection)
        {
            var subpieceList = new List <Kapasitematik_TakimOmru_v3.SubPiece>();

            if (Request != null)
            {
                HttpPostedFileBase file = Request.Files["UploadedFile"];
                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))
                {
                    string fileName        = file.FileName;
                    string fileContentType = file.ContentType;
                    byte[] fileBytes       = new byte[file.ContentLength];
                    var    data            = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));
                    using (var package = new ExcelPackage(file.InputStream))
                    {
                        ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
                        var currentSheet = package.Workbook.Worksheets;
                        var workSheet    = currentSheet.First();
                        var noOfCol      = workSheet.Dimension.End.Column;
                        var noOfRow      = workSheet.Dimension.End.Row;
                        for (int rowIterator = 1; rowIterator <= noOfRow; rowIterator++)
                        {
                            var subpiece = new Kapasitematik_TakimOmru_v3.SubPiece();

                            subpiece.SubPieceName = workSheet.Cells[rowIterator, 1].Value.ToString();

                            subpiece.ToolLife = Convert.ToInt32(workSheet.Cells[rowIterator, 2].Value);



                            subpieceList.Add(subpiece);
                        }
                    }
                }
            }
            using (TakimOmruDBEntities db = new TakimOmruDBEntities())
            {
                foreach (var item in subpieceList)
                {
                    db.SubPiece.Add(new SubPiece()
                    {
                        SubPieceName = item.SubPieceName,
                        ToolLife     = item.ToolLife,
                        FKPieceID    = Convert.ToInt32(formCollection["id"]),
                        Type         = Convert.ToBoolean("false")
                    });
                }
                db.SaveChanges();
            }
            return(RedirectToAction("TakimOmru", "Home"));
        }
        public ActionResult ParcaGuncelle(SubPiece subPiece, FormCollection form)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();
            var id = Convert.ToInt32(form["par"]);
            var existingsubpiece = db.SubPiece.Where(s => s.SubPieceID == id).FirstOrDefault();

            if (existingsubpiece != null)
            {
                existingsubpiece.SubPieceName = subPiece.SubPieceName;
                existingsubpiece.ToolLife     = subPiece.ToolLife;
                db.SaveChanges();
            }
            return(RedirectToAction("TakimOmru", "Home"));
        }
        public ActionResult Create([Bind(Include = "SubPieceID,SubPieceName,ToolLife,Now,FKPieceID,FKUserID,Type")] SubPiece subPiece)
        {
            //ViewBag.Data = new SelectList(db.PimsunDeviceNoes, "DeviceNo", "MachineName", piece.FKDeviceID);
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            if (ModelState.IsValid)
            {
                db.SubPiece.Add(subPiece);
                db.SaveChanges();
                return(RedirectToAction("TakimOmru", "Home"));
            }

            ViewBag.FKPieceID = new SelectList(db.Piece, "PieceID", "PieceName", subPiece.FKPieceID);
            ViewBag.FKUserID  = new SelectList(db.User, "UserID", "UserName", subPiece.FKUserID);
            return(RedirectToAction("TakimOmru", "Home"));
        }
        public ActionResult Edit([Bind(Include = "PieceID,PieceName,FKUserID,CreatedDate,Adet")] Piece piece)
        {
            ViewBag.UserID = Session["UserID"];
            int ID = Convert.ToInt32(Session["UserID"]);
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            if (ModelState.IsValid)
            {
                piece.FKUserID        = ID;
                piece.Adet            = 0;
                piece.CreatedDate     = DateTime.Now;
                db.Entry(piece).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Indexx"));
            }
            ViewBag.FKUserID = new SelectList(db.User, "UserID", "UserName", piece.FKUserID);
            return(View(piece));
        }
Example #13
0
        public ActionResult AddUser(FormCollection form)
        {
            TakimOmruDBEntities db = new TakimOmruDBEntities();
            User user = new User();

            //eğer dosya gelmişse işlemleri yap
            if (Request.Files.Count > 0)
            {
                //Guid nesnesini benzersiz dosya adı oluşturmak için tanımladık ve Replace ile aradaki “-” işaretini atıp yan yana yazma işlemi yaptık.
                string DosyaAdi = Guid.NewGuid().ToString().Replace("-", "");
                //Kaydetceğimiz resmin uzantısını aldık.
                string uzanti     = System.IO.Path.GetExtension(Request.Files[0].FileName);
                string TamYolYeri = "/Images/" + DosyaAdi + uzanti;
                //Eklediğimiz Resni Server.MapPath methodu ile Dosya Adıyla birlikte kaydettik.
                Request.Files[0].SaveAs(Server.MapPath(TamYolYeri));
                //Ve veritabanına kayıt için dosya adımızı değişkene aktarıyoruz.
                user.CompanyLogo = DosyaAdi + uzanti;
            }

            user.Company   = form["company"];
            user.FirstName = form["firstname"];
            user.LastName  = form["lastname"];
            user.Email     = form["email"];
            user.UserName  = form["username"];
            //user.Password = hs.PassHass(form["password"]);
            user.Password = form["password"];
            db.User.Add(user);
            db.SaveChanges();
            return(Redirect("Login"));


            //using (var client = new HttpClient())
            //{
            //    client.BaseAddress = new Uri("https://1ns5809cw0.execute-api.eu-west-2.amazonaws.com/Prod/");
            //    client.DefaultRequestHeaders.Accept.Clear();
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //    HttpResponseMessage response = client.PostAsJsonAsync("api/Login/AddUser", user).Result;
            //    if (response.IsSuccessStatusCode)
            //    {
            //        return RedirectToAction("Login");
            //    }
            //    return null;
            //}
        }
        public ActionResult ParcaEklee(Piece piece)
        {
            var sessionId          = Convert.ToInt32(Session["UserID"]);
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            ViewBag.Data = new SelectList(db.PimsunDeviceNoes, "DeviceNo", "MachineName", piece.FKDeviceID);
            try
            {
                db.Piece.Add(new Piece()
                {
                    PieceName   = piece.PieceName,
                    CreatedDate = piece.CreatedDate.GetValueOrDefault(DateTime.Now),
                    FKUserID    = sessionId,
                    FKDeviceID  = piece.FKDeviceID
                });
                db.SaveChanges();
                return(RedirectToAction("Indexx"));
            }
            catch (Exception)
            {
                return(RedirectToAction("ParcaEkle"));
            }
        }
        public ActionResult TakimOmru(Notification noti, [Bind(Include = "NoteID,NoteHeader,NoteDescription,CreatedDate,FkPieceID,FkSubPieceID,FkUserID")] Note note)
        {
            //ActionResult result = null;
            TakimOmruDBEntities db = new TakimOmruDBEntities();

            ViewBag.FKPieceID = new SelectList(db.Piece, "PieceID", "PieceName");
            //ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName");
            //ViewBag.FkUserID = new SelectList(db.User, "UserID", "UserName");

            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Login"));
            }
            ViewBag.UserID  = Session["UserID"];
            ViewBag.Company = Session["Company"];
            ViewBag.Logo    = Session["Logo"];
            ViewBag.Name    = Session["FirstName"];
            int        UserId = Convert.ToInt32(Session["UserID"]);
            ThreeModel tm     = new ThreeModel();

            tm.notification = db.Notification.ToList();
            tm.pieces       = db.Piece.ToList();
            tm.subpieces    = db.SubPiece.ToList();
            tm.notes        = db.Notes.ToList();

            ViewBag.FkPieceIDd   = new SelectList(db.Piece, "PieceID", "PieceName", note.FkPieceID);
            ViewBag.FkSubPieceID = new SelectList(db.SubPiece, "SubPieceID", "SubPieceName", note.FkSubPieceID);
            ViewBag.FkUserID     = new SelectList(db.User, "UserID", "UserName", note.FkUserID);

            var altkategori = from s in db.SubPiece
                              join dt in db.Detail on s.SubPieceID equals dt.FKSubPieceID
                              where s.FKUserID == UserId
                              select new
            {
                SubPieceId   = s.SubPieceID,
                SubPieceName = s.SubPieceName,
                ToolLife     = s.ToolLife,
                PieceID      = s.FKPieceID,
                PieceCount   = dt.PieceCount,
            };
            var data = altkategori.GroupBy(x => x.SubPieceId).Select(x => new
            {
                SubPieceId   = x.FirstOrDefault().SubPieceId,
                SubPieceName = x.FirstOrDefault().SubPieceName,
                ToolLife     = x.FirstOrDefault().ToolLife,
                PieceID      = x.FirstOrDefault().PieceID,
                PieceCount   = x.Sum(y => y.PieceCount),
            }).Where(v => v.PieceCount > (v.ToolLife * 2) / 3);

            if (data != null && data.Any())
            {
                foreach (var item in data)
                {
                    db.Notification.Add(new Notification()
                    {
                        NotificationID           = noti.NotificationID,
                        Notification_Description = noti.Notification_Description = (item.SubPieceName) + " " + "parçasının ömrü tükenmek üzere Kalan parça sayısı " + (item.ToolLife - item.PieceCount),
                        Count             = noti.Count = 0,
                        FKUserId          = UserId,
                        Notification_Date = noti.Notification_Date.GetValueOrDefault(DateTime.Now),
                    });
                }

                db.SaveChanges();
            }

            //var noti = db.Notification.ToList();


            //ViewBag.PieceID = new SelectList(db.Piece, "PieceId", "PieceName", subPiece.FKPieceID);
            //ViewBag.Message = "Your application description page.";

            //ViewBag.Piece = new SelectList(db.Piece, "PieceId", "PieceName");
            //var prodecure= db.SP_Notification_Update_Counter_v1(UserId);
            return(View(tm));
        }