示例#1
0
        public ActionResult Create([Bind(Include = "TerritoryID,TerritoryName")] TERRITORY tERRITORY)
        {
            if (ModelState.IsValid)
            {
                if (tERRITORY.TerritoryName == null)
                {
                    ViewBag.Error           = "Null Input!";
                    Session["ErrorMessage"] = ViewBag.Error;
                    return(View(tERRITORY));
                }
                var count = db.TERRITORies.ToList().Count();
                if (count == 0)
                {
                    tERRITORY.TerritoryID   = "1";
                    tERRITORY.TerritoryName = "Canada";
                    db.TERRITORies.Add(tERRITORY);
                }
                else
                {
                    tERRITORY.TerritoryID = "0" + (count + 1).ToString();
                    db.TERRITORies.Add(tERRITORY);
                }

                db.TERRITORies.Add(tERRITORY);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                ViewBag.Error = "Invalid Input!";
            }

            return(View(tERRITORY));
        }
        public ActionResult Create([Bind(Include = "EmployeeID,EmployeeName,EmployeeAddress,Supervisor")] EMPLOYEE eMPLOYEE)
        {
            if (ModelState.IsValid)
            {
                var count = db.EMPLOYEEs.ToList().Count();
                if (count == 0)
                {
                    eMPLOYEE.EmployeeID = "1";
                    eMPLOYEE.Supervisor = "CEO";
                    db.EMPLOYEEs.Add(eMPLOYEE);
                }
                else
                {
                    eMPLOYEE.EmployeeID = (count + 1).ToString();

                    string supervisor = (db.EMPLOYEEs.Find(eMPLOYEE.Supervisor).EmployeeName) ?? " ";
                    eMPLOYEE.Supervisor = supervisor;
                    db.EMPLOYEEs.Add(eMPLOYEE);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeID = new SelectList(db.EMPLOYEEs, "EmployeeID", "EmployeeName", eMPLOYEE.EmployeeID);

            return(View(eMPLOYEE));
        }
        public IHttpActionResult Putincident(string id, incident incident)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != incident.incident_type)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Create([Bind(Include = "Id,CheckinDate,CheckoutDate,RoomType,HotelId,UserId,Description")] Reservation reservation)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Reservations.Add(reservation);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                ViewBag.HotelId = new SelectList(db.Hotels, "Id", "Name", reservation.HotelId);
            }
            catch (DbEntityValidationException ex)
            {
                foreach (var errors in ex.EntityValidationErrors)
                {
                    foreach (var validationError in errors.ValidationErrors)
                    {
                        string errorMessage = validationError.ErrorMessage;
                    }
                }

            }
            return View(reservation);
        }
        public ActionResult Create([Bind(Include = "SalespersonID,SalespersonName,SalespersonTelephone,SalespersonFax,TerritoryID")] SALESPERSON sALESPERSON)
        {
            if (ModelState.IsValid)
            {
                var count = db.SALESPERSONs.ToList().Count();
                if (count == 0)
                {
                    sALESPERSON.SalespersonID        = "01";
                    sALESPERSON.SalespersonName      = "Ikechukwu";
                    sALESPERSON.SalespersonTelephone = "2265068940";
                    sALESPERSON.SalespersonFax       = "555673";
                    sALESPERSON.TerritoryID          = "03";
                }
                else
                {
                    sALESPERSON.SalespersonID = "0" + (count + 1).ToString();
                }
                db.SALESPERSONs.Add(sALESPERSON);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TerritoryID = new SelectList(db.TERRITORies, "TerritoryID", "TerritoryName", sALESPERSON.TerritoryID);
            return(View(sALESPERSON));
        }
        public ActionResult Create([Bind(Include = "MaterialID,MaterialName,MaterialStandardCost,UnitOfMeasure")] RAWMATERIAL rawMaterial)
        {
            if (ModelState.IsValid)
            {
                var count = db.RAWMATERIALs.ToList().Count();
                if (count == 0)
                {
                    rawMaterial.MaterialID           = "01";
                    rawMaterial.MaterialName         = "Doe Material";
                    rawMaterial.MaterialStandardCost = "200";
                    rawMaterial.UnitOfMeasure        = "1";
                }
                else
                {
                    rawMaterial.MaterialID    = "0" + (count + 1).ToString();
                    rawMaterial.UnitOfMeasure = rawMaterial.UnitOfMeasure ?? "1";
                }

                db.RAWMATERIALs.Add(rawMaterial);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(rawMaterial));
        }
示例#7
0
        public ActionResult Cart(int id, string username)
        {
            User    User    = db.User.Where(a => a.UserName == username).FirstOrDefault();
            Product Product = db.Product.Find(id);

            Product.UserId = User.UserId;
            db.SaveChanges();
            Session["totalprice"] = db.Product.Where(a => a.UserId == User.UserId).Sum(a => a.ProductPrice);
            return(View(db.Product.Where(a => a.UserId == User.UserId).ToList()));
        }
        public ActionResult Create([Bind(Include = "Id,Name")] AspNetRoles aspNetRoles)
        {
            if (ModelState.IsValid)
            {
                db.AspNetRoles.Add(aspNetRoles);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetRoles));
        }
        public ActionResult Create([Bind(Include = "ProductLineID,ProductLineName")] PRODUCT_LINE pRODUCT_LINE)
        {
            if (ModelState.IsValid)
            {
                db.PRODUCT_LINE.Add(pRODUCT_LINE);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(pRODUCT_LINE));
        }
