Example #1
0
 public DTO.ProductionCostingPrintData DB2DTO_ProductionCosting(ProductionCostingRpt_ProductionCosting_View dbItem)
 {
     return(AutoMapper.Mapper.Map <ProductionCostingRpt_ProductionCosting_View, DTO.ProductionCostingPrintData>(dbItem));
 }
Example #2
0
        private void ParseProductionCostingToList(ProductionCostingRpt_ProductionCosting_View data, ref ReportDataObject dsResult)
        {
            if (data != null && data.ProductionCostingRpt_ProductionCosting_View1 != null)
            {
                if (data.ProductionItemTypeID == 2 && (data.PlanQnt == null || data.PlanQnt == 0) && (data.UsingQnt == null || data.UsingQnt == 0))
                {
                }
                else
                {
                    //push to list result
                    ReportDataObject.ProductionCostingReportDataRow dr;
                    dr = dsResult.ProductionCostingReportData.NewProductionCostingReportDataRow();
                    if (data.PieceIndex.HasValue)
                    {
                        dr.PieceIndex = data.PieceIndex.Value;
                    }
                    if (data.ProductionItemTypeID.HasValue)
                    {
                        dr.ProductionItemTypeID = data.ProductionItemTypeID.Value;
                    }
                    if (!string.IsNullOrEmpty(data.ProductionItemTypeNM))
                    {
                        dr.ProductionItemTypeNM = data.ProductionItemTypeNM;
                    }
                    if (!string.IsNullOrEmpty(data.WorkCenterNM))
                    {
                        dr.WorkCenterNM = data.WorkCenterNM;
                    }
                    if (!string.IsNullOrEmpty(data.ProductionItemUD))
                    {
                        dr.ProductionItemUD = data.ProductionItemUD;
                    }
                    if (!string.IsNullOrEmpty(data.ProductionItemNM))
                    {
                        dr.ProductionItemNM = data.ProductionItemNM;
                    }
                    if (!string.IsNullOrEmpty(data.Unit))
                    {
                        dr.Unit = data.Unit;
                    }
                    if (data.Price.HasValue)
                    {
                        dr.Price = data.Price.Value;
                    }
                    if (data.WorkOrderQnt.HasValue)
                    {
                        dr.WorkOrderQnt = data.WorkOrderQnt.Value;
                    }
                    if (data.PlanQnt.HasValue)
                    {
                        dr.PlanQnt = data.PlanQnt.Value;
                    }
                    if (data.UsingQnt.HasValue)
                    {
                        dr.UsingQnt = data.UsingQnt.Value;
                    }
                    if (data.VarianceQnt.HasValue)
                    {
                        dr.VarianceQnt = data.VarianceQnt.Value;
                    }
                    if (data.PlanCosting.HasValue)
                    {
                        dr.PlanCosting = data.PlanCosting.Value;
                    }
                    if (data.UsingCosting.HasValue)
                    {
                        dr.UsingCosting = data.UsingCosting.Value;
                    }
                    if (data.VarianceValue.HasValue)
                    {
                        dr.VarianceValue = data.VarianceValue.Value;
                    }
                    if (data.VarianceCosting.HasValue)
                    {
                        dr.VarianceCosting = data.VarianceCosting.Value;
                    }
                    dr.BOMID = data.BOMID;
                    if (data.WorkCenterID.HasValue)
                    {
                        dr.WorkCenterID = data.WorkCenterID.Value;
                    }
                    if (data.CountChildBOM.HasValue)
                    {
                        dr.CountChildBOM = data.CountChildBOM.Value;
                    }
                    if (data.ProductionItemID.HasValue)
                    {
                        dr.ProductionItemID = (int)data.ProductionItemID;
                    }
                    if (data.WorkOrderID.HasValue)
                    {
                        dr.WorkOrderID = (int)data.WorkOrderID;
                    }
                    if (data.ProductionItemTypeID == 1)
                    {
                        dr.UsingQnt = 0;
                        if (data.TotalReceivedQnt == null)
                        {
                            dr.UsingQnt = 0;
                        }
                        else
                        {
                            dr.UsingQnt = data.TotalReceivedQnt.Value;
                        }
                        if (data.Price.HasValue)
                        {
                            if (dr.PlanCosting > 0 && dr.PlanCosting != null)
                            {
                                dr.VarianceQnt     = (decimal)(dr.UsingQnt - dr.PlanQnt);
                                dr.UsingCosting    = dr.Price * dr.UsingQnt;
                                dr.VarianceValue   = dr.UsingCosting - dr.PlanCosting;
                                dr.VarianceCosting = 0;
                            }
                            else
                            {
                                dr.VarianceQnt   = (decimal)(dr.UsingQnt - dr.PlanQnt);
                                dr.UsingCosting  = dr.Price * dr.UsingQnt;
                                dr.VarianceValue = dr.UsingCosting - dr.PlanCosting;
                                if (dr.PlanCosting == 0 || dr.PlanCosting == null)
                                {
                                    dr.VarianceCosting = 0;
                                }
                                else
                                {
                                    dr.VarianceCosting = dr.VarianceValue / dr.PlanCosting * 100;
                                }
                            }
                        }
                    }
                    dsResult.ProductionCostingReportData.AddProductionCostingReportDataRow(dr);

                    //it just only assign piece index for child of root node
                    if (data.ParentBOMID == null)
                    {
                        int i = 1;
                        foreach (var item in data.ProductionCostingRpt_ProductionCosting_View1.ToList())
                        {
                            item.PieceIndex = i;
                            i++;
                        }
                    }
                    // edit ActualQnt and VarianceQnt follow totalRecevingNote


                    foreach (var item in data.ProductionCostingRpt_ProductionCosting_View1.OrderBy(o => o.ProductionCostingRpt_ProductionCosting_View1.Count))
                    {
                        item.CountChildBOM = item.ProductionCostingRpt_ProductionCosting_View1.Count;
                        if (!item.PieceIndex.HasValue)
                        {
                            item.PieceIndex = data.PieceIndex;
                        }
                        ParseProductionCostingToList(item, ref dsResult);
                    }
                }
            }
        }