コード例 #1
0
        protected void insertproduct_Click(object sender, EventArgs e)
        {
            Int32 prodtypeid = 0;
            Int32 stock      = 0;
            Int32 price      = 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))
                    {
                        RepositoryProduct.InsertProduct(name, prodtypeid, stock, price);
                        Response.Write("<script>alert('Insert 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>");
            }
        }