示例#10
0
        public ActionResult Create([Bind(Include = "Id,opis,data_start,data_koniec,color")] Spotkanie spotkanie)
        {
            if (ModelState.IsValid)
            {
                db.Spotkanie.Add(spotkanie);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(spotkanie));
        }
        public ActionResult Create([Bind(Include = "Id,Email,EmailConfirmed,PasswordHash,SecurityStamp,PhoneNumber,PhoneNumberConfirmed,TwoFactorEnabled,LockoutEndDateUtc,LockoutEnabled,AccessFailedCount,UserName")] AspNetUsers aspNetUsers)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUsers.Add(aspNetUsers);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(aspNetUsers));
        }
示例#12
0
        public ActionResult Create([Bind(Include = "Cat_id,Cat_name")] categories_table categories_table)
        {
            if (ModelState.IsValid)
            {
                db.categories_tables.Add(categories_table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(categories_table));
        }
示例#13
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,StarLevel,UpdateDate")] Hotel hotel)
        {
            if (ModelState.IsValid)
            {
                db.Hotels.Add(hotel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(hotel));
        }
        public ActionResult Create([Bind(Include = "Skill1")] SKILL sKILL)
        {
            if (ModelState.IsValid)
            {
                db.SKILLs.Add(sKILL);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sKILL));
        }
示例#15
0
        public ActionResult Create([Bind(Include = "Id,UserId,ClaimType,ClaimValue")] AspNetUserClaims aspNetUserClaims)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUserClaims.Add(aspNetUserClaims);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", aspNetUserClaims.UserId);
            return(View(aspNetUserClaims));
        }
