Exemple #1
0
        public int AddNewPurchaseOrder(object pvoPOMaster, DataSet pdstPODetail)
        {
            PO_PurchaseOrderMasterDS dsMaster = new PO_PurchaseOrderMasterDS();
            int intPOMasterID = dsMaster.AddAndReturnID(pvoPOMaster);

            foreach (DataRow objRow in pdstPODetail.Tables[0].Rows)
            {
                if (objRow.RowState == DataRowState.Deleted)
                {
                    continue;
                }
                objRow[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intPOMasterID;
            }
            PO_PurchaseOrderDetailDS dsDetail = new PO_PurchaseOrderDetailDS();

            dsDetail.UpdateDataSet(pdstPODetail);
            return(intPOMasterID);
        }
Exemple #2
0
        /// <summary>
        /// Add new for case : Convert CPO to new PO
        /// </summary>
        /// <param name="pdstCPODetail"></param>
        /// <param name="pobjMasterVO"></param>
        /// <param name="pdstDetail"></param>
        ///<author>TuanDM</author>

        public int AddPOAndDelSchedule(System.Data.DataSet pdstCPODetail, object pobjMasterVO, System.Data.DataSet pdstDetail)
        {
            //Add Master and Get returning ID
            PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS();
            int intMasterID = dsPOMaster.AddAndReturnID(pobjMasterVO);

            //Add detail
            ArrayList arlDueDate = new ArrayList();

            foreach (DataRow drowDetail in pdstDetail.Tables[0].Rows)
            {
                drowDetail[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intMasterID;
                arlDueDate.Add(drowDetail[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD].ToString());
            }
            PO_PurchaseOrderDetailDS dsPODetail = new PO_PurchaseOrderDetailDS();

            dsPODetail.UpdateDataSet(pdstDetail);

            //Get PODetail DataSet which includes PURCHASEORDERDETAILID_FLD
            pdstDetail = dsPODetail.List(intMasterID);

            //Create DeliverySchedule -- and add DeliverySchedule
            PO_DeliveryScheduleVO voSchedule;

            for (int i = 0; i < pdstDetail.Tables[0].Rows.Count; i++)
            {
                voSchedule = new PO_DeliveryScheduleVO();
                voSchedule.DeliveryLine          = 1;
                voSchedule.PurchaseOrderDetailID = int.Parse(pdstDetail.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.PURCHASEORDERDETAILID_FLD].ToString());
                voSchedule.ScheduleDate          = DateTime.Parse(arlDueDate[i].ToString());
                voSchedule.DeliveryQuantity      = decimal.Parse(pdstDetail.Tables[0].Rows[i][PO_PurchaseOrderDetailTable.ORDERQUANTITY_FLD].ToString());
                new PO_DeliveryScheduleDS().Add(voSchedule);
            }

            //Update CPODetail
            new MTR_CPODS().SetPOMasterID(null, intMasterID);

            //return ID
            return(intMasterID);
        }
Exemple #3
0
        /// <summary>
        /// Add new for case : Convert CPO to new PO
        /// </summary>
        /// <param name="pobjMasterVO"></param>
        /// <param name="pdstDetail"></param>
        /// <param name="pdstDelivery"></param>
        ///<author>TuanDM</author>

        public int AddPOAndDelScheduleImmediate(object pobjMasterVO, System.Data.DataSet pdstDetail, DataSet pdstDelivery, ArrayList parlCPOIDs)
        {
            //Add Master and Get returning ID
            PO_PurchaseOrderMasterDS dsPOMaster = new PO_PurchaseOrderMasterDS();
            int intMasterID = dsPOMaster.AddAndReturnID(pobjMasterVO);

            //Add detail
            foreach (DataRow drowDetail in pdstDetail.Tables[0].Rows)
            {
                drowDetail[PO_PurchaseOrderDetailTable.PURCHASEORDERMASTERID_FLD] = intMasterID;
            }
            PO_PurchaseOrderDetailDS dsPODetail = new PO_PurchaseOrderDetailDS();

            dsPODetail.UpdateDataSet(pdstDetail);

            //Get PODetail DataSet which includes PURCHASEORDERDETAILID_FLD
            pdstDetail = dsPODetail.ListToGetID(intMasterID);

            //Create DeliverySchedule -- and add DeliverySchedule
            int intPOLineID = 0;
            int i           = 0;
            PO_DeliveryScheduleDS dsDelivery = new PO_DeliveryScheduleDS();

            while (i++ < pdstDetail.Tables[0].Rows.Count)
            {
                DataSet dstNewDelPO = pdstDelivery.Clone();

                DataRow[] drowSameDelivery = pdstDelivery.Tables[0].Select(ITM_ProductTable.PRODUCTID_FLD + "='" + pdstDetail.Tables[0].Rows[i - 1][ITM_ProductTable.PRODUCTID_FLD].ToString() + "'");

                intPOLineID = (int)pdstDetail.Tables[0].Rows[i - 1][PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD];
                foreach (DataRow t in drowSameDelivery)
                {
                    int k = GetIndexForDeliveryLine(dstNewDelPO, (DateTime)t[PO_DeliveryScheduleTable.SCHEDULEDATE_FLD]);
                    if (k > -1)
                    {
                        dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] = (decimal)dstNewDelPO.Tables[0].Rows[k][PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD] + (decimal)t[PO_DeliveryScheduleTable.DELIVERYQUANTITY_FLD];
                        t[PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD] = intPOLineID;
                    }
                    else
                    {
                        t[PO_DeliveryScheduleTable.PURCHASEORDERDETAILID_FLD] = intPOLineID;
                        t[PO_DeliveryScheduleTable.DELIVERYLINE_FLD]          = dstNewDelPO.Tables[0].Rows.Count + 1;
                        dstNewDelPO.Tables[0].ImportRow(t);
                    }
                }
                dsDelivery.UpdateDataSet(dstNewDelPO);
            }
            //Update CPODetail
            MTR_CPODS dsCPO = new MTR_CPODS();

            if (parlCPOIDs.Count > 0)
            {
                if (Convert.ToInt32(parlCPOIDs[0]) > 0)
                {
                    dsCPO.SetPOMasterID(parlCPOIDs, intMasterID);
                }
                else
                {
                    dsCPO.SetPOMasterIDForDCPDetail(parlCPOIDs, intMasterID);
                }
            }

            return(intMasterID);
        }