0
我正在使用visual studio 2008,在Web應用程序C#(前端)& SQL作爲後端。在文本框中,當用戶輸入數量時,我想首先檢查數量是否可用,然後處理&在gridview中顯示特定產品信息,如果數量不可用,則顯示消息...查看代碼我是艱難的是...如何在asp.net C#web應用程序中維護庫存?
public void stkMaintain()
{
SqlDataReader drd;
var qty = 0;
SqlCommand cmd = new SqlCommand("SELECT * from StockMstrDetail where ItemId='" + Convert.ToString(txtScanBarcode.Text) + "'", con);
//cmd.CommandType = CommandType.Text;
con.Open();
drd = cmd.ExecuteReader();
if (drd.HasRows)
{
while (drd.Read())
{
qty = Convert.ToInt32(drd["Quantity"].ToString());
}
if (Convert.ToInt32(txtentrqty.Text) > (Convert.ToInt32(qty)))
{
Response.Write("Product Not In Stock...!);
}
if(txtentrqty.Text=="")
{
Response.Write("Quantity Should not be blank...!");
}
}
con.Close();
}
和
protected void Button1_Click(object sender, EventArgs e)
{
stkMaintain();
SqlDataReader rdr;
SqlCommand cmd = new SqlCommand("SELECT * from Purchase_Details where ItemId='" + Convert.ToString(txtScanBarcode.Text) + "'", con);
cmd.CommandType = CommandType.Text;
using (con)
{
con.Open();
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
var purTaxPer = Convert.ToInt32(rdr["VatPercent"].ToString());
var salersdum = Convert.ToInt32(rdr["SaleRs"].ToString());
var cal1 = (Convert.ToDouble(salersdum)) * ((Convert.ToDouble(purTaxPer))/100);
var cal2 = (100 + (Convert.ToDouble(purTaxPer)));
var Itemtax = Math.Round(((Convert.ToDouble(cal1))/(Convert.ToDouble(cal2))) * 100, 2);
var ratewidoutax = Math.Round((Convert.ToDouble(salersdum)) - (Convert.ToDouble(Itemtax)), 2);
var pricewidoutax = Math.Round((Convert.ToDouble(ratewidoutax)) * (Convert.ToInt32(rdr["Quantity"].ToString())), 2);
var discount = Math.Round((Convert.ToInt32(ddldisc.SelectedValue)) * (Convert.ToDouble(ratewidoutax))/100.0, 2);
var discountamt = Math.Round((Convert.ToDouble(ratewidoutax)) - (Convert.ToDouble(discount)), 2);
var newitemtax = Math.Round((Convert.ToDouble(discountamt)) * (Convert.ToDouble(purTaxPer))/100.0, 2);
var newrate = Math.Round((Convert.ToDouble(newitemtax)) + (Convert.ToDouble(discountamt)), 2);
//Session["SrNo"] += rdr["Srno"].ToString() + "|";
Session["Barcode"] += rdr["ItemId"].ToString() + "|";
Session["Product Name"] += rdr["ProdName"].ToString() + "|";
Session["Desc"] += rdr["GroupName"].ToString() + "|";
Session["Rate"] += rdr["SaleRs"].ToString() + "|";
Session["Qty"] += rdr["Quantity"].ToString() + "|";
Session["Tax(%)"] += (Convert.ToString(purTaxPer)) + "|";
Session["Sale Price"] += Math.Round(Convert.ToInt32(rdr["Quantity"].ToString()) * Convert.ToDouble(rdr["SaleRs"].ToString()), 2) + "|";
Session["Item Tax"] += (Convert.ToString(newitemtax)) + "|";
Session["RateWithoutTax"] += (Convert.ToString(ratewidoutax)) + "|";
Session["PriceWithoutTax"] += (Convert.ToString(pricewidoutax)) + "|";
Session["Discount(%)"] += (Convert.ToString(ddldisc.SelectedValue)) + "|";
Session["Discount"] += (Convert.ToString(discount)) + "|";
Session["DiscountedAmt"] += (Convert.ToString(discountamt)) + "|";
Session["TotDiscount"] += Math.Round((Convert.ToDouble(rdr["Quantity"])) * (Convert.ToDouble(discount)), 2) + "|";
Session["TotDiscountedAmt"] += Math.Round((Convert.ToInt32(rdr["Quantity"])) * (Convert.ToDouble(discountamt)), 2) + "|";
Session["Final Rate"] += (Convert.ToString(newrate)) + "|";
Session["Final Amt"] += Math.Round((Convert.ToInt32(rdr["Quantity"])) * (Convert.ToDouble(newrate)), 2) + "|";
Session["Type"] += rdr["SrNoType"].ToString() + "|";
Session["IMEI/SrNo"] += rdr["IMEINO"].ToString() + "|";
Session["Brand"] += rdr["BrandName"].ToString() + "|";
Session["SaleDiscount"] += rdr["Colour"].ToString() + "|";
Session["SaleDisAmt"] += rdr["Colour"].ToString() + "|";
Session["Size"] += rdr["Colour"].ToString() + "|";
CreateTable();
當我運行兩個語句得到執行的項目。我想,如果首先獲得假,則第二個執行,反之亦然.. 人有任何想法.. Thnks &問候
它正常工作... – chirag