private void checkProduct() { string codee; int codeproduct; if (i != 0) { for (i = 0; i <= dt.Rows.Count - 1; i++) { codee = dt.Rows[i]["รหัสบาร์โค้ด"].ToString(); if (txtcodeProduct.Text == codee.ToString()) { codeproduct = Convert.ToInt32(dt.Rows[i]["จำนวน"]); codeproduct = codeproduct + 1; dr = dt.Rows[i]; dt.Rows[i]["จำนวน"] = codeproduct; } if (i == dt.Rows.Count - 1) { if (txtcodeProduct.Text != codee.ToString()) { MessageBox.Show("ต้องเพิ่มใหม่นะ"); myGridView.DataSource = CreateDsToDt(); } } txtcodeProduct.Clear(); } } if (i == 0) { myGridView.DataSource = CreateDsToDt(); } }
private object CreateDsToDt() { System.Data.SqlClient.SqlConnection objConn = new System.Data.SqlClient.SqlConnection(); System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand(); System.Data.SqlClient.SqlDataAdapter dtAdapter = new System.Data.SqlClient.SqlDataAdapter(); String strConnString, strSQL; strConnString = "Data Source=MARKETINGYUI\\SQLEXPRESS;Initial Catalog = bacode;Integrated Security =True"; strSQL = " SELECT Product_code AS รหัสบาร์โค้ด, Product_name AS ชื่อสินค้า, Product_pricep AS ราคาทั่วไป, Product_pricem AS ราคาสมาชิก,countt AS จำนวน FROM Product WHERE Product_code=@Product_code "; objCmd.Parameters.AddWithValue("Product_code", txtcodeProduct.Text); objConn.ConnectionString = strConnString; objCmd.Connection = objConn; objCmd.CommandText = strSQL; objCmd.CommandType = CommandType.Text; dtAdapter.SelectCommand = objCmd; dtAdapter.Fill(ds); dt = ds.Tables[0]; dr = dt.Rows[0]; label4.Text = i.ToString(); dt.Rows[i]["จำนวน"] = 1; i = i + 1; objConn.Close(); objConn = null; dtAdapter = null; txtcodeProduct.Clear(); return dt; //*** Return DataTable ***// }
DataRow newCustomersRow = dataSet1.Tables["Customers"].NewRow(); newCustomersRow["CustomerID"] = "ALFKI"; newCustomersRow["CompanyName"] = "Alfreds Futterkiste"; dataSet1.Tables["Customers"].Rows.Add(newCustomersRow);
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง