예제 #1
0
        public async Task <ActionResult> EditAddPayment(MaterialBuyPaymentData materialBuyPaymentData)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                //                db.Entry(materialBuyData).State = EntityState.Modified;
                MaterialBuy materialBuy = db.MaterialBuys.FirstOrDefault(m => m.ID == materialBuyPaymentData.MaterialBuy.ID);

                materialBuyPaymentData.Payment.EmployeeID = Convert.ToInt32(Session["LoginUserEmployeeID"]);
                materialBuyPaymentData.Payment.Employee   = db.Employees.FirstOrDefault(e => e.ID == materialBuyPaymentData.Payment.EmployeeID);
                materialBuyPaymentData.Payment.CompanyID  = materialBuyPaymentData.MaterialBuy.CompanyID;
                materialBuyPaymentData.Payment.ProjectID  = materialBuyPaymentData.MaterialBuy.ProjectID;

                db.Payments.Add(materialBuyPaymentData.Payment);
                materialBuy.Payments.Add(materialBuyPaymentData.Payment);

                await db.SaveChangesAsync();

                return(RedirectToAction("EditAddPayment", new { id = materialBuyPaymentData.MaterialBuy.ID }));
            }
            return(View(materialBuyPaymentData));
        }
예제 #2
0
        public async Task <ActionResult> Create([Bind(Include = "ID,ProjectID,StartDate,EndDate,Complete,WorkNameVn,WorkNameKr,NoteVn,NoteKr,Translate")] WorkUnit workUnit)
        {
            if (ModelState.IsValid)
            {
                db.WorkUnits.Add(workUnit);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectID = new SelectList(db.Projects, "ID", "NameVn", workUnit.ProjectID);
            return(View(workUnit));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,DailyWorkID,Date,NameVn,NameKr,NoteVn,NoteKr,EquipCount,Translate")] EquipmentUnit equipmentUnit)
        {
            if (ModelState.IsValid)
            {
                db.EquipmentUnits.Add(equipmentUnit);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.DailyWorkID = new SelectList(db.DailyWorks, "ID", "WeatherVn", equipmentUnit.DailyWorkID);
            return(View(equipmentUnit));
        }
예제 #4
0
        public async Task <ActionResult> Create([Bind(Include = "ID,FactoryDailyWorkID,ProjectID,Type,EquipCount,NoteVn,NoteKr,Translate")] FactoryWorkUnit factoryWorkUnit)
        {
            if (ModelState.IsValid)
            {
                db.FactoryWorkUnits.Add(factoryWorkUnit);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.FactoryDailyWorkID = new SelectList(db.FactoryDailyWorks, "ID", "NoteVn", factoryWorkUnit.FactoryDailyWorkID);
            ViewBag.ProjectID          = new SelectList(db.Projects, "ID", "NameVn", factoryWorkUnit.ProjectID);
            return(View(factoryWorkUnit));
        }
예제 #5
0
        public async Task <ActionResult> Create([Bind(Include = "ID,EmployeeID,MaterialBuyID,CompanyID,Date,Amount,AmountString,Type,StatementType,NoteVn,NoteKr,Translate")] Payment payment)
        {
            if (ModelState.IsValid)
            {
                db.Payments.Add(payment);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.CompanyID  = new SelectList(db.Companys, "ID", "Name", payment.CompanyID);
            ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "DepartmentVn", payment.EmployeeID);
//            ViewBag.MaterialBuyID = new SelectList(db.MaterialBuys, "ID", "NoteVn", payment.MaterialBuyID);
            return(View(payment));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,NameVn,NameKr,Sort")] MaterialName materialName)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                db.MaterialNames.Add(materialName);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(materialName));
        }
예제 #7
0
        public async Task <ActionResult> Create([Bind(Include = "ID,Name,Address,Tel,Texcode,BankAccount,BankLocation")] Company company)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                db.Companys.Add(company);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(company));
        }
예제 #8
0
        public async Task <ActionResult> Create([Bind(Include = "ID,EmployeeID,TitleVn,TitleKr,NoteVn,NoteKr,Date,UploadFiles,Translate")] Board board)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                List <UploadFile> UploadFiles = new List <UploadFile>();
                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);
                        UploadFile uploadFile = new UploadFile()
                        {
                            FileName     = fileName,
                            SaveFileName = Guid.NewGuid() + "_" + fileName,
                            FolderName   = "Board",
                            Date         = DateTime.Now
                        };
                        UploadFiles.Add(uploadFile);

                        var path = Path.Combine(Server.MapPath("~/UploadFile/"), uploadFile.FolderName + "/" + uploadFile.SaveFileName);
                        file.SaveAs(path);
                    }
                }

                board.UploadFiles = UploadFiles;
                board.Date        = (DateTime)DateTime.Now;
                board.TitleKr     = board.TitleVn;
                board.NoteKr      = board.NoteVn;
                board.EmployeeID  = (int)Session["LoginUserEmployeeID"];
                db.Boards.Add(board);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "Name", board.EmployeeID);
            return(View(board));
        }
예제 #9
0
        public async Task <ActionResult> Create([Bind(Include = "ID,EmployeeID,SendDate,ReasonVn,ReasonKr,StartDate,EndDate,HalfDay,Type,Translate")] Personnel personnel)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (ModelState.IsValid)
            {
                personnel.SendDate = DateTime.Now;
                db.Personnels.Add(personnel);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeID = new SelectList(db.Employees, "ID", "Name", personnel.EmployeeID);
            return(View(personnel));
        }
