public static void AcknowledgePurchaseOrder(PurchaseOrderHeader header, Collection <PurchaseOrderItemSchedule> schedules)
        {
            try
            {
                EpTransaction tran = DataManager.BeginTransaction();
                try
                {
                    PurchaseOrderHeaderDAO.Update(tran, header);

                    foreach (PurchaseOrderItemSchedule schedule in schedules)
                    {
                        PurchaseOrderItemScheduleDAO.Update(tran, schedule);
                    }
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw (ex);
                }
                finally
                {
                    tran.Dispose();
                }
            }
            catch (Exception ex)
            {
                Utility.ExceptionLog(ex);
                throw (ex);
            }
        }
Пример #2
0
        public void UpdateContract()
        {
            int wstep;

            try
            {
                EpTransaction tran = DataManager.BeginTransaction();
                try
                {
                    wstep = 100 / contractHeader.Count;
                    foreach (ZCONTRACT_HDR x in contractHeader)
                    {
                        ContractHeader hrd = new ContractHeader();
                        hrd.ContractNumber     = x.Ebeln;
                        hrd.ContractDate       = Convert.ToInt64(x.Bedat);
                        hrd.ContractCategory   = x.Bstyp;
                        hrd.DocumentType       = x.Bsart;
                        hrd.ContractValue      = x.Ktwrt;
                        hrd.CreatedBy          = x.Ernam;
                        hrd.Currency           = x.Waers;
                        hrd.ExchangeRate       = x.Wkurs;
                        hrd.InternalReference  = "";
                        hrd.PaymentTerms       = x.Zterm;
                        hrd.PurchasingGroup    = x.Ekgrp;
                        hrd.SalesContactPerson = x.Verkf;
                        hrd.SupplierId         = x.Lifnr;
                        hrd.Telephone          = x.Telf1;
                        hrd.ValidityEnd        = Convert.ToInt64(x.Kdate);
                        hrd.ValidityStart      = Convert.ToInt64(x.Kdatb);

                        if (ContractHeaderDAO.RetrieveByKey(tran, x.Ebeln) != null)
                        {
                            ContractHeaderDAO.Update(tran, hrd);
                        }
                        else
                        {
                            ContractHeaderDAO.Insert(tran, hrd);
                        }

                        wstr = wstr + x.Ebeln + ", ";
                        aForm.getProgressBar().Increment(wstep);
                    }

                    this.setParameters();
                    wstep = 100 / contractItem.Count;
                    foreach (ZCONTRACT_ITM x in contractItem)
                    {
                        ContractItem itm = new ContractItem();
                        itm.ContractNumber       = x.Ebeln;
                        itm.ContractItemSequence = x.Ebelp;
                        itm.Description          = x.Txz01;
                        itm.MaterialGroup        = x.Matkl;
                        itm.MaterialNumber       = x.Matnr;
                        itm.NetValue             = x.Brtwr;
                        itm.Plant             = x.Werks;
                        itm.PricePerUnit      = x.Peinh;
                        itm.Requisitioner     = x.Afnam;
                        itm.RequisitionNumber = x.Banfn;
                        itm.RFQNumber         = x.Anfnr;
                        itm.TargetQuantity    = x.Ktmng;
                        itm.UnitOfMeasure     = x.Meins;
                        itm.UnitPrice         = x.Netpr;

                        if (ContractItemDAO.RetrieveByKey(tran, x.Ebeln, x.Ebelp) != null)
                        {
                            ContractItemDAO.Update(tran, itm);
                        }
                        else
                        {
                            ContractItemDAO.Insert(tran, itm);
                        }

                        wstr = wstr + x.Ebeln + ", ";
                        aForm.getProgressBar().Increment(wstep);
                    }
                    tran.Commit();
                }
                catch (Exception ex)
                {
                    tran.Rollback();
                    throw (ex);
                }
                finally
                {
                    tran.Dispose();
                }

                this.RemoveContractDetails();
            }
            catch (Exception ex)
            {
                Utility.ExceptionLog(ex);
                throw (ex);
            }
        }