コード例 #1
0
 private double GetLastLotNo()
 {
     if (!string.IsNullOrEmpty(baseAddEditMasterDetail.FormKeyCode) && ddlWarehouseDetails.SelectedIndex != 0)
     {
         PhyLot entity = new PhyLot()
         {
             warehouse_id = ddlWarehouseDetails.SelectedValue.ToLong(), material_id = baseAddEditMasterDetail.FormKeyCode.ToLong()
         };
         return(ServiceProvider.PhyLotService.GetCurrentLotNo(entity) + 1);
     }
     return(1);
 }
コード例 #2
0
 private double GetLastLotNo()
 {
     if (ddlMaterial.SelectedIndex != 0 && ddlWarehouseDetails.SelectedIndex != 0)
     {
         PhyLot entity = new PhyLot()
         {
             warehouse_id = ddlWarehouseDetails.SelectedValue.ToLong(), material_id = ddlMaterial.SelectedValue.ToLong()
         };
         return(ServiceProvider.PhyLotService.GetCurrentLotNo(entity) + 1);
     }
     return(1);
 }
コード例 #3
0
        private void btnLoadPortFolio_Click(object sender, EventArgs e)
        {
            object result = base.OpenPopup <InPortfolio>();

            if (result != null)
            {
                DataSet dsPortfolioDetail = (DataSet)result;

                if (dsPortfolioDetail.Tables.Count > 0)
                {
                    foreach (DataRow dr in dsPortfolioDetail.Tables[0].Rows)
                    {
                        DataRow newRow = this.dsTranDetail.Tables[0].NewRow();
                        if (!string.IsNullOrEmpty(base.FormKeyCode))
                        {
                            newRow["tran_head_id"] = base.FormKeyCode.ToLong();
                        }
                        newRow["material_code"]     = dr["material_code"];
                        newRow["material_id"]       = dr["material_id"];
                        newRow["warehouse_id_dest"] = dr["warehouse_id"];
                        newRow["Quantity"]          = 0;
                        newRow["Remark"]            = "";
                        newRow["Material"]          = dr["material_name"];
                        newRow["warehouse_id_dest"] = dr["warehouse_id"];
                        newRow["Warehouse"]         = dr["warehouse_name"];

                        PhyLot entityPhyLot = new PhyLot()
                        {
                            warehouse_id = newRow["warehouse_id_dest"].ToLong(), material_id = newRow["material_id"].ToLong()
                        };
                        newRow["Lot No."] = (ServiceProvider.PhyLotService.GetCurrentLotNo(entityPhyLot) + 1);
                        newRow["UOM"]     = dr["uom_name"];
                        this.dsTranDetail.Tables[0].Rows.Add(newRow);
                    }

                    baseGridDetail.LoadData();
                }
            }
        }
コード例 #4
0
        private void SaveLots(TranDetail entityDetail, TranHead entityTranHead)
        {
            //get in_material
            Material entityMaterial = new Material()
            {
                material_id = entityDetail.material_id
            };

            entityMaterial = ServiceProvider.MaterialService.FindByKeys(entityMaterial, false);

            //update into in_phy_lot
            PhyLot entityPhyLot = ServiceProvider.PhyLotService.GetPhyLot(entityDetail.material_id, entityDetail.warehouse_id_dest, entityDetail.lot_no.Value);

            entityPhyLot.bal_qty = (entityPhyLot.bal_qty - entityDetail.quantity.Value);
            ServiceProvider.PhyLotService.Update(entityPhyLot);

            //update into in_log_lot
            LogLot entityLogLot = ServiceProvider.LogLotService.GetLogLot(entityDetail.material_id, entityDetail.warehouse_id_dest);

            entityLogLot.bal_qty = (entityLogLot.bal_qty - entityDetail.quantity.Value);
            ServiceProvider.LogLotService.Update(entityLogLot);
        }
コード例 #5
0
        private void SaveLots(StockDetail entityDetail, StockHead entityStockHead)
        {
            //update into in_phy_lot
            PhyLot entityPhyLot = ServiceProvider.PhyLotService.GetPhyLot(entityDetail.material_id, entityStockHead.warehouse_id, entityDetail.lot_no, false);

            entityPhyLot.bal_qty = entityDetail.bal_qty;
            entityPhyLot.bf_qty  = entityDetail.bf_qty;
            entityPhyLot.bf_date = entityDetail.bf_date;
            ServiceProvider.PhyLotService.Update(entityPhyLot);

            //update into in_log_lot
            LogLot entityLogLot = ServiceProvider.LogLotService.GetLogLot(entityDetail.material_id, entityStockHead.warehouse_id);

            entityLogLot.bal_qty = entityDetail.bal_qty;
            entityLogLot.bf_qty  = entityDetail.bf_qty;
            entityLogLot.bf_date = entityDetail.bf_date;
            ServiceProvider.LogLotService.Update(entityLogLot);

            //Insert
            BFLogical bfLogical = new BFLogical();

            bfLogical.period_id    = entityStockHead.period_id;
            bfLogical.warehouse_id = entityStockHead.warehouse_id;
            bfLogical.material_id  = entityDetail.material_id;
            bfLogical.bf_qty       = entityDetail.bf_qty;
            bfLogical.bal_qty      = entityDetail.bal_qty;
            ServiceProvider.BFLogicalService.Insert(bfLogical);

            BFPhysical bfPhysical = new BFPhysical();

            bfPhysical.period_id    = entityStockHead.period_id;
            bfPhysical.warehouse_id = entityStockHead.warehouse_id;
            bfPhysical.material_id  = entityDetail.material_id;
            bfPhysical.bf_qty       = entityDetail.bf_qty;
            bfPhysical.bal_qty      = entityDetail.bal_qty;
            bfPhysical.lot_no       = entityDetail.lot_no;
            ServiceProvider.BFPhysicalService.Insert(bfPhysical);
        }
コード例 #6
0
        private void ValidationDetail(TranDetail entity)
        {
            ValidationResults results = new ValidationResults();

            if (baseGridDetail.FormMode == ObjectState.Add)
            {
                if (entity.material_id == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Material"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
                else
                {
                    if (entity.warehouse_id_dest != 0)
                    {
                        DataRow[] drs = this.GetDataRowDetail(entity.material_id, entity.warehouse_id_dest);
                        if (drs.Count() >= 1)
                        {
                            ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsDuplicate, "Material"), this, string.Empty, string.Empty, null);
                            results.AddResult(result);
                        }
                    }
                }

                if (entity.warehouse_id_dest == 0)
                {
                    ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Warehouse"), this, string.Empty, string.Empty, null);
                    results.AddResult(result);
                }
            }

            if (string.IsNullOrEmpty(txtLotNo.Text))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Lot No."), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (Converts.ParseDoubleNullable(txtLotNo.Text) == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Lot No."), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (entity.lot_no == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Lot No.", "0"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else
            {
                if (entity.material_id != 0 && entity.warehouse_id_dest != 0)
                {
                    PhyLot entityPhyLot = ServiceProvider.PhyLotService.GetPhyLot(entity.material_id, entity.warehouse_id_dest, entity.lot_no.Value, false);
                    if (entityPhyLot == null || entityPhyLot.phy_lot_id == 0)
                    {
                        ValidationResult result = new ValidationResult(string.Format(ErrorMessage.NotExistsField, "Lot No.", entity.lot_no.Value), this, string.Empty, string.Empty, null);
                        results.AddResult(result);
                    }
                    else
                    {
                        if ((entityPhyLot.bal_qty - entity.quantity) < 0)
                        {
                            ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", "material in stock"), this, string.Empty, string.Empty, null);
                            results.AddResult(result);
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IsRequired, "Quantity"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (Converts.ParseDoubleNullable(txtQuantity.Text) == null)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.IncorrectFormatOne, "Quantity"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }
            else if (entity.quantity == 0)
            {
                ValidationResult result = new ValidationResult(string.Format(ErrorMessage.CompareValueMore, "Quantity", "0"), this, string.Empty, string.Empty, null);
                results.AddResult(result);
            }

            if (results.Count > 0)
            {
                throw new ValidationException(results);
            }
        }