protected void Button1_Click(object sender, EventArgs e) { var listProduct = GetProduct(DropDownList1.SelectedItem.Value); modal.Product = DropDownList1.SelectedValue; modal.price = listProduct[0].Price; modal.ProductQty = quantity_txt.Text; if (quantity_txt.Text.Length > 0) { clsOrder clsOrder = new clsOrder(); var result = clsOrder.CheckQuantityValid(quantity_txt.Text); if (result) { var total = int.Parse(listProduct[0].Price) * int.Parse(quantity_txt.Text.ToString()); modal.Total = total.ToString(); modal.Name = Session["UserName"].ToString(); string constring = ConfigurationManager.ConnectionStrings["studentconn"].ToString(); con = new SqlConnection(constring); var listCustomer = AddOrderItem(modal); if (listCustomer) { var orderItem = GetOrderItem(modal.Name); table.Columns.Add("Product"); table.Columns.Add("Quantity"); table.Columns.Add("Price Per Unit"); table.Columns.Add("Total Price"); for (int i = 0; i < orderItem.Count; i++) { table.Rows.Add(orderItem[i].Product, orderItem[i].ProductQty, orderItem[i].price, orderItem[i].Total); } DataGrid1.DataSource = table; DataGrid1.DataBind(); } //product_txt.Text = ""; quantity_txt.Text = ""; //total_txt.Text = "" ; } else { var script = String.Format("alert('{0} Please Using Digit Value Only for Quantity ')", Session["Name"].ToString()); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", script.ToString(), true); } } else { var script = String.Format("alert('{0} Please Enter some Quantity ')", Session["Name"].ToString()); this.Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", script.ToString(), true); } }
public void QuantityValidPropertyOK() { clsOrder AWidget = new clsOrder(); string TestData = "1"; AWidget.Quantity = TestData; var Error = AWidget.CheckQuantityValid(TestData); Assert.AreEqual(Error, true); }