Beispiel #1
0
 public void updateProductionRequestDetailCells()
 {
     if (isUpdating && entranceStock != null && entranceStockDetails.Count < dgvStockEntranceDetails.RowCount)
     {
         ProductAttributeService productAttrService = new ProductAttributeService();
         for (int i = 0; i < entranceStockDetails.Count; i++)
         {
             // Product + Attribute
             if (dgvStockEntranceDetails.Rows[i].Cells[ProductAttrCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvStockEntranceDetails.Rows[i].Cells[ProductAttrCell];
                 try
                 {
                     pkgBoxCell.Value = productAttrService.GetProductAttribute(entranceStockDetails[i].ProductId,
                                                                               entranceStockDetails[i].AttributeId).Id;
                 }
                 catch { }
             }
             // Unit
             if (dgvStockEntranceDetails.Rows[i].Cells[UnitCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvStockEntranceDetails.Rows[i].Cells[UnitCell];
                 try
                 {
                     pkgBoxCell.Value = entranceStockDetails[i].UnitId;
                 }
                 catch { }
             }
         }
     }
 }
Beispiel #2
0
        private void dgvStockEntranceDetails_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            DataGridView dgv = (DataGridView)sender;

            if (entranceStockDetails == null)
            {
                entranceStockDetails = new BindingList <EntranceStockDetail>();
            }
            if (entranceStockDetails.Count < dgvStockEntranceDetails.RowCount - 1)
            {
                EntranceStockDetail entranceStockDetail = new EntranceStockDetail();
                entranceStockDetails.Add(entranceStockDetail);
            }
            if (dgv.CurrentCell.Value != null)
            {
                switch (e.ColumnIndex)
                {
                case ProductAttrCell:
                {
                    ProductAttributeService productAttrService = new ProductAttributeService();
                    ProductAttribute        pa = productAttrService.GetProductAttribute((int)dgv.CurrentCell.Value);
                    if (pa != null)
                    {
                        entranceStockDetails[e.RowIndex].ProductId   = pa.ProductId;
                        entranceStockDetails[e.RowIndex].AttributeId = pa.AttributeId;
                    }
                } break;

                case NumberUnitCell:
                {
                    int value = (int)dgv.CurrentCell.Value;
                    if (value < 0)
                    {
                        entranceStockDetails[e.RowIndex].NumberUnit = 0;
                    }
                    else
                    {
                        entranceStockDetails[e.RowIndex].NumberUnit = value;
                    }
                } break;

                case UnitCell:
                    entranceStockDetails[e.RowIndex].UnitId = (int)dgv.CurrentCell.Value;
                    break;

                case NoteCell:
                    entranceStockDetails[e.RowIndex].Note = (string)dgv.CurrentCell.Value;
                    break;
                }
            }
        }
 private void dgwOrderDetails_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     DataGridView dgv = (DataGridView)sender;
     if (orderDetails == null)
     {
         orderDetails = new BindingList<OrderDetail>();
     }
     if (orderDetails.Count < dgwOrderDetails.RowCount - 1)
     {
         OrderDetail orderDetail = new OrderDetail();
         orderDetails.Add(orderDetail);
     }
     if (dgv.CurrentCell.Value != null)
     {
         switch (e.ColumnIndex)
         {
             case ProductAttrCell:
                 {
                     ProductAttributeService productAttrService = new ProductAttributeService();
                     ProductAttribute pa = productAttrService.GetProductAttribute((int)dgv.CurrentCell.Value);
                     if (pa != null)
                     {
                         orderDetails[e.RowIndex].ProductId = pa.ProductId;
                         orderDetails[e.RowIndex].AttributeId = pa.AttributeId;
                     }
                 } break;
             case PriceCell:
                 {
                     double price = 0;
                     try
                     {
                         price = (double)dgv.CurrentCell.Value;
                         if (price < 0)
                             price = 0;
                     }
                     catch { price = 0; }
                     orderDetails[e.RowIndex].Price = price;
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(price.ToString());
                 } break;
             case CommissionCell:
                 {
                     double commission = 0;
                     try
                     {
                         commission = (double)dgv.CurrentCell.Value;
                         if (commission < 0)
                             commission = 0;
                     }
                     catch { commission = 0; }
                     orderDetails[e.RowIndex].Commission = commission;
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(commission.ToString());
                 } break;
             case TotalCell:
                 {
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(orderDetails[e.RowIndex].Cost.ToString());
                 } break;
             case NoteCell:
                 {
                     orderDetails[e.RowIndex].Note = (string)dgv.CurrentCell.Value;
                 } break;
             default:
                 break;
         }
     }
     calculateNumberUnit(dgv, e.RowIndex, e.ColumnIndex);
     calculateTotal();
     orderDetails[e.RowIndex].Cost = (int)dgwOrderDetails.Rows[e.RowIndex].Cells[NumberUnitCell].Value
         * (double)dgwOrderDetails.Rows[e.RowIndex].Cells[PriceCell].Value;
     dgwOrderDetails.Rows[e.RowIndex].Cells[TotalCell].ToolTipText = Global.formatVNDCurrencyText(orderDetails[e.RowIndex].Cost.ToString());
 }
 public void updateProductionRequestDetailCells()
 {
     if (isUpdating && order != null && orderDetails.Count < dgwOrderDetails.RowCount)
     {
         ProductAttributeService productAttrService = new ProductAttributeService();
         for (int i = 0; i < orderDetails.Count; i++)
         {
             if (dgwOrderDetails.Rows[i].Cells[ProductAttrCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgwOrderDetails.Rows[i].Cells[ProductAttrCell];
                 try
                 {
                     pkgBoxCell.Value = productAttrService.GetProductAttribute(orderDetails[i].ProductId, orderDetails[i].AttributeId).Id;
                 }
                 catch { }
             }
             // Unit
             if (dgwOrderDetails.Rows[i].Cells[UnitCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgwOrderDetails.Rows[i].Cells[UnitCell];
                 try
                 {
                     pkgBoxCell.Value = orderDetails[i].UnitId;
                 }
                 catch { }
             }
         }
     }            
 }
 public void updateProductionRequestDetailCells()
 {
     ProductAttributeService productAttrService = new ProductAttributeService();
     if (isUpdating && productionRequest != null && productionRequestDetailInProductions.Count < dgvProduct.RowCount)
     {
         for (int i = 0; i < productionRequestDetailInProductions.Count; i++)
         {
             if (dgvProduct.Rows[i].Cells[ProductAttrCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvProduct.Rows[i].Cells[ProductAttrCell];
                 try
                 {
                     pkgBoxCell.Value = productAttrService.GetProductAttribute(productionRequestDetailInProductions[i].ProductId,
                         productionRequestDetailInProductions[i].AttributeId).Id;
                 }
                 catch { }
             }
             // Unit
             if (dgvProduct.Rows[i].Cells[UnitCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvProduct.Rows[i].Cells[UnitCell];
                 try
                 {
                     pkgBoxCell.Value = productionRequestDetailInProductions[i].UnitId;
                 }
                 catch { }
             }
         }
     }
     if (isUpdating && productionRequest != null && productionRequestDetailInMaterials.Count < dgvMaterial.RowCount)
     {
         for (int i = 0; i < productionRequestDetailInMaterials.Count; i++)
         {
             if (dgvMaterial.Rows[i].Cells[ProductAttrCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvMaterial.Rows[i].Cells[ProductAttrCell];
                 try
                 {
                     pkgBoxCell.Value = productAttrService.GetProductAttribute(productionRequestDetailInMaterials[i].ProductId,
                         productionRequestDetailInMaterials[i].AttributeId).Id;
                 }
                 catch { }
             }
             // Unit
             if (dgvMaterial.Rows[i].Cells[UnitCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvMaterial.Rows[i].Cells[UnitCell];
                 try
                 {
                     pkgBoxCell.Value = productionRequestDetailInMaterials[i].UnitId;
                 }
                 catch { }
             }
         }
     }
 }
 private void dgvProduct_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     DataGridView dgv = (DataGridView)sender;
     if (productionRequestDetailInProductions == null)
     {
         productionRequestDetailInProductions = new BindingList<ProductionRequestDetail>();
     }
     if (productionRequestDetailInProductions.Count < dgvProduct.RowCount - 1)
     {
         ProductionRequestDetail productionRequestDetail = new ProductionRequestDetail();
         productionRequestDetailInProductions.Add(productionRequestDetail);
     }
     if (dgv.CurrentCell.Value != null)
     {
         switch (e.ColumnIndex)
         {
             case ProductAttrCell:
                 {
                     ProductAttributeService productAttrService = new ProductAttributeService();
                     ProductAttribute pa = productAttrService.GetProductAttribute((int)dgv.CurrentCell.Value);
                     if (pa != null)
                     {
                         productionRequestDetailInProductions[e.RowIndex].ProductId = pa.ProductId;
                         productionRequestDetailInProductions[e.RowIndex].AttributeId = pa.AttributeId;
                     }
                 } break;
             case NumberUnitCell:
                 productionRequestDetailInProductions[e.RowIndex].NumberUnit = (int)dgv.CurrentCell.Value;
                 break;
             case UnitCell:
                 productionRequestDetailInProductions[e.RowIndex].UnitId = (int)dgv.CurrentCell.Value;
                 break;
             case NoteCell:
                 productionRequestDetailInProductions[e.RowIndex].Note = (string)dgv.CurrentCell.Value;
                 break;
         }
     }
 }
 private void dgvStockEntranceDetails_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     DataGridView dgv = (DataGridView)sender;
     if (entranceStockDetails == null)
     {
         entranceStockDetails = new BindingList<EntranceStockDetail>();
     }
     if (entranceStockDetails.Count < dgvStockEntranceDetails.RowCount - 1)
     {
         EntranceStockDetail entranceStockDetail = new EntranceStockDetail();
         entranceStockDetails.Add(entranceStockDetail);
     }
     if (dgv.CurrentCell.Value != null)
     {
         switch (e.ColumnIndex)
         {
             case ProductAttrCell:
                 {
                     ProductAttributeService productAttrService = new ProductAttributeService();
                     ProductAttribute pa = productAttrService.GetProductAttribute((int)dgv.CurrentCell.Value);
                     if (pa != null)
                     {
                         entranceStockDetails[e.RowIndex].ProductId = pa.ProductId;
                         entranceStockDetails[e.RowIndex].AttributeId = pa.AttributeId;
                     }
                 } break;
             case NumberUnitCell:
                 {
                     int value = (int)dgv.CurrentCell.Value;
                     if (value < 0)
                         entranceStockDetails[e.RowIndex].NumberUnit = 0;
                     else
                         entranceStockDetails[e.RowIndex].NumberUnit = value;
                 } break;
             case UnitCell:
                 entranceStockDetails[e.RowIndex].UnitId = (int)dgv.CurrentCell.Value;
                 break;
             case NoteCell:
                 entranceStockDetails[e.RowIndex].Note = (string)dgv.CurrentCell.Value;
                 break;
         }
     }
 }
 public void updateProductionRequestDetailCells()
 {
     if (isUpdating && entranceStock != null && entranceStockDetails.Count < dgvStockEntranceDetails.RowCount)
     {
         ProductAttributeService productAttrService = new ProductAttributeService();
         for (int i = 0; i < entranceStockDetails.Count; i++)
         {
             // Product + Attribute
             if (dgvStockEntranceDetails.Rows[i].Cells[ProductAttrCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvStockEntranceDetails.Rows[i].Cells[ProductAttrCell];
                 try
                 {
                     pkgBoxCell.Value = productAttrService.GetProductAttribute(entranceStockDetails[i].ProductId,
                         entranceStockDetails[i].AttributeId).Id;
                 }
                 catch { }
             }
             // Unit
             if (dgvStockEntranceDetails.Rows[i].Cells[UnitCell] is DataGridViewComboBoxCell)
             {
                 DataGridViewComboBoxCell pkgBoxCell = (DataGridViewComboBoxCell)dgvStockEntranceDetails.Rows[i].Cells[UnitCell];
                 try
                 {
                     pkgBoxCell.Value = entranceStockDetails[i].UnitId;
                 }
                 catch { }
             }
         }
     }
 }