示例#1
0
 /*ค้นหาสินค้าจาก dialog เก็บลงใน list และแสดงใน datagridview*/
 public void SearchProduct(TextBox name)
 {
     Dialog.frmDialogSearchProductResignment frm;
     frm = new Dialog.frmDialogSearchProductResignment(name.Text.Trim(), Class.Function.GetTextId(txtProduct.Text), GetStrPoId(), GetStrSum(), 1, txtReq.Text);
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK)
     {
         dgvDetail.ColumnCount = 15;
         FormatdgvDetail();
         foreach (String id in frm.PoDetailId())
         {
             //String PriceUnit = frm.PriceUnit;
             String sql = "";
             //sql = "select PRODUCT.ProductId,PRODUCT.ProductName,'' as NumPack,UNITPACK.UnitPackName,'' as NumSale,UNITSALE.UnitSaleName,'' as [Weight]," +
             //    "'กก.' as UnitWeight,isnull((select top 1 RECEIVE_DETAIL.ReceiveDetailPriceUnit from RECEIVE_DETAIL inner join RECEIVE_HEAD " +
             //    "on RECEIVE_HEAD.ReceiveHeadId=RECEIVE_DETAIL.ReceiveHeadId where PRODUCT.ProductId = RECEIVE_DETAIL.ProductId " +
             //    "order by RECEIVE_HEAD.ReceiveHeadDate desc),'0') as ReceiveDetailPriceUnit,'' as Distext,'' as Dis,'' as DiscountBth,'' as w,'' as t," +
             //    "'' as TotalPrice from PRODUCT inner join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId inner join UNITSALE " +
             //    "on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId where PRODUCT.ProductId='" + id + "'";
             sql = "select PRODUCT.ProductId,PRODUCT.ProductName,'' as NumPack,UNITPACK.UnitPackName,'' as NumSale,UNITSALE.UnitSaleName,'' as [Weight]," +
                 "'กก.' as UnitWeight,'' as ReceiveDetailPriceUnit,'' as Distext,'' as Dis,'' as DiscountBth,'' as w,'' as t," +
                 "'' as TotalPrice from PRODUCT inner join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId inner join UNITSALE " +
                 "on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId where PRODUCT.ProductId='" + id + "'";
             DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);
             foreach (DataRow row in dtNew.Rows)
             {
                 Double test = Convert.ToDouble(Class.Function.CostTopReturn(id));
                 row[8] = test.ToString("N2");
                 uni = 0;
                 for (int nbRow = 0; nbRow < dgvDetail.Rows.Count; nbRow++)
                 {
                     string value = dgvDetail.Rows[nbRow].Cells[0].Value.ToString();
                     if (id == value) { uni += 1; }
                 }
                 if (uni == 0) { dgvDetail.Rows.Add(row.ItemArray); }
                 foreach (DataGridViewRow r in dgvDetail.Rows)
                 {
                     if (r.Index % 2 == 0) { r.DefaultCellStyle.BackColor = Color.LightBlue; }
                     else { r.DefaultCellStyle.BackColor = Color.SkyBlue; }
                 }
             }
         }
     }
 }
示例#2
0
 /*ค้นหารายการสินค้าที่ดึงมาจาก Dialog เลือกรายการสินค้า*/
 public void SearchProduct(TextBox Name)
 {
     Dialog.frmDialogSearchProductResignment frm;
     frm = new Dialog.frmDialogSearchProductResignment(Name.Text.Trim());
     frm.ShowDialog();
     if (frm.DialogResult == DialogResult.OK)
     {
         dgvDetail.ColumnCount = 12;
         FormatdgvSaleAdding();
         foreach (String id in frm.PoDetailId())
         {
             String sql = "select PRODUCT.ProductId,PRODUCT.ProductName,'' as NumPack,UNITPACK.UnitPackName,'' as NumSale,UNITSALE.UnitSaleName,'' as [Weight]," +
                 "'กก.' as UnitWeight,'' as ReceiveDetailPriceUnit,'' as Distext,'' as Dis,'' as DiscountBth,'' as w," +
                 "'' as t,'' as TotalPrice from PRODUCT inner join UNITPACK on UNITPACK.UnitPackId=PRODUCT.UnitPackId inner join UNITSALE " +
                 "on UNITSALE.UnitSaleId=PRODUCT.UnitSaleId " +
                 //"inner join CO_REQ_DETAIL on CO_REQ_DETAIL.ProductId=PRODUCT.ProductId " +
                 "where PRODUCT.ProductId='" + id + "'";
             DataTable dtNew = Class.DBConnString.clsDB.QueryDataTable(sql);
             foreach (DataRow row in dtNew.Rows)
             {
                 Double test = Convert.ToDouble(Class.Function.CostTopReturn(id));
                 row[8] = test.ToString();
                 uni = 0;
                 for (int nbRow = 0; nbRow < dgvDetail.Rows.Count; nbRow++)
                 {
                     string value = dgvDetail.Rows[nbRow].Cells[0].Value.ToString();
                     if (id == value) { uni += 1; }
                 }
                 if (uni == 0) { dgvDetail.Rows.Add(row.ItemArray); }
                 foreach (DataGridViewRow r in dgvDetail.Rows)
                 {
                     if (r.Index % 2 == 0) { r.DefaultCellStyle.BackColor = Color.LightBlue; }
                     else { r.DefaultCellStyle.BackColor = Color.SkyBlue; }
                 }
             }
         }
     }
 }