public ActionResult Create([Bind(Include = "InventoryType_ID,InventoryType_Name,InventoryType_Description")] Inventory_Type inventory_Type)
        {
            if (ModelState.IsValid)
            {
                db.Inventory_Type.Add(inventory_Type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(inventory_Type));
        }
        public ActionResult Create([Bind(Include = "InvSupplier_ID,InvSupp_Name,InvSupp_Address,InvSupp_Email,InvSupp_Phone")] Inventory_Supplier inventory_Supplier)
        {
            if (ModelState.IsValid)
            {
                db.Inventory_Supplier.Add(inventory_Supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(inventory_Supplier));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "UserRole_ID,UserRole_Description")] User_Role user_Role)
        {
            if (ModelState.IsValid)
            {
                db.User_Role.Add(user_Role);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user_Role));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "BookSupplier_ID,BookSupplier_Name,BookSupplier_Phone,BookTitle,Condition,Edition,Date")] Book_Supplier book_Supplier)
        {
            if (ModelState.IsValid)
            {
                db.Book_Supplier.Add(book_Supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book_Supplier));
        }
        public ActionResult Create([Bind(Include = "PaymentType_ID,PaymentType_Name,PaymentType_Description")] Payment_Type payment_Type)
        {
            if (ModelState.IsValid)
            {
                db.Payment_Type.Add(payment_Type);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(payment_Type));
        }
