TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Tayyab Jatoi
NA
135
27.9k
Cant Add item in sale cart
Nov 25 2018 11:15 AM
Hi,
my item is not getting add into datagrid view when i press the add button.its giving me message "This Much Value is not available"
but my opening quantity in Item table is 10 as i am entering item Laptop.
private void addButton_Click(object sender, EventArgs e)
{
//First we need to check stock if stock available,if not we will give message
int stock = 0;
SqlCommand cmd1 = con.CreateCommand();
cmd1.CommandType = CommandType.Text;
cmd1.CommandText = "select * from Item where ItemName = '"+ itemNameValue +"'";
cmd1.ExecuteNonQuery();
DataTable dt1 = new DataTable();
SqlDataAdapter da1 = new SqlDataAdapter(cmd1);
da1.Fill(dt1);
foreach (DataRow dr1 in dt1.Rows)
{
stock = Convert.ToInt32(dr1["OpeningQuantity"].ToString());
}
if (Convert.ToUInt32(qtyValue.Text)>stock)
{
MessageBox.Show("This Much Value is not available");
}
else
{
DataRow dr = dt.NewRow();
dr["ItemName"] = itemNameValue.Text;
dr["Rate"] = salePrice.Text;
dr["Qty"] = qtyValue.Text;
dr["Amount"] = amountValue.Text;
dt.Rows.Add(dr);
dataGridView.DataSource = dt;
tot = tot + Convert.ToInt32(dr["total"].ToString());
totallabelvalue.Text = tot.ToString();
}
}
}
Reply
Answers (
5
)
What is the solution for TCP Zero Window in C#?
Error CS0106 The modifier 'private' is not valid for this it