Example #1
0
        public static void DeleteType(String ID)
        {
            MsProductType product = SearchTypeByID(ID);

            db.MsProductTypes.Remove(product);
            db.SaveChanges();
        }
Example #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["LoginSession"] == null)
     {
         Response.Redirect("../HomeView/Home.aspx");
     }
     else if (Request.QueryString["id"] == null)
     {
         Response.Redirect("../HomeView/Home.aspx");
     }
     else
     {
         String ID   = Session["LoginSession"].ToString();
         MsUser user = HomeController.FetchDataForHome(ID);
         if (user.RoleID != "RL2")
         {
             Response.Redirect("../HomeView/Home.aspx");
         }
         else
         {
             String        ProductID = Request.QueryString["id"];
             MsProduct     product   = AddToCartController.FetchDataByID(ProductID);
             MsProductType type      = AddToCartController.GetProductType(product.ProductTypeID);
             LabelProductName.Text  = product.ProductName.ToString();
             LabelProductStock.Text = product.ProductStock.ToString();
             LabelProductPrice.Text = product.ProductPrice.ToString();
             LabelProductType.Text  = type.ProductTypeName.ToString();
         }
     }
 }
Example #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["LoginSession"] == null)
     {
         Response.Redirect("../HomeView/Home.aspx");
     }
     else
     {
         String ID   = Session["LoginSession"].ToString();
         MsUser user = HomeController.FetchDataForHome(ID);
         if (user.RoleID != "RL1")
         {
             Response.Redirect("../HomeView/Home.aspx");
         }
         else
         {
             if (Request.QueryString["id"] == null)
             {
                 Response.Redirect("../HomeView/Home.aspx");
             }
             else
             {
                 if (!IsPostBack)
                 {
                     String        ProductTypeID = Request.QueryString["id"];
                     MsProductType type          = UpdateProductTypeController.SearchProductType(ProductTypeID);
                     BoxTypeName.Text    = type.ProductTypeName.ToString();
                     BoxDescription.Text = type.ProductTypeDescription.ToString();
                 }
             }
         }
     }
 }
Example #4
0
        protected void rptProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Label     lblProductID       = (Label)e.Item.FindControl("lblProductID");
            Label     lblProductName     = (Label)e.Item.FindControl("lblProductName");
            Label     lblProductStock    = (Label)e.Item.FindControl("lblProductStock");
            Label     lblProductType     = (Label)e.Item.FindControl("lblProductType");
            Label     lblProductQuantity = (Label)e.Item.FindControl("lblProductQuantity");
            var       div     = e.Item.FindControl("AdminAction");
            string    user    = Session["user_role"] == null ? "Guest" : Session["user_role"].ToString();
            MsProduct Product = (MsProduct)e.Item.DataItem;

            if (user == "Admin")
            {
                div.Visible = true;
            }

            lblProductID.Text       = Product.ID.ToString();
            lblProductName.Text     = Product.Name.ToString();
            lblProductStock.Text    = Product.Stock.ToString();
            lblProductQuantity.Text = Product.Price.ToString();
            MsProductType ProductType = ProductRepository.GetProductName(Product.ProductTypeID).ElementAt(0);

            lblProductType.Text = ProductType.Name.ToString();
            if (user == "Admin")
            {
                Button lbUpdate = (Button)e.Item.FindControl("lbUpdate");
                Button lbDelete = (Button)e.Item.FindControl("lbDelete");

                lbDelete.CommandArgument = Product.ID.ToString();
                lbUpdate.CommandArgument = Product.ID.ToString();
            }
        }
Example #5
0
        public static void UpdateProductType(int ID, string ProductType, string Description)
        {
            MsProductType Product = db.MsProductTypes.Single(x => x.ID == ID);

            Product.Name        = ProductType;
            Product.Description = Description;
            db.SaveChanges();
        }
Example #6
0
        public static void UpdateType(String ID, String TypeName, String Desc)
        {
            MsProductType product = SearchTypeByID(ID);

            product.ProductTypeName        = TypeName;
            product.ProductTypeDescription = Desc;
            db.SaveChanges();
        }
