|
 |
|
ช่วยดู Error ให้ทีครับ มันบอกว่า Input String was not in a correct format |
|
 |
|
|
 |
 |
|

โค้ดในการ คืน stock เวลา กด Delete ครับ
มันเด้ง dialog box มา แต่พอกด OK มันก็ลบ ข้อมูลในตารางให้ครับ งง ช่วยทีครับ
Code (C#)
#region คืนค่า Stock ที่ยกเลิก
private void recoverInStock()
{
string sql2; string IDProduct = ""; string nProduct = ""; string Bill_No = "";
string Amount = ""; string InStock = ""; int quanboxpage; int Stock; int unitResult;
string constr = Properties.Settings.Default.DatabaseCarserviceConnectionString;
OleDbConnection conn = new OleDbConnection(constr);
sql2 = "Select [Bill_Detail].Bill_No ,[Product].Pro_ID ,[Product].Pro_Name_Model ,[Product].InStock ,[Bill_Detail].Amount From [Product] INNER Join [Bill_Detail] ON [Product].Pro_ID = [Bill_Detail].Pro_ID Where [Bill_Detail].Bill_No = '" + txtBillNo + "'";
OleDbCommand cmd = new OleDbCommand(sql2, conn);
try
{
this.Cursor = Cursors.WaitCursor;
conn.Open();
OleDbDataReader render = cmd.ExecuteReader();
while (render.Read())
{
Bill_No = render.GetValue(0).ToString();
IDProduct = render.GetValue(1).ToString();
nProduct = render.GetValue(2).ToString();
InStock = render.GetValue(3).ToString();
Amount = render.GetValue(4).ToString();
}
conn.Close();
this.Cursor = Cursors.Default;
txtProID.Text = IDProduct;
cmbProName.Text = nProduct;
quanboxpage = Convert.ToInt32(txtAmount.Text);
Stock = Convert.ToInt32(InStock);
unitResult = quanboxpage + Stock;
sql2 = "UPDATE Product Set InStock = '" + unitResult + "' Where Pro_ID = '" + IDProduct + "'";
OleDbDataAdapter adapter = new OleDbDataAdapter(sql2, conn);
DataSet data = new DataSet();
adapter.Fill(data, "Product");
data.Clear();
MessageBox.Show("สินค้าได้คืนค่า Stock เป็น" + unitResult);
}
catch (Exception exc)
{
MessageBox.Show(exc.Message, "Exception");
this.Cursor = Cursors.Default;
}
}
#endregion
Tag : .NET, Ms Access, Win (Windows App), C#, Windows

|
ประวัติการแก้ไข 2012-08-24 01:55:23
|
 |
 |
 |
 |
Date :
2012-08-24 01:54:03 |
By :
peteyothin |
View :
1958 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าเป็น DB Access พวก Number จะต้องไม่มี '' ครับ
Code (C#)
sql2 = "UPDATE Product Set InStock = " + unitResult + " Where Pro_ID = " + IDProduct + " ";
|
 |
 |
 |
 |
Date :
2012-08-24 09:27:50 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ได้ครับพี่วิน มันเด้งแบบในรูป แต่มันเพิ่มข้อมูลให้ แล้วพอกดลบ มันก็เด้งแบบรูปแรก แล้วก็ลบให้ แต่ว่ามัน เพิ่ม ลบ ได้แล้วทำไมมันถึงเด้งหว่า งง

|
 |
 |
 |
 |
Date :
2012-08-24 18:27:33 |
By :
peteyothin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|