Exemplo n.º 1
0
        private void grid_CellValueChanged(object sender, GridCellValueChangedEventArgs e)
        {
            GridCell cell = e.GridCell;
            var      row  = (GridRow)e.GridPanel.Rows[cell.RowIndex];

            //根据选择的零件号,获取库存批次,单价
            if (cell.GridColumn == gcPartCode)
            {
                var stockDetail = StockDetailController.GetListByPartCode(_db, cell.Value.ToString()).OrderBy(p => p.Batch).FirstOrDefault();
                row.Cells[gcBatch].Value       = stockDetail.Batch;
                row.Cells[gcFromLocCode].Value = stockDetail.LocCode;
            }
        }
Exemplo n.º 2
0
        private void grid_CellValueChanged(object sender, GridCellValueChangedEventArgs e)
        {
            GridCell cell = e.GridCell;
            var      row  = (GridRow)e.GridPanel.Rows[cell.RowIndex];

            //相同批次的物料,看库存中是否有单价
            if (cell.GridColumn == gcPartCode || cell.GridColumn == gcBatch)
            {
                if (row[gcPartCode].Value != null)
                {
                    var partcode = row[gcPartCode].Value.ToString();
                    if (row[gcBatch].Value != null)
                    {
                        var batch       = row[gcBatch].Value.ToString();
                        var stockDetail =
                            StockDetailController.GetListByPartCode(_db, partcode)
                            .Where(p => p.Batch == batch)
                            .OrderBy(p => p.Batch)
                            .FirstOrDefault();
                        if (stockDetail != null)
                        {
                            row.Cells[gcUnitPrice].Value = stockDetail.UnitPrice;
                        }
                    }
                }
                if (row[gcProduceDate].Value == null)
                {
                    row[gcProduceDate].Value = DateTime.Now;
                }
            }
            //根据出库数量,自动计算金额
            if (cell.GridColumn == gcUnitPrice || cell.GridColumn == gcQty)
            {
                if (Convert.ToString(row.Cells[gcUnitPrice].Value) != "" && Convert.ToString(row.Cells[gcQty].Value) != "")
                {
                    row.Cells[gcAmount].Value = (decimal)row.Cells[gcUnitPrice].Value * (decimal)row.Cells[gcQty].Value;
                }
            }
        }