Example #7
0
        public static MsProductType InitProductType(Int64 ID, String Name, String Desc)
        {
            MsProductType ProductType = new MsProductType();

            ProductType.ProductTypeID          = "PY" + ID;
            ProductType.ProductTypeName        = Name;
            ProductType.ProductTypeDescription = Desc;
            return(ProductType);
        }
Example #8
0
        public static Response DoInsertProduct(String TypeID, String Name, int Price, int Stock, Int64 ID)
        {
            MsProductType type = Repository.RepositoryMsProductType.SearchTypeByID(TypeID);

            if (type == null)
            {
                return(new Response(false, "Type ID Cannot Found"));
            }
            Repository.RepositoryMsProduct.InsertProduct(TypeID, Name, Price, Stock, ID);
            return(new Response(true));
        }
Example #9
0
        public static Response DoInsertProductType(Int64 ID, String Name, String Description)
        {
            MsProductType type = Repository.RepositoryMsProductType.SearchTypeByName(Name);

            if (type != null)
            {
                return(new Response(false, "Product Type Name Must be Unique"));
            }
            Repository.RepositoryMsProductType.InsertType(ID, Name, Description);
            return(new Response(true));
        }
Example #10
0
        public static Response UpdateProductType(String ID, String TypeName, String Desc)
        {
            MsProductType type = Repository.RepositoryMsProductType.SearchTypeByName(TypeName);

            if (type != null)
            {
                return(new Response(false, "Product Type Name Must be Unique"));
            }
            Repository.RepositoryMsProductType.UpdateType(ID, TypeName, Desc);
            return(new Response(true));
        }
        public static MsProductType initProduct(int ID, string ProductType, string Description)
        {
            MsProductType Product = new MsProductType()
            {
                ID          = ID,
                Name        = ProductType,
                Description = Description
            };

            return(Product);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         HideErrorMessage();
         if (Session["user_role"] == null || Session["user_role"].ToString() != "Admin")
         {
             Response.Redirect("../Home/index.aspx");
         }
         MsProductType ProductType = ProductRepository.GetOneProductType(Convert.ToInt32(Session["update_id"].ToString())).ElementAt(0);
         txtProductType.Text = ProductType.Name.ToString();
         txtDescription.Text = ProductType.Description.ToString();
     }
 }
        protected void rptProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Label         lblProductTypeID = (Label)e.Item.FindControl("lblProductTypeID");
            Label         lblProductType   = (Label)e.Item.FindControl("lblProductType");
            TextBox       txtDesc          = (TextBox)e.Item.FindControl("txtDesc");
            MsProductType ProductType      = (MsProductType)e.Item.DataItem;

            lblProductTypeID.Text = ProductType.ID.ToString();
            lblProductType.Text   = ProductType.Name.ToString();
            txtDesc.Text          = ProductType.Description.ToString();

            Button lbUpdate = (Button)e.Item.FindControl("lbUpdate");
            Button lbDelete = (Button)e.Item.FindControl("lbDelete");

            lbDelete.CommandArgument = ProductType.ID.ToString();
            lbUpdate.CommandArgument = ProductType.ID.ToString();
        }
Example #14
0
        protected void rptProducts_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Label     lblProductID       = (Label)e.Item.FindControl("lblProductID");
            Label     lblProductName     = (Label)e.Item.FindControl("lblProductName");
            Label     lblProductStock    = (Label)e.Item.FindControl("lblProductStock");
            Label     lblProductType     = (Label)e.Item.FindControl("lblProductType");
            Label     lblProductQuantity = (Label)e.Item.FindControl("lblProductQuantity");
            string    user    = Session["user_role"] == null ? "Guest" : Session["user_role"].ToString();
            MsProduct Product = (MsProduct)e.Item.DataItem;

            lblProductID.Text       = Product.ID.ToString();
            lblProductName.Text     = Product.Name.ToString();
            lblProductStock.Text    = Product.Stock.ToString();
            lblProductQuantity.Text = Product.Price.ToString();
            MsProductType ProductType = ProductRepository.GetProductName(Product.ProductTypeID).ElementAt(0);

            lblProductType.Text = ProductType.Name.ToString();
        }