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
John Mekubo
NA
11
2.3k
Selection Problem
Apr 10 2016 4:02 AM
Hi guys,
I am trying to check for inventory quantity in database. If quatinty entered in dispatch webform is less than inventory, the dispatch should continue. else i should see error message that dispatch quantity is more than inventory and terminate the process.
My code below gives the following results:
When i try dispatching quantity less than inventory, the error still pops up and the program does not continue to excecute dispatch. i do not want this.
I am implementing the code from addbutton that should insert item to gridview (only if quantity is more than inventory).
int SelectedDPItem;
int InventoryQTY;
int DinventoryQTY;
SqlConnection Connection = new SqlConnection("Data Source=localhost;Initial Catalog=warehousedb;Integrated Security=True ");
SqlDataAdapter INVadapter = new SqlDataAdapter("Select ItemID, ItemName, Quantity FROM inventory ", Connection);
SelectedDPItem = int.Parse(DropDownListItem_D.SelectedValue.ToString());
// Open Connection
Connection.Open();
SqlCommand Inventorychkcommand = new SqlCommand(("Select Quantity FROM inventory " + ("WHERE (ItemName LIKE \'"
+ (DropDownListItem_D.Text + "\')"))), Connection);
InventoryQTY = Convert.ToInt32(Inventorychkcommand.ExecuteScalar());
DinventoryQTY = Convert.ToInt32(txtQuantity_D.Text);
if (InventoryQTY < DinventoryQTY)
{
{
ClientScript.RegisterStartupScript(this.GetType(), "key", "<script>alert('sorry , Stock Balance is less than requested quantity.')</script>");
}
}
else
{
{
// procedure of inserting the record
AddNewRecordRowToGrid();
txtwaybill_D.Enabled = false;
DropDownListTransp.Enabled = false;
txtTruckNo_D.Enabled = false;
txtDrivername_D.Enabled = false;
DropDownListEmployee_D.Enabled = false;
btnNew.Enabled = false;
btnPostDispatch.Enabled = true;
DropDownListItem_D.Enabled = false;
txtDispatchDate.Enabled = false;
txtDestn.Enabled = false;
txtQuantity_D.Enabled = false;
txtDestn.Enabled = false;
}
}
Reply
Answers (
7
)
Lecture Timetable
How can i multiply a decimal? with a double?