示例#16
0
        public ActionResult Create([Bind(Include = "LoginProvider,ProviderKey,UserId")] AspNetUserLogins aspNetUserLogins)
        {
            if (ModelState.IsValid)
            {
                db.AspNetUserLogins.Add(aspNetUserLogins);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = new SelectList(db.AspNetUsers, "Id", "Email", aspNetUserLogins.UserId);
            return(View(aspNetUserLogins));
        }
        public ActionResult Create([Bind(Include = "ProductID,ProductDescription,ProductFinish,ProductStandardPrice,ProductLineID")] PRODUCT pRODUCT)
        {
            if (ModelState.IsValid)
            {
                db.PRODUCTs.Add(pRODUCT);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductLineID = new SelectList(db.PRODUCT_LINE, "ProductLineID", "ProductLineName", pRODUCT.ProductLineID);
            return(View(pRODUCT));
        }
示例#18
0
        public ActionResult Create([Bind(Include = "Pro_id,Pro_details,Pro_price,Pro_qty,Pro_name,Cat_Id")] product_table product_table)
        {
            if (ModelState.IsValid)
            {
                db.product_tables.Add(product_table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Cat_Id = new SelectList(db.categories_tables, "Cat_id", "Cat_name", product_table.Cat_Id);
            return(View(product_table));
        }
示例#19
0
        public ActionResult Create([Bind(Include = "u_id,user_name,user_address,user_password,user_type")] user_table user_table)
        {
            if (ModelState.IsValid)
            {
                user_table.user_password = this.Hash(user_table.user_password);
                db.user_tables.Add(user_table);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user_table));
        }
示例#20
0
        public ActionResult Create([Bind(Include = "Id,Name,Model,image_path,vehicle_description")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                vehicle.userId = User.Identity.GetUserId();
                db.Vehicles.Add(vehicle);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.userId = new SelectList(db.AspNetUsers, "Id", "Email", vehicle.userId);
            return(View(vehicle));
        }
示例#21
0
        public ActionResult Create([Bind(Include = "VendorID,MaterialID,SupplyUnitPrice,SupplyID")] SUPPLy sUPPLy)
        {
            if (ModelState.IsValid)
            {
                sUPPLy.SupplyID = GenerateID(sUPPLy.VendorID, sUPPLy.MaterialID);
                db.SUPPLIES.Add(sUPPLy);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MaterialID = new SelectList(db.RAWMATERIALs, "MaterialID", "MaterialName", sUPPLy.MaterialID);
            ViewBag.VendorID   = new SelectList(db.VENDORs, "VendorID", "VendorName", sUPPLy.VendorID);
            return(View(sUPPLy));
        }
        public ActionResult Create([Bind(Include = "Id,id_funkcyjna,id_klient,id_spotkanie,status")] Lista_spotkan lista_spotkan)
        {
            if (ModelState.IsValid)
            {
                db.Lista_spotkan.Add(lista_spotkan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.id_spotkanie = new SelectList(db.Spotkanie, "Id", "opis", lista_spotkan.id_spotkanie);
            ViewBag.id_funkcyjna = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_funkcyjna);
            ViewBag.id_klient    = new SelectList(db.Uzytkownik, "Id", "imie", lista_spotkan.id_klient);
            return(View(lista_spotkan));
        }
        public ActionResult Create([Bind(Include = "OrderID,ProductID,OrderedQuantity")] OrderedLine orderedLine)
        {
            if (ModelState.IsValid)
            {
                orderedLine.OrderdedLineID = GenerateID(orderedLine.OrderID, orderedLine.ProductID, orderedLine.OrderedQuantity.ToString());
                db.OrderedLines.Add(orderedLine);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderID   = new SelectList(db.ORDERs, "OrderID", "CustomerID", orderedLine.OrderID);
            ViewBag.ProductID = new SelectList(db.PRODUCTs, "ProductID", "ProductDescription", orderedLine.ProductID);
            return(View(orderedLine));
        }
示例#24
0
        public ActionResult Create([Bind(Include = "ProductID,MaterialID,GoesIntoQuantity,UsesID")] US uS)
        {
            if (ModelState.IsValid)
            {
                uS.UsesID = GenerateID(uS.ProductID, uS.MaterialID);

                db.USES.Add(uS);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID  = new SelectList(db.PRODUCTs, "ProductID", "ProductDescription", uS.ProductID);
            ViewBag.MaterialID = new SelectList(db.RAWMATERIALs, "MaterialID", "MaterialName", uS.MaterialID);
            return(View(uS));
        }
示例#25
0
 private void tbtYes_Click(object sender, EventArgs e)
 {
     try
     {
         string password    = txtPassword.Text;
         string newpasss    = txtNewPassword.Text;
         string newpassword = txtNewPass.Text;
         //MessageBox.Show(password.ToString() + " " + nhanVien.MatKhau);
         if (nhanVien.MatKhau.Trim() != password.ToString())
         {
             MessageBox.Show("Mật khẩu hiện tại không đúng");
             return;
         }
         else if (newpasss.Trim() != newpassword.Trim())
         {
             MessageBox.Show("Mật khẩu mới nhập không khớp");
             return;
         }
         else
         {
             nhanVien.MatKhau = newpasss;
             // db.Set<NhanVien>().Attach(nhanVien);
             db.Database.ExecuteSqlCommand("Update NhanVien set MatKhau ='" + newpasss + "' where MaNV = '" + nhanVien.MaNv + "'");
             db.SaveChanges();
             MessageBox.Show("Đổi Mật Khẩu Thành Công !");
             this.Close();
             frmMain frm = new frmMain(nhanVien);
             frm.Show();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Đổi Mật Khẩu Không Thành Công !" + ex.Message);
     }
 }
示例#26
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            string userName = txtID.Text;
            string Add      = txtDiaChi.Text;
            string Phone    = txtSDT.Text;
            string name     = txtHoTen.Text;

            if (userName == "")
            {
                MessageBox.Show("Nhấp chọn vào nhân viên cần edit", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (Add == "" || Phone == "" || name == "")
            {
                MessageBox.Show("Thông tin không được để trông", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var user = db.NhanViens.Where(s => s.MaNv == userName).FirstOrDefault();

            if (user != null)
            {
                //DataGridViewRow row = this.dgvListNV.Rows[local];
                var query = ("Update NhanVien set TenNV = N'" + txtHoTen.Text + "' ,DiaChi = N'" + txtDiaChi.Text + "',SDT='" + txtSDT.Text + "' where MaNV=N'" + txtID.Text + "'");
                db.Database.ExecuteSqlCommand(query);
                db.SaveChanges();
                Entities3 a   = new Entities3();
                var       lst = a.NhanViens.ToList();
                dgvListNV.DataSource = lst;
            }
            else
            {
                MessageBox.Show("Không tìm thấy ID trong database", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#27
0
 private void btCapNhat_Click(object sender, EventArgs e)
 {
     if (txtMaLoai.Text == "" || txtTenMon.Text == "" || txtGia.Text == "" || txtMaMon.Text == "")
     {
         MessageBox.Show("Vui long nhap day du thong tin mon an", "Thong bao", MessageBoxButtons.OK);
     }
     else
     {
         {
             string Lmon   = ("N'" + txtMaLoai.Text + "',N'" + txtTenMon.Text + "'");
             string values = ("N'" + txtMaMon.Text + "',N'" + txtTenMon.Text + "',N'" + txtGia.Text + "',N'" + txtMaLoai.Text + "'");
             context.Database.ExecuteSqlCommand("Insert into LoaiMon (MaLoai,TenMon) values (" + Lmon + ")");
             context.SaveChanges();
             context.Database.ExecuteSqlCommand("Insert into MonAn (MaMon,TenMon,GiaTien,MaLoai) values (" + values + ")");
             context.SaveChanges();
             MessageBox.Show("Thành công!", "Thông báo", MessageBoxButtons.OK);
             this.Close();
         }
     }
 }
示例#28
0
        public ActionResult Create([Bind(Include = "WorkCenterID,WorkCenterLocation")] WORKCENTER wORKCENTER)
        {
            if (ModelState.IsValid)
            {
                var count = db.WORKCENTERs.ToList().Count();
                if (count == 0)
                {
                    wORKCENTER.WorkCenterID       = "01";
                    wORKCENTER.WorkCenterLocation = "101 Dalmation St";
                }
                else
                {
                    wORKCENTER.WorkCenterID = "0" + (count + 1).ToString();
                }
                db.WORKCENTERs.Add(wORKCENTER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(wORKCENTER));
        }
示例#29
0
        public ActionResult Create([Bind(Include = "CustomerID,CustomerName,CustomerAddress,CustomerPostalCode")] CUSTOMER cUSTOMER)
        {
            if (ModelState.IsValid)
            {
                var count = db.TERRITORies.ToList().Count();
                if (count == 0)
                {
                    cUSTOMER.CustomerID         = "1";
                    cUSTOMER.CustomerName       = "John Doe";
                    cUSTOMER.CustomerPostalCode = "N96 2X6";
                }
                else
                {
                    cUSTOMER.CustomerID = (count + 1).ToString();
                }
                db.CUSTOMERs.Add(cUSTOMER);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(cUSTOMER));
        }
示例#30
0
        public ActionResult Create([Bind(Include = "Id,facebook,instagram,snapchat,twitter,id_uzytkownik")] Spolecznosc spolecznosc)
        {
            if (ModelState.IsValid)
            {
                var         u = db.AspNetUsers.SingleOrDefault(x => x.Email == User.Identity.Name);
                Uzytkownik  p = db.Uzytkownik.SingleOrDefault(x => x.id_aspUser == u.Id);
                Spolecznosc a = db.Spolecznosc.SingleOrDefault(x => x.id_uzytkownik == p.Id);
                if (a != null)
                {
                    return(Redirect("/UzytkownikHome/Index"));
                }
                else
                {
                    spolecznosc.id_uzytkownik = p.Id;
                    db.Spolecznosc.Add(spolecznosc);
                    db.SaveChanges();
                    return(Redirect("/UzytkownikHome/Index"));
                }
            }

            //  ViewBag.id_uzytkownik = new SelectList(db.Uzytkownik, "Id", "imie", spolecznosc.id_uzytkownik);
            return(View(spolecznosc));
        }