예제 #1
0
        public ActionResult Register([Bind(Include = "Id,Username,Firstname,Lastname,Email,Password,ConfirmPassword,UserRole")] User user)
        {
            if (String.IsNullOrEmpty(user.UserRole))
            {
                user.UserRole = UserRole.USER.ToString();
            }

            if (!Available(user.Username))
            {
                ModelState.AddModelError("", "Username is not available");
            }

            if (ModelState.IsValid)
            {
                //Using BCrypt Password hashing + salting
                string hashed = BCrypt.Net.BCrypt.HashPassword(user.Password);
                user.Password = user.ConfirmPassword = hashed;

                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
예제 #2
0
 public ActionResult OrderUpdateX(OrderMix model, string status)
 {
     using (var db = new Database1Entities1())
     {
         var p = db.OrderMixes.Find(model.OrderMixId);
         var q = db.Items.Find(p.ItemId);
         if (p.Status != status)
         {
             if (status == "未出荷")
             {
                 q.Stock = q.Stock + p.Quantity;
                 db.SaveChanges();
                 p.Status = status;
                 db.SaveChanges();
             }
             else if (status == "出荷済")
             {
                 if (q.Stock >= p.Quantity)
                 {
                     q.Stock = q.Stock - p.Quantity;
                     db.SaveChanges();
                     p.Status = status;
                     db.SaveChanges();
                 }
                 else if (q.Stock < p.Quantity)
                 {
                     ViewBag.message = "在庫数量が不足しています。";
                     return(View("OrderUpdateInput", Session["Update"]));
                 }
             }
         }
         return(View("OrderUpdate", p));
     }
 }
예제 #3
0
        public IHttpActionResult PuttblAdmin(int id, tblAdmin tblAdmin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblAdmin.AdminID)
            {
                return(BadRequest());
            }

            db.Entry(tblAdmin).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tblAdminExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult  ChangePasswordAdmin(int id, string password)
        {
            Admin admin = db.Admins.Find(id);

            admin.password = password;
            db.SaveChanges();
            return(RedirectToAction("index", "Home"));
        }
예제 #5
0
 public ActionResult addProj(Project p)
 {
     if (ModelState.IsValid)
     {
         db.Projects.Add(p);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(p));
 }
예제 #6
0
        public void DeleteRow(Wizyta wizyta)
        {
            var Query = (from el in db.Wizyta where el.WizytaID == wizyta.WizytaID select el).ToList();

            foreach (var row in Query)
            {
                db.Wizyta.Remove(row);
                db.SaveChanges();
            }
        }
예제 #7
0
        public ActionResult Create([Bind(Include = "Emp_ID,password,name,email,no_acc")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #8
0
        public ActionResult Create([Bind(Include = "Id,PublisherName")] Publisher publisher)
        {
            if (ModelState.IsValid)
            {
                db.Publishers.Add(publisher);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(publisher));
        }
        public ActionResult Create([Bind(Include = "id_pessoa,nome,sobrenome,email,cpf")] pessoa pessoa)
        {
            if (ModelState.IsValid)
            {
                db.pessoa.Add(pessoa);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pessoa));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "Id,AuthorName")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(author);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(author));
        }
예제 #11
0
        public ActionResult Create([Bind(Include = "Id,Title,Description,Developer,Publisher,Genre,Release,Price")] Game game)
        {
            if (ModelState.IsValid)
            {
                db.Games.Add(game);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(game));
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "Supplier_ID,Name,PhoneNum,Address")] Supplier supplier)
        {
            if (ModelState.IsValid)
            {
                db.Suppliers.Add(supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(supplier));
        }
예제 #13
0
        public ActionResult Create([Bind(Include = "AEmail,Job_id,Status")] Apply_Job apply_Job)
        {
            if (ModelState.IsValid)
            {
                db.Apply_Job.Add(apply_Job);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(apply_Job));
        }
        public ActionResult Create([Bind(Include = "id_grupo,nome_grupo")] grupo grupo)
        {
            if (ModelState.IsValid)
            {
                db.grupo.Add(grupo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(grupo));
        }
        public ActionResult Create([Bind(Include = "Id,Comapany_Name,Job_Descripation,Requirements,Salary,Contact_Info,Email,Require_Qualification")] Post_Job post_Job)
        {
            if (ModelState.IsValid)
            {
                db.Post_Job.Add(post_Job);
                db.SaveChanges();
            }

            //return View(post_Job);
            return(RedirectToAction("Details", "Post_Job"));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,PhoneNo,Details_About_Comapny,Email,Password")] Company_Details company_Details)
        {
            if (ModelState.IsValid)
            {
                db.Company_Details.Add(company_Details);
                db.SaveChanges();
            }

            //return View(company_Details);
            return(RedirectToAction("Create", "Post_Job"));
        }
예제 #17
0
        public ActionResult Create([Bind(Include = "Id,ulica,numerDomu,numerMieszkania,miasto,kod")] Adres adres)
        {
            if (ModelState.IsValid)
            {
                db.Adres.Add(adres);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(adres));
        }
예제 #18
0
        public ActionResult Create([Bind(Include = "CategoryId,CategoryName")] CategoryMaster categoryMaster)
        {
            if (ModelState.IsValid)
            {
                db.CategoryMasters.Add(categoryMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categoryMaster));
        }
예제 #19
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
예제 #20
0
 public ActionResult Edit(Project project)
 {
     if (ModelState.IsValid)
     {
         db.Entry(project).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("listProj"));
     }
     ViewBag.user_id = new SelectList(db.Users, "ID", "FirstName", project.user_id);
     return(View(project));
 }
예제 #21
0
        public ActionResult Create([Bind(Include = "Batch_Id,Batch_Name,Batch_Date,Batch_Time,Subject,Trainer_Name,Student_Name")] Schedule schedule)
        {
            if (ModelState.IsValid)
            {
                db.Schedules.Add(schedule);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(schedule));
        }
        public ActionResult Create([Bind(Include = "TId,TName,TDOB,TDateofjoin,TSalary,TQualification,TSchedule,TEmail,TPWD")] Trainer_Details trainer_Details)
        {
            if (ModelState.IsValid)
            {
                db.Trainer_Details.Add(trainer_Details);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trainer_Details));
        }
        public ActionResult Create([Bind(Include = "Stock_ID,Stock_Name,Quantity,Price,Supplier_ID")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Supplier_ID = new SelectList(db.Suppliers, "Supplier_ID", "Name", stock.Supplier_ID);
            return(View(stock));
        }
예제 #24
0
        public ActionResult Create([Bind(Include = "ProductId,ProductName,RefSubCategoryId,price,Description,ProductImage")] ProductMaster productMaster)
        {
            if (ModelState.IsValid)
            {
                db.ProductMasters.Add(productMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RefSubCategoryId = new SelectList(db.SubCategoryMasters, "SubCategoryId", "SubCategoryName", productMaster.RefSubCategoryId);
            return(View(productMaster));
        }
예제 #25
0
        public ActionResult Create([Bind(Include = "CityId,CityName,RefStateId")] CityMaster cityMaster)
        {
            if (ModelState.IsValid)
            {
                db.CityMasters.Add(cityMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RefStateId = new SelectList(db.StateMasters, "StateId", "StateName", cityMaster.RefStateId);
            return(View(cityMaster));
        }
        public ActionResult Create(int id)
        {
            try
            {
                Temporary_Orders temp = tempServices.findTempOrderById(id);
                int account_id = temp.Account_Id;
                TransactionAccount account = transactionService.findTransactionAccount(account_id);
                Sale_Order s_order = new Sale_Order();
              
                s_order.bags = temp.bags;
                s_order.broker_name = temp.broker_name;
                s_order.brokers_commision = temp.brokers_commision;
             
                s_order.company_sign = temp.company_sign;
                s_order.created_at_ = temp.created_at_;
                s_order.is_active = temp.is_active;
                s_order.vendor_sign = temp.vendor_sign;
                s_order.item = temp.item;
                s_order.party_name = account.name;
              
                s_order.so_number = temp.order_number;
                s_order.terms = temp.terms;
                s_order.uptdated_at = temp.created_at_;
                s_order.weight = temp.weight;
                s_order.rate = temp.rate;
                s_order.prepared_by = temp.prepared_by;
                s_order.approved_by = Session["username"].ToString();
                s_order.checked_by = temp.checked_by;
                s_order.Account_Id = account.id;
                service.addSO(s_order);
                service.save();

                Temporary_Orders TO = db.Temporary_Orders.Find(id);
                TO.is_active = "N";
                db.SaveChanges();
                return RedirectToAction("listOfTempOrders");
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}",
                            validationErrors.Entry.Entity.GetType().FullName,
                            validationError.PropertyName,
                            validationError.ErrorMessage);
                    }
                }

                return RedirectToAction("listOfTempOrders");
            }
        }
예제 #27
0
        public ActionResult Create([Bind(Include = "Id,imie,nazwisko,pesel,email,telefon,adresId")] Pracownik pracownik)
        {
            if (ModelState.IsValid)
            {
                db.Pracownik.Add(pracownik);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.adresId = new SelectList(db.Adres, "Id", "ulica", pracownik.adresId);
            return(View(pracownik));
        }
예제 #28
0
        public ActionResult Create([Bind(Include = "Pid,Price,Hot,Show,Pname")] Product product)
        {
            if (ModelState.IsValid)
            {
                product.Pid = Guid.NewGuid();
                db.Product.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(product));
        }
예제 #29
0
        public ActionResult Create([Bind(Include = "StateId,StateName,RefCountryId")] StateMaster stateMaster)
        {
            if (ModelState.IsValid)
            {
                db.StateMasters.Add(stateMaster);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.RefCountryId = new SelectList(db.CountryMasters, "CountryId", "CountryName", stateMaster.RefCountryId);
            return(View(stateMaster));
        }
예제 #30
0
        public ActionResult Create([Bind(Include = "TransactionNo,Emp_ID,Stock_ID,TQuantity,TotalPrice,Date")] Transaction transaction)
        {
            if (ModelState.IsValid)
            {
                db.Transactions.Add(transaction);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Emp_ID   = new SelectList(db.Employees, "Emp_ID", "password", transaction.Emp_ID);
            ViewBag.Stock_ID = new SelectList(db.Stocks, "Stock_ID", "Stock_Name", transaction.Stock_ID);
            return(View(transaction));
        }