예제 #1
0
        private void GetTotalCost()
        {
            decimal total = 0;

            for (int i = 1; i < LinesView.RowCount; i++)
            {
                total += decimal.Parse(LinesView.GetRowCellValue(i, LinesView.Columns[6]).ToString());
            }
            LinesView.SetRowCellValue(0, LinesView.Columns[4], total / decimal.Parse(LinesView.GetRowCellValue(0, LinesView.Columns[5]).ToString()));
        }
예제 #2
0
        private void LinesView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
        {
            try
            {
                if (LinesView.RowCount <= 1)
                {
                    int OUtCode = int.Parse(output.GetCode().ToString());
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[0], "OUT" + OUtCode);
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], "0");
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[5], "1");

                    output.Add(new BOMOutputProduct()
                    {
                        BOMCode    = BOMCode,
                        OutputCode = OUtCode,
                        LookUpCode = "OUT" + OUtCode,
                        Cost       = 0,
                        Quantity   = 1
                    });
                }
                else
                {
                    int INGCode = int.Parse(ingred.GetCode().ToString());
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[0], "ING" + INGCode);
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[4], "0");
                    LinesView.SetRowCellValue(e.RowHandle, LinesView.Columns[5], "1");

                    ingred.Add(new BOMIngredientsProducts()
                    {
                        BOMCode    = BOMCode,
                        IngCode    = INGCode,
                        LookUpCode = "ING" + INGCode,
                        OutputCode = long.Parse(LinesView.GetRowCellValue(0, LinesView.Columns[0]).ToString().Substring(3)),
                        Cost       = 0,
                        Quantity   = 1
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #3
0
 private void GetTotalLineCost(int rowHandle, int ColumnIndex, decimal Value)
 {
     LinesView.SetRowCellValue(rowHandle, LinesView.Columns[6]
                               , Value * decimal.Parse((LinesView.GetRowCellValue(rowHandle, LinesView.Columns[ColumnIndex])).ToString()));
 }
예제 #4
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);
                }
            }
        }