예제 #10
0
        public async Task <ActionResult> Create([Bind(Include = "ID,ProjectID,ProparingPersonID,Date,PrrocessPerPlan,PrrocessPerResult,WeatherVn,WeatherKr,NoteVn,NoteKr,Translate,WorkUnits")] DailyWork dailyWork)
        {
            if (ModelState.IsValid)
            {
                //                dailyWork.Project.WorkUnits = db.WorkUnits.Where(w => w.DailyWorks.Count(d=>d.ProjectID == dailyWork.ProjectID)>0 && w.StartDate < dailyWork.Date && w.Complete == false).ToList();
                List <UploadFile> UploadFiles = new List <UploadFile>();
                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);
                        UploadFile uploadFile = new UploadFile()
                        {
                            FileName     = fileName,
                            SaveFileName = Guid.NewGuid() + "_" + fileName,
                            FolderName   = "DailyWork",
                            Date         = DateTime.Now
                        };
                        UploadFiles.Add(uploadFile);

                        var path = Path.Combine(Server.MapPath("~/UploadFile/"), uploadFile.FolderName + "/" + uploadFile.SaveFileName);
                        file.SaveAs(path);
                    }
                }

                dailyWork.UploadFiles = UploadFiles;

                db.DailyWorks.Add(dailyWork);
                await db.SaveChangesAsync();

//                return RedirectToAction("Index");
                return(RedirectToAction("EditAddWork", new { id = dailyWork.ID }));
            }

            ViewBag.ProjectID         = new SelectList(db.Projects, "ID", "NameVn", dailyWork.ProjectID);
            ViewBag.ProparingPersonID = new SelectList(db.Employees.Where(e => e.ResignID == null), "ID", "Name", dailyWork.ProparingPersonID);
            return(View(dailyWork));
        }
        public async Task <ActionResult> Create([Bind(Include = "ID,ProparingPersonID,Date,NoteVn,NoteKr,Translate")] FactoryDailyWork factoryDailyWork)
        {
            if (ModelState.IsValid)
            {
                db.FactoryDailyWorks.Add(factoryDailyWork);
                await db.SaveChangesAsync();

//                return RedirectToAction("Index");
                return(RedirectToAction("EditAddWorkUnit", new { id = factoryDailyWork.ID }));
            }

            var employees = db.Employees.Where(e => e.ResignID == null);

            ViewBag.ProparingPersonID = new SelectList(employees, "ID", "Name", factoryDailyWork.ProparingPersonID);
            return(View(factoryDailyWork));
        }
예제 #12
0
        public async Task <ActionResult> Details([Bind(Include = "ID,CompanyID,NameVn,NameKr,Date,Company,Manager,ManagerID,Constructor,ConstructorID,UploadFiles,Translate")] Project project)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (Convert.ToInt32(Session["LoginUserSecurity"]) < Convert.ToInt32(Security.Manager))
            {
                return(RedirectToAction("Index", "Home"));
            }

            Project sproject = await db.Projects.FindAsync(project.ID);

            if (sproject != null && ModelState.IsValid)
            {
                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);
                        UploadFile uploadFile = new UploadFile()
                        {
                            FileName     = fileName,
                            SaveFileName = Guid.NewGuid() + "_" + fileName,
                            FolderName   = "Project",
                            Date         = DateTime.Now,
                            Security     = true
                        };
                        var path = Path.Combine(Server.MapPath("~/UploadFile/"), uploadFile.FolderName + "/" + uploadFile.SaveFileName);
                        file.SaveAs(path);

                        db.Entry(uploadFile).State = EntityState.Added;

                        sproject.UploadFiles.Add(uploadFile);
                    }
                }

                await db.SaveChangesAsync();

                //                return RedirectToAction("Index");
                return(RedirectToAction("Details", new { id = project.ID }));
            }

            //            ViewBag.CompanyID = new SelectList(db.Companys, "ID", "Name", project.CompanyID);
            return(View(project));
        }
예제 #13
0
        // GET: Employee/Details/5
        public async Task <ActionResult> Details(int?id, int?contractsID)
        {
            if (Session["LoginUserID"] == null)
            {
                return(RedirectToAction("Login", "Account"));
            }

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (contractsID != null)
            {
                Contract contract = await db.Contracts.FindAsync(contractsID);

                if (contract != null)
                {
                    //                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                    try
                    {
                        //                db.Entry(employee).State = EntityState.Deleted;
                        db.Contracts.Remove(contract);

                        await db.SaveChangesAsync();

                        //                return RedirectToAction("Details", id);
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        return(RedirectToAction("Details", id));
                        //                return RedirectToAction("Delete", new { concurrencyError = true, id = employee.ID });
                    }
                    catch (DataException /* dex */)
                    {
                        //Log the error (uncomment dex variable name after DataException and add a line here to write a log.
                        ModelState.AddModelError(string.Empty, "Unable to delete. Try again, and if the problem persists contact your system administrator.");
                        return(RedirectToAction("Details", id));
                        //                return View(employee);
                    }
                }
            }

            //            Employee employee = await db.Employees.FindAsync(id);
            var employee = new EmployeeExtendData();

            employee.Employee = db.Employees.Include(e => e.Resign)
                                .Where(e => e.ID == id)
                                .Include(e => e.Contracts.Select(c => c.Employee))
                                .Include(e => e.Personnels.Select(p => p.Employee))
                                .Single();

            employee.Employee.Personnels = employee.Employee.Personnels.OrderBy(p => p.StartDate).ToList();
            employee.Employee.Contracts  = employee.Employee.Contracts.OrderBy(c => c.StartDate).ToList();

            if (employee.Employee == null)
            {
                return(HttpNotFound());
            }

            return(View(employee));
        }