Ejemplo n.º 1
0
        /// <summary>
        /// Delete record by condition
        /// </summary>

        public void Delete(object pObjectVO)
        {
            CST_ActualCostHistoryDS       dsActualCost = new CST_ActualCostHistoryDS();
            CST_ActCostAllocationMasterVO voPeriod     = (CST_ActCostAllocationMasterVO)pObjectVO;

            dsActualCost.Delete(voPeriod.ActCostAllocationMasterID);
        }
Ejemplo n.º 2
0
        public void SaveData(DataSet pdstData, object pobjPeriod)
        {
            CST_ActCostAllocationMasterVO voPeriod = (CST_ActCostAllocationMasterVO)pobjPeriod;
            // delete old cost first
            CST_ActualCostHistoryDS dsActualCost = new CST_ActualCostHistoryDS();

            try
            {
                dsActualCost.Delete(voPeriod.ActCostAllocationMasterID);
            }
            catch
            {
                throw new PCSBOException(ErrorCode.MESSAGE_CAN_NOT_DELETE, "SaveData", null);
            }
            // update actual cost
            dsActualCost.UpdateDataSet(pdstData);
            // update period rollupdate
            CST_ActCostAllocationMasterDS dsPeriod = new CST_ActCostAllocationMasterDS();

            dsPeriod.Update(pobjPeriod);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Allocate cost for selected period
        /// </summary>
        /// <param name="pobjObject"></param>
        /// <param name="pdtbDetail"></param>

        public void Allocate(object pobjObject, DataTable pdtbDetail)
        {
            CST_AllocationResultDS        dsAllocationResult = new CST_AllocationResultDS();
            CST_ActCostAllocationMasterVO voAllocationMaster = (CST_ActCostAllocationMasterVO)pobjObject;

            //Delete old data first
            dsAllocationResult.DeleteByAllocationMasterID(voAllocationMaster.ActCostAllocationMasterID);

            //copy table
            DataTable dtbSource = pdtbDetail.Copy();

            //Table contain max lead time
            DataTable dtbLeadTime;

            dtbLeadTime = dsAllocationResult.GetLeadTimeData(voAllocationMaster.FromDate, voAllocationMaster.ToDate, voAllocationMaster.CCNID);

            //Table contain completed quantity by production line
            DataTable dtbCompletedByProductionLine;

            dtbCompletedByProductionLine = dsAllocationResult.GetCompletedQuantityByProductionLine(voAllocationMaster.FromDate, voAllocationMaster.ToDate, voAllocationMaster.CCNID);

            //Table contain completed quantity by product
            DataTable dtbCompletedByProductGroup;

            dtbCompletedByProductGroup = dsAllocationResult.GetCompletedQuantityByProductGroup(voAllocationMaster.FromDate, voAllocationMaster.ToDate, voAllocationMaster.CCNID);

            #region Temp table to keep completed quantity, leadtime of product
            DataTable dtbTemp = new DataTable();

            dtbTemp.Columns.Add(CST_AllocationResultTable.PRODUCTID_FLD, typeof(System.Int32));
            dtbTemp.Columns.Add(QUANTITY_LEADTIME_FLD, typeof(System.Decimal));
            dtbTemp.Columns.Add(COMPLETED_QUANTITY_FLD, typeof(System.Decimal));

            #endregion

            //Build template of AllocationResult table
            DataTable dtbAllocationResult = BuildAllocationResultTemplate();

            //Loop each row and insert data
            foreach (DataRow drowSource in dtbSource.Rows)
            {
                //irnoge deleted row
                if (drowSource.RowState == DataRowState.Deleted)
                {
                    continue;
                }

                //Processing if product is not null
                if (!drowSource[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].Equals(DBNull.Value) &&
                    drowSource[CST_ActCostAllocationDetailTable.PRODUCTID_FLD].ToString().Trim() != string.Empty)
                {
                    //Allocate cost by product
                    AllocateByProduct(drowSource, dtbCompletedByProductGroup, dtbAllocationResult);

                    //move to next row
                    continue;
                }

                //Processing if product group is not null
                if (!drowSource[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].Equals(DBNull.Value) &&
                    drowSource[CST_ActCostAllocationDetailTable.PRODUCTGROUPID_FLD].ToString().Trim() != string.Empty)
                {
                    //Allocate cost by product group
                    AllocateByGroup(drowSource, dtbCompletedByProductGroup, dtbLeadTime, dtbTemp, dtbAllocationResult);

                    //move to next row
                    continue;
                }

                //Processing if production line is not null
                if (!drowSource[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].Equals(DBNull.Value) &&
                    drowSource[CST_ActCostAllocationDetailTable.PRODUCTIONLINEID_FLD].ToString().Trim() != string.Empty)
                {
                    //Allocate cost by production line
                    AllocateByProductionLine(drowSource, dtbCompletedByProductionLine, dtbLeadTime, dtbTemp, dtbAllocationResult);

                    //move to next row
                    continue;
                }

                //Processing if deparment is not null
                if (!drowSource[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].Equals(DBNull.Value) &&
                    drowSource[CST_ActCostAllocationDetailTable.DEPARTMENTID_FLD].ToString().Trim() != string.Empty)
                {
                    //Allocate cost by department
                    AllocateByDepartment(drowSource, dtbCompletedByProductionLine, dtbLeadTime, dtbTemp, dtbAllocationResult);

                    //move to next row
                    continue;
                }

                //Finally, allocate cost by CCN
                AllocateByCCN(voAllocationMaster.CCNID, drowSource, dtbCompletedByProductionLine, dtbLeadTime, dtbTemp, dtbAllocationResult);
            }            //foreach

            //Build dataset for allocation result
            DataSet dtsAllocation = dtbAllocationResult.DataSet;
            if (dtsAllocation == null)
            {
                dtsAllocation = new DataSet();
                dtsAllocation.Tables.Add(dtbAllocationResult);
            }

            //update dataset
            dsAllocationResult.UpdateDataSet(dtsAllocation);
            dsAllocationResult.InsertNewAllocation(voAllocationMaster.ActCostAllocationMasterID, voAllocationMaster.FromDate, voAllocationMaster.ToDate);
        }