here is my code
protected void btnSave_Click(object sender, EventArgs e)
{
lblMessage2.Visible = false;
if (txtname.Text == "")
{
// MessageBox1.ShowError("Enter Date Please");
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Enter Customer Name ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (ddlItems.SelectedIndex < 1)
{
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Select Item ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (ddlCategory.SelectedIndex < 1)
{
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Select Block Category ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (ddlpaymentmethod.SelectedIndex < 1)
{
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Select Payment Method ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (ddlorderstatus.SelectedIndex < 1)
{
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Select Order Status ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (txtcustomerqty.Text == "")
{
// MessageBox1.ShowError("Enter Date Please");
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Enter Customer Quantity ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
if (txtunitprice.Text == "")
{
// MessageBox1.ShowError("Enter Date Please");
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Enter Selling Price ... !!')</script>", false);
}
else
{
lblMessage2.Text = "";
// int availableInventoryQty = AvailableInventoryQty();
if (ddlstock.Text.Length > 0 && txtcustomerqty.Text.Length > 0)
{
double stock = Convert.ToDouble(ddlstock.Text);
double customerqty = Convert.ToDouble(txtcustomerqty.Text);
double tqty = stock - customerqty;
double gqty = tqty;
{
if (txtunitprice.Text.Length > 0 && txtcustomerqty.Text.Length > 0)
{
double unitprice2 = Convert.ToDouble(txtunitprice.Text);
double customerqty2 = Convert.ToDouble(txtcustomerqty.Text);
double grandtotal = unitprice2 * customerqty;
double total = grandtotal;
{
if (txtunitprice.Text.Length > 0 && txtdiscount.Text.Length > 0)
{
double unitprice = Convert.ToDouble(txtunitprice.Text);
double discount = Convert.ToDouble(txtdiscount.Text);
double sum = grandtotal - discount;
double sumb = sum;
//if (txtunitprice.Text.Length > 0 && txtquantity.Text.Length > 0)
{
string Currency = ("N");
string constr = ConfigurationManager.ConnectionStrings["db"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("InsertSixInchesSolidHandMoldNkwereORDER"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@UserName", Session["userName"]);
cmd.Parameters.AddWithValue("@Name", txtname.Text.Trim());
cmd.Parameters.AddWithValue("@Location", ddlLocation.Text.Trim());
cmd.Parameters.AddWithValue("@Item", ddlItems.Text.Trim());
// cmd.Parameters.AddWithValue("@Inches", ddlInches.Text.Trim()); //Name of rep
// cmd.Parameters.AddWithValue("@MouldType", ddlmouldcategory.Text.Trim());
cmd.Parameters.AddWithValue("@Category", ddlCategory.Text.Trim());
cmd.Parameters.AddWithValue("@StockRemaining", tqty);
cmd.Parameters.AddWithValue("@PaymentMethod", ddlpaymentmethod.Text.Trim());
cmd.Parameters.AddWithValue("@OrderStatus", ddlorderstatus.Text.Trim());
//Address
cmd.Parameters.AddWithValue("@QuantityOrdered", txtcustomerqty.Text.Trim());
cmd.Parameters.AddWithValue("@Discount", txtdiscount.Text.Trim());
cmd.Parameters.AddWithValue("@UnitPrice", txtunitprice.Text.Trim());
cmd.Parameters.AddWithValue("@TotalAmount", sum);
cmd.Parameters.AddWithValue("@OrderDate", DateTime.Today);
// cmd.Parameters.AddWithValue("@Location", ddlLocation.Text.Trim());
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
string message = string.Empty;
{
lblMessage2.Visible = true;
lblMessage2.Text = "Data Submitted Successfully";
}
ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Data Submitted Successfully ... !!')</script>", false);
}
}
}
// else
string a = "33a";
if (a == "a")
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "btnModalPopup();", true);
}
else if (a != "a")
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "btnModalPopup();", true);
}
// {
// ScriptManager.RegisterClientScriptBlock(btnSave, this.GetType(), "alert", "<script>alert('Please quantity required is more than the stock, Stock is 1 or less than 1, update stock ... !!')</script>", false);
// lbl.Text = "Data Submitted Sucessfully";
// btnSave.Show();
}
}
}
}
}
}
}
}
}
}
}
}
}