protected void deleteproducttype_Click(object sender, EventArgs e)
        {
            Int32 deletebyID = 0;

            Int32.TryParse(id.Text.ToString(), out deletebyID);
            bool cekKedua   = RepositoryProduct.CekProductTypeID(deletebyID);
            bool cekPertama = RepositoryProductType.CekID(deletebyID);

            if (cekPertama)
            {
                if (cekKedua)
                {
                    Response.Write("<script>alert('Deleted product type can not have reference to other table.')</script>");
                }
                else
                {
                    RepositoryProductType.DeleteProductType(deletebyID);
                    Response.Write("<script>alert('Delete product type successfully.')</script>");
                    refresh();
                }
            }
            else
            {
                Response.Write("<script>alert('ID does not exists.')</script>");
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "View Product Type Page";
     if (Session["UserName"] == null)
     {
         Response.Redirect("../HomePage.aspx");
     }
     _allProduct.DataSource = RepositoryProductType.GetAll();
     _allProduct.DataBind();
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.Title = "Insert Product Page";
     if (Session["UserName"] == null)
     {
         Response.Redirect("../HomePage.aspx");
     }
     _allproducttype.DataSource = RepositoryProductType.GetAll();
     _allproducttype.DataBind();
     tableColor.Style.Add(HtmlTextWriterStyle.BackgroundColor, "Red");
 }
Exemple #4
0
        protected void Insert_Click(object sender, EventArgs e)
        {
            String prodtype = producttype.Text.ToString();
            String desc     = description.Text.ToString();

            if (validation(prodtype, desc))
            {
                RepositoryProductType.InsertProductType(prodtype, desc);
                Response.Write("<script>alert('Insert product type successfully.')</script>");
            }
            else
            {
                Response.Write("<script>alert('Product type must be consist of 5 character or more.')</script>");
            }
        }
        protected void updateproducttype_Click(object sender, EventArgs e)
        {
            String prodtype = producttype.Text.ToString();
            String desc     = description.Text.ToString();

            if (validation(prodtype, desc))
            {
                Int32 myid = Int32.Parse(Request.QueryString["id"]);
                RepositoryProductType.UpdateProductType(myid, prodtype, desc);
                Response.Write("<script>alert('Update product type successfully.')</script>");
            }
            else
            {
                Response.Write("<script>alert('Product type must be consist of 5 character or more.')</script>");
            }
        }
        protected void newproducttype_Click(object sender, EventArgs e)
        {
            Int32 myid = 0;

            Int32.TryParse(id.Text.ToString(), out myid);
            bool cekid = RepositoryProductType.CekID(myid);

            if (cekid)
            {
                Response.Redirect("InsertNewProductTypePage.aspx?id=" + myid);
            }
            else
            {
                Response.Write("<script>alert('ID does not exists.')</script>");
            }
        }
Exemple #7
0
        protected void updateproduct_Click(object sender, EventArgs e)
        {
            Int32 prodtypeid = 0;
            Int32 price      = 0;
            Int32 stock      = 0;
            Int32 ID         = 0;

            Int32.TryParse(producttypeid.Text.ToString(), out ID);
            bool cek = RepositoryProductType.CekID(ID);

            if (cek)
            {
                String name = productname.Text.ToString();
                if (Int32.TryParse(producttypeid.Text.ToString(), out prodtypeid) &&
                    Int32.TryParse(productstock.Text.ToString(), out stock) &&
                    Int32.TryParse(productprice.Text.ToString(), out price) && name != "")
                {
                    if (validation(price, stock))
                    {
                        Int32 myid = Int32.Parse(Request.QueryString["id"]);
                        RepositoryProduct.UpdateProduct(myid, prodtypeid, name, price, stock);
                        Response.Write("<script>alert('Update product successfully.')</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Stock must be 1 or more and price must be above 1000 and multiply of 1000.')</script>");
                    }
                }
                else
                {
                    Response.Write("<script>alert('Data can not be null and non numeric value.')</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('Product type id does not exists.')</script>");
            }
        }
 private void refresh()
 {
     _allproduct.DataSource = RepositoryProductType.GetAll();
     _allproduct.DataBind();
 }