Exemplo n.º 1
0
 private void btnDelete_ItemClick(object sender, ItemClickEventArgs e)
 {
     try
     {
         if (LinesView.RowCount > 0 && LinesView.FocusedRowHandle > 0)
         {
             BOMIngredientsProducts BOMIngr = ingred.Get(
                 long.Parse(LinesView.GetRowCellValue(LinesView.FocusedRowHandle,
                                                      LinesView.Columns[0]).ToString().Substring(3)));
             ingred.Delete(BOMIngr);
             LinesView.DeleteRow(LinesView.FocusedRowHandle);
             GetTotalCost();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        private void LinesView_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e)
        {
            string Code = LinesView.GetRowCellValue(e.RowHandle, LinesView.Columns[0]).ToString();

            if (e.RowHandle >= 0)
            {
                if (e.RowHandle == 0)
                {
                    BOMOutputProduct outProduct = output.Get(int.Parse(Code.Substring(3)));
                    switch (e.Column.AbsoluteIndex)
                    {
                    case 1:
                        outProduct.ProductCode = int.Parse(e.Value.ToString());
                        LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[2], new ProductManager().Get(int.Parse(e.Value.ToString())).Product_Name);

                        break;

                    case 3:
                        outProduct.WHCode   = int.Parse(e.Value.ToString());
                        e.Column.ColumnEdit = new RepositoryItemTextEdit();
                        break;

                    case 4:
                        outProduct.Cost = decimal.Parse(e.Value.ToString());
                        //GetTotalCost();
                        GetTotalLineCost(e.RowHandle, 5, decimal.Parse(e.Value.ToString()));
                        break;

                    case 5:
                        outProduct.Quantity = decimal.Parse(e.Value.ToString());
                        GetTotalCost();
                        GetTotalLineCost(e.RowHandle, 4, decimal.Parse(e.Value.ToString()));
                        break;

                    default:
                        break;
                    }
                    output.Update(outProduct);
                }
                else
                {
                    BOMIngredientsProducts ingProduct = ingred.Get(int.Parse(Code.Substring(3)));
                    switch (e.Column.AbsoluteIndex)
                    {
                    case 1:
                        int PCode = int.Parse(e.Value.ToString());
                        ingProduct.ProductCode = PCode;
                        DALLayer.Product productMgr = new ProductManager().Get(PCode);
                        decimal?         Cost       = productMgr.ProductOnHand.Count() > 0?productMgr.ProductOnHand.FirstOrDefault().AvgCost:null;
                        LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], Cost == null?0:Cost);
                        LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[2], new ProductManager().Get(PCode).Product_Name);
                        break;

                    case 3:
                        ingProduct.WHCode   = int.Parse(e.Value.ToString());
                        e.Column.ColumnEdit = new RepositoryItemTextEdit();
                        break;

                    case 4:
                        ingProduct.Cost = decimal.Parse(e.Value.ToString());
                        GetTotalLineCost(e.RowHandle, 5, decimal.Parse(e.Value.ToString()));
                        break;

                    case 5:
                        ingProduct.Quantity = decimal.Parse(e.Value.ToString());
                        GetTotalLineCost(e.RowHandle, 4, decimal.Parse(e.Value.ToString()));
                        break;

                    case 6:
                        GetTotalCost();
                        break;

                    default:
                        break;
                    }
                    ingred.Update(ingProduct);
                }
            }
        }