/*เพิ่มข้อมูลใน list*/ void PuseiQty(ref DataGridView grd,string ProductId) { DGVQTY.Rows.Clear(); foreach (DataGridViewRow r in grd.Rows) { ProductionNew.QtyOnPalet q = new ProductionNew.QtyOnPalet(ProductId, r.Cells["No"].Value, r.Cells["Qty"].Value); iQty.Add(q); //DGVQTY.Rows.Add(new object[] { r.Cells["No"].Value, r.Cells["Qty"].Value }); } }
/*ดึงข้อมูลใบสั่งขาย*/ private void LoadForUpdate() { #region HEAD string sql = "SELECT * FROM SALE_ORDER_HEAD h INNER JOIN Customer c ON c.CustomerId = h.CustomerId WHERE h.OrderId = '" + EditID + "' "; DataTable data = Class.DBConnString.clsDB.QueryDataTable(sql); if (data.Rows.Count > 0) { DataRow r = data.Rows[0]; txtSaleOrderId.Text = r["OrderId"].ToString(); dateTimePicker1.Value = Convert.ToDateTime(r["OrderDate"]); txtCustomer.Text = "[" + r["CustomerId"].ToString() + "] " + r["CustomerName"].ToString(); txtRef.Text = r["OrderRef"].ToString(); } #endregion #region DETAIL sql = "SELECT d.*,p.*,(d.DetailQuantity - d.DetailQuantitySaled) AS Balance FROM SALE_ORDER_DETAIL d INNER JOIN PRODUCT p ON p.ProductId = d.ProductId WHERE d.OrderId = '" + EditID + "' "; data = Class.DBConnString.clsDB.QueryDataTable(sql); foreach (DataRow r in data.Rows) { DgvProduct.Rows.Add(new object[] { r["ProductId"], r["ProductName"],r["LastPriceSaleUnit"], r["DetailQuantity"], r["DetailQuantitySaled"], r["Balance"], //"[" + r["UnitPackId"] + "] " + r["UnitPackName"], r["DateSend"] == DBNull.Value ? null : Convert.ToDateTime(r["DateSend"], new System.Globalization.CultureInfo("th-TH")).ToString("dd-MM-yyyy") }); } #endregion #region QTY sql = "SELECT * FROM SALE_ORDER_QTY WHERE OrderId = '" + EditID + "' "; data = Class.DBConnString.clsDB.QueryDataTable(sql); iQty = new List<ProductionNew.QtyOnPalet>(); foreach (DataRow r in data.Rows) { ProductionNew.QtyOnPalet q = new ProductionNew.QtyOnPalet(r["ProductId"], r["OrderPack"], r["OrderQty"]); iQty.Add(q); } #endregion }