Exemplo n.º 6
0
        public ActionResult Create([Bind(Include = "BookSupplier_ID,BookSupplier_Name,BookSupplier_Surname,BookSupplier_Email,BookSupplier_Address,BookSupplier_Type")] Book_Supplier book_Supplier)
        {
            if (ModelState.IsValid)
            {
                db.Book_Supplier.Add(book_Supplier);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(book_Supplier));
        }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "StockTurn_ID,Turn_Over_Ratio")] Stock_Turns stock_Turns)
        {
            if (ModelState.IsValid)
            {
                db.Stock_Turns.Add(stock_Turns);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(stock_Turns));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Customer_ID,Customer_Name,Customer_Surname,Customer_Email,Customer_Contact")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(customer));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "Purchase_ID,Purchase_Amount,Purchase_Date,BookSupplier_ID")] Purchase purchase)
        {
            if (ModelState.IsValid)
            {
                db.Purchases.Add(purchase);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookSupplier_ID = new SelectList(db.Book_Supplier, "BookSupplier_ID", "BookSupplier_Name", purchase.BookSupplier_ID);
            return(View(purchase));
        }
Exemplo n.º 10
0
        public ActionResult Create([Bind(Include = "ProsBook_ID,BookSupplier_ID,ProsBook_Date")] Prospective_Book prospective_Book)
        {
            if (ModelState.IsValid)
            {
                db.Prospective_Book.Add(prospective_Book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookSupplier_ID = new SelectList(db.Book_Supplier, "BookSupplier_ID", "BookSupplier_Name", prospective_Book.BookSupplier_ID);
            return(View(prospective_Book));
        }
Exemplo n.º 11
0
        public ActionResult Create([Bind(Include = "Write_Off_ID,Inventory_ID")] Write_Off_Stock write_Off_Stock)
        {
            if (ModelState.IsValid)
            {
                db.Write_Off_Stock.Add(write_Off_Stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Inventory_ID = new SelectList(db.Inventories, "Inventory_ID", "Inventory_Name", write_Off_Stock.Inventory_ID);
            return(View(write_Off_Stock));
        }
Exemplo n.º 12
0
        public ActionResult Create([Bind(Include = "Book_ID,Book_Title,Book_Author,ISBN,Book_Edition,BookStatus_ID")] Book book)
        {
            if (ModelState.IsValid)
            {
                db.Books.Add(book);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BookStatus_ID = new SelectList(db.Book_Status, "BookStatus_ID", "BookStatus_Description", book.BookStatus_ID);
            return(View(book));
        }
Exemplo n.º 13
0
        public ActionResult Create([Bind(Include = "Book_Request_ID,Customer_ID,Book_Title,Book_Author,Book_Edition,Book_Request_Description,Customer_Name,Customer_Surname,Customer_Phone")] Book_Request book_Request)
        {
            if (ModelState.IsValid)
            {
                db.Book_Request.Add(book_Request);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Customer_ID = new SelectList(db.Customers, "Customer_ID", "Customer_Name", book_Request.Customer_ID);
            return(View(book_Request));
        }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "Employee_ID,User_ID,Employee_Name,Employee_Surname,Employee_Address,Emp_Phone,Emp_Email,ID_Number,EmpTitle_ID,EmpGender_ID,ImageData")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmpGender_ID = new SelectList(db.Employee_Gender, "EmpGender_ID", "Gender_Description", employee.EmpGender_ID);
     ViewBag.EmpTitle_ID  = new SelectList(db.Employee_Title, "EmpTitle_ID", "Title_Description", employee.EmpTitle_ID);
     ViewBag.User_ID      = new SelectList(db.Users, "User_ID", "UserName", employee.User_ID);
     return(View(employee));
 }
Exemplo n.º 15
0
        public ActionResult Create([Bind(Include = "InvSuppOrder_ID,InvSupplier_ID,SuppOrder_Status_ID,Order_Date")] Inventory_Supplier_Order inventory_Supplier_Order)
        {
            if (ModelState.IsValid)
            {
                db.Inventory_Supplier_Order.Add(inventory_Supplier_Order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.InvSupplier_ID      = new SelectList(db.Inventory_Supplier, "InvSupplier_ID", "InvSupp_Name", inventory_Supplier_Order.InvSupplier_ID);
            ViewBag.SuppOrder_Status_ID = new SelectList(db.Order_Status, "SuppOrder_Status_ID", "Order_Status_Description", inventory_Supplier_Order.SuppOrder_Status_ID);
            return(View(inventory_Supplier_Order));
        }
        public ActionResult Create([Bind(Include = "Inventory_ID,InventoryType_ID,Inventory_Name,Inventory_Description,Inventory_Quantity,Minimum_Quantity,StockTurn_ID")] Inventory inventory)
        {
            if (ModelState.IsValid)
            {
                db.Inventories.Add(inventory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.InventoryType_ID = new SelectList(db.Inventory_Type, "InventoryType_ID", "InventoryType_Name", inventory.InventoryType_ID);
            ViewBag.StockTurn_ID     = new SelectList(db.Stock_Turns, "StockTurn_ID", "Turn_Over_Ratio", inventory.StockTurn_ID);
            return(View(inventory));
        }
Exemplo n.º 17
0
        public ActionResult Create([Bind(Include = "InvSuppOrder_ID,Inventory_ID,SuppOrder_Status_ID,Quanity,Line_Total,Date")] Order_Line order_Line)
        {
            if (ModelState.IsValid)
            {
                db.Order_Line.Add(order_Line);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Inventory_ID        = new SelectList(db.Inventories, "Inventory_ID", "Inventory_Name", order_Line.Inventory_ID);
            ViewBag.InvSuppOrder_ID     = new SelectList(db.Inventory_Supplier_Order, "InvSuppOrder_ID", "InvSuppOrder_ID", order_Line.InvSuppOrder_ID);
            ViewBag.SuppOrder_Status_ID = new SelectList(db.Order_Status, "SuppOrder_Status_ID", "Order_Status_Description", order_Line.SuppOrder_Status_ID);
            return(View(order_Line));
        }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "Sale_ID,Customer_ID,PaymentType_ID,Employee_ID,TaxRate_ID")] Sale sale)
        {
            if (ModelState.IsValid)
            {
                db.Sales.Add(sale);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.Customer_ID    = new SelectList(db.Customers, "Customer_ID", "Customer_Name", sale.Customer_ID);
            ViewBag.Employee_ID    = new SelectList(db.Employees, "Employee_ID", "Employee_Name", sale.Employee_ID);
            ViewBag.PaymentType_ID = new SelectList(db.Payment_Type, "PaymentType_ID", "PaymentType_Name", sale.PaymentType_ID);
            ViewBag.TaxRate_ID     = new SelectList(db.TaxRates, "TaxRate_ID", "Tax_Description", sale.TaxRate_ID);
            return(View(sale));
        }
Exemplo n.º 19
0
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (The_Book_MarketEntities dc = new The_Book_MarketEntities())
                {
                    var user = dc.Users.Where(a => a.ResetCode == model.ResetPassCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.UserPassword = EncryptPassword.Hash(model.NewPassword);
                        user.ResetCode    = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New password updated successfully";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Exemplo n.º 20
0
        public ActionResult SaveOrder(string name, long phone, string product, Sale[] order)
        {
            string result = "Error! could not complete sale!";

            if (name != null && product != null && order != null)
            {
                Customer model = new Customer();
                customerId            += 1;
                model.Customer_Name    = name;
                model.Customer_Contact = phone;
                model.Product_Name     = product;
                model.Customer_ID      = customerId;
                model.Date             = DateTime.Now;
                db.Customers.Add(model);

                foreach (var item in order)
                {
                    orderId += 1;
                    Sale sale = new Sale()
                    {
                        Sale_ID     = orderId,
                        Quantity    = item.Quantity,
                        Price       = item.Price,
                        Total       = item.Total,
                        Customer_ID = customerId
                    };
                    db.Sales.Add(sale);
                }
                db.SaveChanges();

                result = "Success! Sale Is Complete!";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "Employee_ID,User_ID,Employee_Name,Employee_Surname,Employee_Address,Emp_Phone,Emp_Email,ID_Number,EmpTitle_ID,EmpGender_ID,ImageData")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                /*string fileName = Path.GetFileNameWithoutExtension(employee.ImageFile.FileName);
                 * string extension = Path.GetExtension(employee.ImageFile.FileName);
                 * fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension;
                 * employee.ImageData = "~/Image/" + fileName;
                 * fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
                 * employee.ImageFile.SaveAs(fileName);*/


                using (The_Book_MarketEntities db = new The_Book_MarketEntities())
                {
                    db.Employees.Add(employee);
                    db.SaveChanges();
                }
                ViewBag.FileStatus = "Employee Added successfully.";


                return(RedirectToAction("Index"));
            }
            ViewBag.EmpGender_ID = new SelectList(db.Employee_Gender, "EmpGender_ID", "Gender_Description", employee.EmpGender_ID);
            ViewBag.EmpTitle_ID  = new SelectList(db.Employee_Title, "EmpTitle_ID", "Title_Description", employee.EmpTitle_ID);
            ViewBag.User_ID      = new SelectList(db.Users, "User_ID", "UserName", employee.User_ID);
            return(View(employee));
        }
Exemplo n.º 22
0
        public ActionResult Register([Bind(Exclude = "IsUserVerified, GUID")] User user)
        {
            bool   Status  = false;
            string message = "";

            //
            // Model Validation
            if (ModelState.IsValid)
            {
                user.IsUserVerified = false;
                #region //User already Exist

                var isExist = IsUserExist(user.UserName);
                if (isExist)
                {
                    ModelState.AddModelError("UserExist", "User already exist");
                    return(View(user));
                }

                #endregion

                #region Generate user Activation Code
                user.GUID = Guid.NewGuid();
                #endregion

                #region  Password Hashing
                user.UserPassword = EncryptPassword.Hash(user.UserPassword);
                //user.PassConfirm = EncryptPassword.Hash(user.PassConfirm);
                #endregion

                #region Save user to Database

                using (The_Book_MarketEntities dc = new The_Book_MarketEntities())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();

                    //Send Email to User
                    SendVerificationLinkEmail(user.UserName, user.GUID.ToString());
                    message = "Registration successfully done. Account activation link " +
                              " has been sent to user email id:" + user.UserName;
                    Status = true;
                }

                #endregion
            }
            else
            {
                message = "Invalid Request";
            }

            ViewBag.Message     = message;
            ViewBag.Status      = Status;
            ViewBag.UserRole_ID = new SelectList(db.User_Role, "UserRole_ID", "UserRole_Description", user.UserRole_ID);
            return(View(user));
        }
        public ActionResult Index(HttpPostedFileBase xmlFile)
        {
            if (xmlFile.ContentType.Equals("application/xml") || xmlFile.ContentType.Equals("text/xml"))
            {
                try
                {
                    var xmlPath = Server.MapPath("~/FileUpload" + xmlFile.FileName);
                    xmlFile.SaveAs(xmlPath);
                    XDocument       xDoc     = XDocument.Load(xmlPath);
                    List <Customer> custList = xDoc.Descendants("customer").Select
                                                   (customer => new Customer
                    {
                        Customer_ID      = Convert.ToInt32(customer.Element("id").Value),
                        Customer_Name    = customer.Element("name").Value,
                        Customer_Surname = customer.Element("surname").Value,
                        Customer_Email   = customer.Element("email").Value,
                        Customer_Contact = customer.Element("contact").Value
                    }).ToList();

                    using (The_Book_MarketEntities db = new The_Book_MarketEntities())
                    {
                        foreach (var i in custList)
                        {
                            var v = db.Customers.Where(a => a.Customer_ID.Equals(i.Customer_ID)).FirstOrDefault();

                            if (v != null)
                            {
                                v.Customer_ID      = i.Customer_ID;
                                v.Customer_Name    = i.Customer_Name;
                                v.Customer_Surname = i.Customer_Surname;
                                v.Customer_Email   = i.Customer_Email;
                                v.Customer_Contact = i.Customer_Contact;
                            }
                            else
                            {
                                db.Customers.Add(i);
                            }
                        }
                        db.SaveChanges();
                        ViewBag.Result = db.Customers.ToList();
                    }
                    return(View("Success"));
                }
                catch
                {
                    ViewBag.Error = "Cant Import XML File";
                    return(View("Index"));
                }
            }
            else
            {
                ViewBag.Error = "Cant Import XML File";
                return(View("Index"));
            }
        }
Exemplo n.º 24
0
        public ActionResult ForgotPassword(string userName)
        {
            //Verify Email ID
            //Generate Reset password link
            //Send Email
            string message = "";
            bool   status  = false;

            using (The_Book_MarketEntities dc = new The_Book_MarketEntities())
            {
                var account = dc.Users.Where(a => a.UserName == userName).FirstOrDefault();

                try
                {
                    if (account != null)
                    {
                        //Send email for reset password
                        string resetCode = Guid.NewGuid().ToString();
                        SendResetPasswordLinkEmail(account.UserName, resetCode);
                        //SendVerificationLinkEmail(account.UserName, resetCode);
                        account.ResetCode = resetCode;
                        // added to avoid confirm password area in model
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "Reset password link has been sent to your email id.";
                    }


                    else
                    {
                        message = "Account not found";
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string Message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
            }
            ViewBag.Message = message;
            return(View());
        }
Exemplo n.º 25
0
        public ActionResult SaveOrder(string name, String phone, string title, string condition, string edition, Purchase[] order)
        {
            string result = "Error! could not complete purchase!";

            if (name != null && phone != null && title != null && condition != null && edition != null && order != null)
            {
                Book_Supplier model = new Book_Supplier();
                customerId += 1;
                model.BookSupplier_Name  = name;
                model.BookSupplier_Phone = phone;
                model.BookTitle          = title;
                model.Condition          = condition;
                model.Edition            = edition;
                model.BookSupplier_ID    = customerId;
                model.Date = DateTime.Now;

                db.Book_Supplier.Add(model);

                foreach (var item in order)
                {
                    orderId += 1;
                    Purchase purchase = new Purchase()
                    {
                        Purchase_ID     = orderId,
                        Quantity        = item.Quantity,
                        Price           = item.Price,
                        Amount          = item.Amount,
                        BookSupplier_ID = customerId
                    };
                    db.Purchases.Add(purchase);
                }
                db.SaveChanges();

                result = "Success! Purchase Is Complete!";
            }
            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 26
0
        public ActionResult VerifyAccount(string id)
        {
            bool Status = false;

            using (The_Book_MarketEntities dc = new The_Book_MarketEntities())
            {
                /*dc.Configuration.ValidateOnSaveEnabled = false;
                 * // to avoid
                 * // Confirm password does not match issue on save changes*/
                var v = dc.Users.Where(a => a.GUID == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsUserVerified = true;
                    dc.SaveChanges();
                    Status = true;
                }
                else
                {
                    ViewBag.Message = "Invalid Request";
                }
            }
            ViewBag.Status = Status;
            return(View());
        }
Exemplo n.º 27
0
        public JsonResult UploadExcel(Customer customers, HttpPostedFileBase FileUpload)
        {
            List <string> data = new List <string>();

            if (FileUpload != null)
            {
                // tdata.ExecuteCommand("truncate table OtherCompanyAssets");
                if (FileUpload.ContentType == "application/vnd.ms-excel" || FileUpload.ContentType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
                {
                    string filename   = FileUpload.FileName;
                    string targetpath = Server.MapPath("~/Doc/");
                    FileUpload.SaveAs(targetpath + filename);
                    string pathToExcelFile  = targetpath + filename;
                    var    connectionString = "";
                    if (filename.EndsWith(".xls"))
                    {
                        connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", pathToExcelFile);
                    }
                    else if (filename.EndsWith(".xlsx"))
                    {
                        connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties=\"Excel 12.0 Xml;HDR=YES;IMEX=1\";", pathToExcelFile);
                    }

                    var adapter = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", connectionString);
                    var ds      = new DataSet();

                    adapter.Fill(ds, "ExcelTable");

                    DataTable dtable = ds.Tables["ExcelTable"];

                    string sheetName = "Sheet1";

                    var excelFile    = new ExcelQueryFactory(pathToExcelFile);
                    var artistAlbums = from a in excelFile.Worksheet <Customer>(sheetName) select a;

                    foreach (var a in artistAlbums)
                    {
                        try
                        {
                            if (a.Customer_Name != "" && a.Customer_Surname != "" && a.Customer_Email != "" && a.Customer_Contact.ToString() != "")
                            {
                                Customer TU = new Customer();
                                TU.Customer_Name    = a.Customer_Name;
                                TU.Customer_Surname = a.Customer_Surname;
                                TU.Customer_Email   = a.Customer_Email;
                                TU.Customer_Contact = a.Customer_Contact;
                                db.Customers.Add(TU);

                                db.SaveChanges();
                            }
                            else
                            {
                                data.Add("<ul>");
                                if (a.Customer_Name == "" || a.Customer_Name == null)
                                {
                                    data.Add("<li> name is required</li>");
                                }
                                if (a.Customer_Surname == "" || a.Customer_Surname == null)
                                {
                                    data.Add("<li> Address is required</li>");
                                }
                                if (a.Customer_Email == "" || a.Customer_Email == null)
                                {
                                    data.Add("<li>Email is required</li>");
                                }
                                if (a.Customer_Contact.ToString() == "" || a.Customer_Contact == null)
                                {
                                    data.Add("<li>Contact is required</li>");
                                }

                                data.Add("</ul>");
                                data.ToArray();
                                return(Json(data, JsonRequestBehavior.AllowGet));
                            }
                        }

                        catch (DbEntityValidationException ex)
                        {
                            foreach (var entityValidationErrors in ex.EntityValidationErrors)
                            {
                                foreach (var validationError in entityValidationErrors.ValidationErrors)
                                {
                                    Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
                                }
                            }
                        }
                    }
                    //deleting excel file from folder
                    //using (System.IO.File.Exists(pathToExcelFile)) { }
                    //if ((System.IO.File.Exists(pathToExcelFile)))
                    //{
                    //    System.IO.File.Delete(pathToExcelFile);
                    //}
                    return(Json("success", JsonRequestBehavior.AllowGet));
                }
                else
                {
                    //alert message for invalid file format
                    data.Add("<ul>");
                    data.Add("<li>Only Excel file format is allowed</li>");
                    data.Add("</ul>");
                    data.ToArray();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                data.Add("<ul>");
                if (FileUpload == null)
                {
                    data.Add("<li>Please choose Excel file</li>");
                }
                data.Add("</ul>");
                data.ToArray();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }