This code here dont allow insert when stock is 1 but i want it to be zero, if stock is zero dont submit
 
 //   string name = ddlcustomername.Text.Trim();
                                // string address = customeraddress.Text.Trim();
                                string customerphone = ddlcustomerphone.SelectedItem.Text.Trim();
                                string productcategory = ddlproductcategory.SelectedItem.Text.Trim();
                                string name = ddlcustomername.SelectedItem.Text.Trim();
                                string address = ddlcustomeraddress.SelectedItem.Text.Trim();
                                decimal unitPrice = Convert.ToDecimal(lblProductPrice.Text.Trim());
                                int availableQuantity = Convert.ToInt32(lblQuantityAvailable.Text.Trim());
                                int quantity = Convert.ToInt32(txtQuantity.Text.Trim());
                                int inserted = 0;
                                //  int availableInventoryQty = AvailableInventoryQty();
                                if (lblProductPrice.Text.Length > 0 && txtQuantity.Text.Length > 0)
                                {
                                    double stock = Convert.ToDouble(txtQuantity.Text);
                                    double customerqty = Convert.ToDouble(txtQuantity.Text);
                                    double tqty = stock - customerqty;
                                    double gqty = tqty;
                                    {
                                        if (lblProductPrice.Text.Length > 0 && txtQuantity.Text.Length > 0)
                                        {
                                            double unitprice2 = Convert.ToDouble(lblProductPrice.Text);
                                            double customerqty2 = Convert.ToDouble(txtQuantity.Text);
                                            double grandtotal = unitprice2 * customerqty;
                                            double total = grandtotal;
                                            {
                                                {
                                                    if ((availableQuantity != 0) && (quantity != 0) && (quantity < availableQuantity))
                                                    {
                                                        using (SqlConnection con = new SqlConnection())
                                                        {
                                                            con.ConnectionString = str;
                                                            using (SqlCommand cmd = new SqlCommand())
                                                            {
                                                                cmd.CommandType = CommandType.Text;
                                                                cmd.Connection = con;
                                                                //Change the query like below
                                                                //Make sure the column name matches the with the name provided in code as per your table
                                                                cmd.CommandText = "INSERT INTO Sells (UserName,CustomerName,CustomerAddress,CustomerPhone,ProductCategory,UnitPrice,Quantity,PaymentStatus,TotalAmount) VALUES(@UserName,@CustomerName,@CustomerAddress,@CustomerPhone,@ProductCategory,@UnitPrice,@Quantity,@PaymentStatus,@TotalAmount)";
                                                                cmd.Parameters.AddWithValue("@UserName", Session["userName"]);
                                                                cmd.Parameters.AddWithValue("@CustomerName", ddlcustomername.SelectedItem.Text.Trim());
                                                                cmd.Parameters.AddWithValue("@CustomerAddress", ddlcustomeraddress.SelectedItem.Text.Trim());
                                                                cmd.Parameters.AddWithValue("@CustomerPhone", customerphone);
                                                                cmd.Parameters.AddWithValue("@ProductCategory", productcategory);
                                                                cmd.Parameters.AddWithValue("@UnitPrice", lblProductPrice.Text.Trim());
                                                                cmd.Parameters.AddWithValue("@Quantity", txtQuantity.Text.Trim());
                                                                cmd.Parameters.AddWithValue("@PaymentStatus", ddlpaymentstatus.SelectedItem.Text.Trim());
                                                                cmd.Parameters.AddWithValue("@TotalAmount", grandtotal);
                                                               // cmd.Parameters.AddWithValue("@OrderDate", DateTime.Today);
                                                                con.Open();
                                                                inserted = cmd.ExecuteNonQuery();
                                                                con.Close();
                                                            }
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('No of Quantity entered is not available in Stock')", true);
                                                    }
                                                    if (inserted > 0)
                                                    {
                                                        int updatedStock = availableQuantity - quantity;
                                                        using (SqlConnection con = new SqlConnection())
                                                        {
                                                            con.ConnectionString = str;
                                                            using (SqlCommand cmd = new SqlCommand())
                                                            {
                                                                cmd.CommandType = CommandType.Text;
                                                                cmd.Connection = con;
                                                                cmd.CommandText = "UPDATE Products SET Quantity = " + updatedStock + " WHERE ProductCategory = '" + productcategory + "'";
                                                                con.Open();
                                                                inserted = cmd.ExecuteNonQuery();
                                                                con.Close();
                                                            }
                                                        }
                                                    }
                                                    BindProductsSells();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
   protected void ProductcategoryChanged(object sender, EventArgs e)
    {
        DataTable dt = GetDataTable("SELECT ProductCategory,UnitPrice,Quantity FROM Products WHERE ProductCategory = '" + ddlproductcategory.SelectedItem.Text.Trim() + "'");
        lblQuantityAvailable.Text = dt.Rows[0]["Quantity"].ToString();
        lblProductPrice.Text = dt.Rows[0]["UnitPrice"].ToString();
    }
    
    
    protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        gvProduct.PageIndex = e.NewPageIndex;
        BindProductsSells();
    }