Esempio n. 1
0
        //Inclusão em tabela customizada por objeto, passar nome da tabela e coleção de parâmetros(Nome do campo e valor)
        protected void Incluir(string nomeObjeto, Dictionary <string, string> parametros)
        {
            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                if (parametros != null && parametros.Count > 0)
                {
                    foreach (var item in parametros)
                    {
                        oGeneralData.SetProperty(item.Key.ToString(), item.Value.ToString());
                    }

                    oGeneralService.Add(oGeneralData);
                }

                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                throw e;
            }
        }
Esempio n. 2
0
        public static string AddData(SAPbobsCOM.Company oCompany, EXR model)
        {
            RTNMANVAL rtn = new RTNMANVAL();
            int       errCode; string errMessage, strResult = "";

            SAPbobsCOM.SBObob    oSBob = null;
            SAPbobsCOM.Recordset rs    = null;
            try
            {
                oCompany.StartTransaction();

                oSBob = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoBridge);
                rs    = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                rs    = oSBob.GetLocalCurrency();
                rs    = oSBob.GetSystemCurrency();

                oSBob.SetCurrencyRate(model.Currency, model.DateRate, model.Rate, true);
                oCompany.EndTransaction(BoWfTransOpt.wf_Commit);

                strResult = "OK";
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
                ;
                throw;
            }
            return(strResult);
        }
Esempio n. 3
0
        public ResultadoVO crearDocumento(DocumentoVO documento)
        {
            Sesion sesion = SessionPool.getSession();

            this.company = sesion.company;
            this.documentoVO = documento;

            // TODO: intentar habilitar transacciones nuevamente
            // company.StartTransaction();
            try
            {
                CrearDocumentoSAP();

                if (company.InTransaction)
                {
                    if (this.resultadoVO.Success) company.EndTransaction(BoWfTransOpt.wf_Commit);
                    else company.EndTransaction(BoWfTransOpt.wf_RollBack);
                }
            }
            catch (Exception e)
            {
                if (company.InTransaction) company.EndTransaction(BoWfTransOpt.wf_RollBack);
                log.Error(e);
                this.resultadoVO.Success = false;
                this.resultadoVO.Mensaje = e.Message;
            }
            finally
            {
                sesion.Close();
            }

            return this.resultadoVO;
        }
Esempio n. 4
0
        /// <summary>
        /// Update bom masal
        /// </summary>
        private void UpdateBomVer_Update(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true)
                {
                    SAPbobsCOM.GeneralService oGeneralService;
                    SAPbobsCOM.GeneralData    oGeneralData;
                    SAPbobsCOM.CompanyService sCmp;
                    SAPbobsCOM.ProductTrees   oBom = (SAPbobsCOM.ProductTrees)oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oProductTrees);
                    sCmp = oSBOCompany.GetCompanyService();

                    SAPbobsCOM.GeneralData    oGenDataUpdtBom;
                    SAPbobsCOM.GeneralService oGenServiceUpdtBom;

                    Form         oForm    = oSBOApplication.Forms.Item(formUID);
                    DBDataSource dtSource = null;
                    dtSource = oForm.DataSources.DBDataSources.Item("@SOL_UPBOMVER_H");
                    string lastDate = dtSource.GetValue("U_SOL_UPDATE", 0);
                    string lastTime = Convert.ToString(int.Parse(dtSource.GetValue("U_SOL_UPTIME", 0).Replace(":", "")));

                    // Get a handle to the UDO
                    oGeneralService = sCmp.GetGeneralService("BOMVER");

                    Recordset oRecBomSap = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
                    Recordset oRecBomVer = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);

                    oForm.Freeze(true);

                    try
                    {
                        if (!oSBOCompany.InTransaction)
                        {
                            oSBOCompany.StartTransaction();
                        }

                        string query = string.Empty;
                        if (oSBOCompany.DbServerType == BoDataServerTypes.dst_HANADB)
                        {
                            query = "CALL SOL_SP_UPDTBOM_GETDIFFBOM('" + lastDate + "', '" + lastTime + "')";
                        }
                        oRecBomSap.DoQuery(query);

                        if (oRecBomSap.RecordCount > 0)
                        {
                            int progress = 0;
                            oProgressBar      = oSBOApplication.StatusBar.CreateProgressBar("Update BOM", oRecBomSap.RecordCount, true);
                            oProgressBar.Text = "Update BOM...";

                            for (int i = 1; i <= oRecBomSap.RecordCount; i++)
                            {
                                // Get BOM SAP and insert to BOM Version
                                string itemCodeFG = oRecBomSap.Fields.Item("Code").Value;
                                string version    = oRecBomSap.Fields.Item("Version").Value;

                                if (oSBOCompany.DbServerType == BoDataServerTypes.dst_HANADB)
                                {
                                    query = "CALL SOL_SP_UPDTBOM_GETBOM('" + itemCodeFG + "')";
                                }
                                oRecBomVer.DoQuery(query);

                                if (oRecBomVer.RecordCount > 0)
                                {
                                    oGeneralData = oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                                    if (!string.IsNullOrEmpty(version)) // jika bom sudah ada di bom version
                                    {
                                        // non aktivin bom version
                                        InactiveBomVer(itemCodeFG);

                                        // update aktivin bom version sesuai versinya
                                        ActivateBomVer(version);

                                        // update versi di bom sap
                                        UpdateBOM(itemCodeFG, version, ref bubbleEvent);
                                    }
                                    else // jika bom belum ada di bom version
                                    {
                                        // non aktivin bom version
                                        InactiveBomVer(itemCodeFG);

                                        // add bom version
                                        string versionCode = string.Empty;
                                        AddBomVer(ref oRecBomVer, ref oGeneralService, ref bubbleEvent, out versionCode);

                                        // update versi di bom sap
                                        UpdateBOM(itemCodeFG, versionCode, ref bubbleEvent);
                                    }
                                }
                                progress          += 1;
                                oProgressBar.Value = progress;

                                oRecBomSap.MoveNext();
                            }

                            // Save ke log update bom version
                            #region Save ke log update bom version
                            oGenServiceUpdtBom = sCmp.GetGeneralService("UPBOMVER");
                            oGenDataUpdtBom    = oGenServiceUpdtBom.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                            oGenDataUpdtBom.SetProperty("Code", GenerateCode());
                            oGenDataUpdtBom.SetProperty("U_SOL_UPDATE", DateTime.Now.Date.ToShortDateString());
                            oGenDataUpdtBom.SetProperty("U_SOL_UPTIME", DateTime.Now.ToString("HH:mm:ss", CultureInfo.InvariantCulture));

                            oGenServiceUpdtBom.Add(oGenDataUpdtBom);
                            #endregion

                            oProgressBar.Stop();
                            TemplateLoad(ref oForm);
                            oSBOApplication.StatusBar.SetText("Update BOM Success", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                        }
                        else
                        {
                            oSBOApplication.MessageBox("Tidak ada data yang dapat di update.");
                        }

                        oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                    }
                    catch (Exception ex)
                    {
                        bubbleEvent = false;
                        oSBOApplication.MessageBox(ex.Message);
                        oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                    }
                    finally
                    {
                        if (oProgressBar != null)
                        {
                            oProgressBar.Stop();
                            Utils.releaseObject(oProgressBar);
                        }

                        if (oForm != null)
                        {
                            oForm.Freeze(false);
                        }

                        Utils.releaseObject(oRecBomSap);
                        Utils.releaseObject(oRecBomVer);
                        Utils.releaseObject(oGeneralService);
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Click button replace
        /// </summary>
        private void ChangeCompItm_Replace(string formUID, ref ItemEvent pVal, ref bool bubbleEvent)
        {
            if (bubbleEvent)
            {
                if (pVal.BeforeAction == false && pVal.ActionSuccess == true)// && pVal.EventType == BoEventTypes.et_CLICK)
                {
                    // Checkk Validation
                    string errorMsg = string.Empty;
                    if (IsBlocReplace(formUID, out errorMsg))
                    {
                        oSBOApplication.StatusBar.SetText(errorMsg, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                    }
                    else
                    {
                        Form oForm = oSBOApplication.Forms.Item(formUID);
                        oForm.Freeze(true);

                        SAPbobsCOM.ProductionOrders oProd;
                        oProd = oSBOCompany.GetBusinessObject(BoObjectTypes.oProductionOrders);

                        SAPbobsCOM.GeneralService oGenService = oSBOCompany.GetCompanyService().GetGeneralService("COMPITM");
                        SAPbobsCOM.GeneralData    compLog     = (SAPbobsCOM.GeneralData)oGenService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                        Recordset oRec = oSBOCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
                        Matrix    oMtx = oForm.Items.Item("mt_1").Specific;

                        ProgressBar oProgressBar = oSBOApplication.StatusBar.CreateProgressBar("Replace Work Order", oMtx.RowCount, true);
                        oProgressBar.Text = "Replace Work Order...";
                        int progress = 0;

                        try
                        {
                            for (int i = 1; i <= oMtx.RowCount; i++)
                            {
                                string check = string.Empty;
                                if (oMtx.Columns.Item("cCheck").Cells.Item(i).Specific.Checked == true)
                                {
                                    check = "Y";
                                }

                                if (check == "Y")
                                {
                                    string query = "SELECT \"DocEntry\" FROM OWOR WHERE \"DocNum\" = '" + oMtx.Columns.Item("cNoWo").Cells.Item(i).Specific.Value + "'";
                                    oRec.DoQuery(query);

                                    int docEntry = 0;
                                    if (oRec.RecordCount > 0)
                                    {
                                        docEntry = oRec.Fields.Item("DocEntry").Value;
                                    }

                                    oProd.GetByKey(docEntry);

                                    for (int j = 0; j < oProd.Lines.Count; j++)
                                    {
                                        string b = oForm.Items.Item("tComItmCd").Specific.Value;
                                        if (oProd.Lines.ItemNo == b)
                                        {
                                            oProd.Lines.SetCurrentLine(j);
                                            oProd.Lines.ItemNo = oForm.Items.Item("tAltItmCd").Specific.Value;
                                            string altQty = oMtx.Columns.Item("cAltQty").Cells.Item(i).Specific.Value;
                                            oProd.Lines.PlannedQuantity = Convert.ToDouble(altQty.Replace(".", ","));

                                            int retCode = oProd.Update();
                                            if (retCode == 0)
                                            {
                                                compLog.SetProperty("Code", GetLogCode());
                                                compLog.SetProperty("U_SOL_DOCNUM", oMtx.Columns.Item("cNoWo").Cells.Item(i).Specific.Value);
                                                compLog.SetProperty("U_SOL_RPLDATE", DateTime.Now.Date);
                                                compLog.SetProperty("U_SOL_ITEMCODE", oForm.Items.Item("tComItmCd").Specific.Value);
                                                compLog.SetProperty("U_SOL_ITEMNAME", oForm.Items.Item("tComItmNm").Specific.Value);
                                                compLog.SetProperty("U_SOL_ITMCODE", oForm.Items.Item("tAltItmCd").Specific.Value);
                                                compLog.SetProperty("U_SOL_ITMNAME", oForm.Items.Item("tAltItmNm").Specific.Value);
                                                compLog.SetProperty("U_SOL_COMPQTY", oMtx.Columns.Item("cComQty").Cells.Item(i).Specific.Value);
                                                compLog.SetProperty("U_SOL_ALTQTY", oMtx.Columns.Item("cAltQty").Cells.Item(i).Specific.Value);

                                                oGenService.Add(compLog);
                                                if (oSBOCompany.InTransaction)
                                                {
                                                    oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                                }
                                            }
                                            else
                                            {
                                                throw new Exception();
                                            }
                                            break;
                                        }
                                        else
                                        {
                                            oProd.Lines.SetCurrentLine(j + 1);
                                        }
                                    }
                                }

                                progress          += 1;
                                oProgressBar.Value = progress;
                            }

                            oSBOApplication.StatusBar.SetText("Success change component item.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
                        }
                        catch (Exception ex)
                        {
                            bubbleEvent = false;
                            oSBOApplication.MessageBox(ex.Message);
                            oSBOCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                        }
                        finally
                        {
                            TemplateLoad(ref oForm);
                            oProgressBar.Stop();
                            if (oForm != null)
                            {
                                oForm.Freeze(false);
                            }
                        }
                    }
                }
            }
        }
        public static string InsertRecord(string UDO_Name, Object Objeto, string UDO_Child, List <Object> DetalleObjeto)
        {
            SAPbobsCOM.Company               SBO_Company = Conexion.oCompany;
            SAPbobsCOM.GeneralService        oGeneralService;
            SAPbobsCOM.GeneralData           oGeneralData;
            SAPbobsCOM.GeneralData           oChild;
            SAPbobsCOM.GeneralDataCollection oChildren;
            //SAPbobsCOM.GeneralDataParams oGeneralParams;
            SAPbobsCOM.CompanyService oCompService;
            string rpta = "N";

            try
            {
                //get company service
                if (!SBO_Company.Connected)
                {
                    Conexion.Conectar_Aplicacion();
                }

                oCompService = SBO_Company.GetCompanyService();

                //SBO_Company.StartTransaction();

                oGeneralService = oCompService.GetGeneralService(UDO_Name);

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

                //Setting Data to Master Data Table Fields
                oGeneralData.SetProperty("Code", FuncionesUDO.GetNextCode(UDO_Name).ToString());
                //Recorrer el Objeto y tomar Nombre y Valor de propiedades y asignarlas
                foreach (PropertyInfo propiedad in Objeto.GetType().GetProperties())
                {
                    try
                    {
                        string tipoPropiedad   = propiedad.PropertyType.Name;
                        string NombrePropiedad = propiedad.Name;
                        var    valorPropiedad  = propiedad.GetValue(Objeto, null);
                        oGeneralData.SetProperty(NombrePropiedad, valorPropiedad);
                    }
                    catch (Exception) { }
                }

                //  Handle child rows
                if (DetalleObjeto.Any())
                {
                    oChildren = oGeneralData.Child(UDO_Child);
                    foreach (Object det in DetalleObjeto)
                    {
                        // Create data for rows in the child table
                        oChild = oChildren.Add();
                        foreach (PropertyInfo dPropiedad in det.GetType().GetProperties())
                        {
                            try
                            {
                                string tipoPropiedad   = dPropiedad.PropertyType.Name;
                                string NombrePropiedad = dPropiedad.Name;
                                var    valorPropiedad  = dPropiedad.GetValue(det, null);
                                oChild.SetProperty(NombrePropiedad, valorPropiedad);
                            }
                            catch (Exception) { }
                        }
                    }
                }
                //if(!DT_CHILD.IsEmpty)
                //{
                //    oChildren = oGeneralData.Child("SM_MOR1");
                //    for (int i = 0; i <= DT_CHILD.Rows.Count - 1; i++)
                //    {
                //    // Create data for rows in the child table
                //        oChild = oChildren.Add();
                //        for (int j = 0; j <= DT_CHILD.Columns.Count - 1; j++)
                //        {
                //            string nombreColumna = DT_CHILD.Columns.Item(j).Name;
                //            var valorColumna = DT_CHILD.GetValue(j, i);
                //            oChild.SetProperty(nombreColumna, valorColumna);
                //        }
                //    }
                //}

                //Attempt to Add the Record
                oGeneralService.Add(oGeneralData);
                rpta = "S";
            }
            catch (Exception) { }
            finally
            {
                if (SBO_Company.InTransaction)
                {
                    SBO_Company.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
            return(rpta);

            //try
            //{
            //    Type c_typo =  Objeto.GetType();
            //    PropertyInfo[] c_propiedades = c_typo.GetProperties();
            //    //var valor = c_propiedades.GetValue(Objeto);
            //    foreach (PropertyInfo propiedad in Objeto.GetType().GetProperties())
            //    {
            //        string tipoPropiedad = propiedad.PropertyType.Name;
            //        string NombrePropiedad = propiedad.Name;
            //        var valorPropiedad = propiedad.GetValue(Objeto, null);
            //    }

            //}
            //catch (Exception){}
        }
Esempio n. 7
0
        void IArmada_Sync.Add(string sKey, SAPbobsCOM.Company oCompany, string strLogger, string strWareHouse, string[] strValues, Hashtable htCCdet)
        {
            //Singleton.traceService("Has Record2");
            DataTable oHeader   = null;
            DataTable oDetails  = null;
            DataTable oPayments = null;

            SAPbobsCOM.Documents oInvoiceR = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(BoObjectTypes.oCreditNotes);
            SAPbobsCOM.Payments  oPayment  = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments);

            try
            {
                string str_S_ORIN = "Exec Armada_Service_S_ORIN_s '" + sKey + "'";
                oDataSet = Singleton.objSqlDataAccess.ExecuteDataSet(str_S_ORIN, strLogger);

                if (oDataSet == null && oDataSet.Tables.Count == 0)
                {
                    return;
                }
                else
                {
                    oHeader   = oDataSet.Tables[0];
                    oDetails  = oDataSet.Tables[1];
                    oPayments = oDataSet.Tables[2];

                    if (oHeader != null && oHeader.Rows.Count > 0)
                    {
                        //Singleton.traceService("Has Record");
                        oInvoiceR.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;

                        //Header Table
                        oInvoiceR.CardCode    = oHeader.Rows[0]["Code"].ToString();
                        oInvoiceR.CardName    = oHeader.Rows[0]["Name"].ToString();
                        oInvoiceR.DocDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                        oInvoiceR.NumAtCard   = oHeader.Rows[0]["DocNum"].ToString();
                        oInvoiceR.DocCurrency = oHeader.Rows[0]["DocCur"].ToString();

                        //oInvoice.DocRate = Convert.ToDouble(oHeader.Rows[0]["DocRate"].ToString());
                        oInvoiceR.Comments = oHeader.Rows[0]["Remarks"].ToString();
                        oInvoiceR.UserFields.Fields.Item("U_Z_PAYTYPE").Value = oHeader.Rows[0]["DocType"].ToString();
                        oInvoiceR.UserFields.Fields.Item("U_Z_CASHIER").Value = oHeader.Rows[0]["Cashier"].ToString();
                        oInvoiceR.UserFields.Fields.Item("U_Z_DOCTIME").Value = oHeader.Rows[0]["DocTime"].ToString();
                        oInvoiceR.UserFields.Fields.Item("U_Z_TrnNum").Value  = oHeader.Rows[0]["DocNum"].ToString();

                        if (oDetails.Rows.Count > 0)
                        {
                            foreach (DataRow dr in oDetails.Rows)
                            {
                                oInvoiceR.Lines.ItemCode        = dr["ItemCode"].ToString();
                                oInvoiceR.Lines.ItemDescription = dr["ItemDesc"].ToString();
                                oInvoiceR.Lines.Quantity        = Convert.ToDouble(dr["Qty"].ToString());
                                oInvoiceR.Lines.UnitPrice       = Convert.ToDouble(dr["UnitPrice"].ToString());
                                //oInvoice.Lines.Currency = dr["Currency"].ToString();
                                oInvoiceR.Lines.WarehouseCode = strWareHouse;
                                if (strValues[1] != "")
                                {
                                    oInvoiceR.Lines.CostingCode = strValues[1];
                                }
                                oInvoiceR.Lines.Add();
                            }
                        }
                        //oInvoice.DocTotal = Convert.ToDouble(oHeader.Rows[0]["DocTotal"].ToString());

                        if (oCompany.InTransaction)
                        {
                            oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                        }

                        oCompany.StartTransaction();

                        int intError = oInvoiceR.Add();
                        if (intError != 0)
                        {
                            //Singleton.traceService(intError.ToString());
                            Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARCreditMemo.ToString(), "0", "0", 0, intError.ToString(), oCompany.GetLastErrorDescription().Replace("'", ""), strLogger);
                            if (oCompany.InTransaction)
                            {
                                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                            }
                        }
                        else
                        {
                            //Singleton.traceService("Success");
                            string strDkey;
                            int    intDocNum = 0;
                            oCompany.GetNewObjectCode(out strDkey);
                            if (oInvoiceR.GetByKey(Convert.ToInt32(strDkey)))
                            {
                                intDocNum = oInvoiceR.DocNum;
                            }

                            //Singleton.traceService("Success2");

                            oPayment.CardCode    = oHeader.Rows[0]["Code"].ToString();
                            oPayment.DocType     = SAPbobsCOM.BoRcptTypes.rCustomer;
                            oPayment.DocDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                            oPayment.TaxDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                            oPayment.DocCurrency = oHeader.Rows[0]["DocCur"].ToString();
                            //Singleton.traceService("Success3");

                            oPayment.Invoices.DocEntry    = Convert.ToInt32(strDkey);
                            oPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_CredItnote;
                            oPayment.Invoices.SumApplied  = Convert.ToDouble(oHeader.Rows[0]["InvTotal"].ToString());
                            oPayment.Invoices.Add();

                            //Singleton.traceService("Success4");

                            if (oPayments.Rows.Count > 0)
                            {
                                foreach (DataRow dr in oPayments.Rows)
                                {
                                    //if (dr["PayMethod"].ToString() == "R")
                                    //{
                                    //    oPayment.CreditCards.CreditCard = 1;
                                    //    oPayment.CreditCards.CreditCardNumber = "1111";
                                    //    oPayment.CreditCards.CardValidUntil = System.DateTime.Now;
                                    //    oPayment.CreditCards.PaymentMethodCode = 1;
                                    //    oPayment.CreditCards.CreditSum = Convert.ToDouble(dr["PayAmount"].ToString());
                                    //    oPayment.CreditCards.VoucherNum = "1111";
                                    //    oPayment.CreditCards.Add();
                                    //    Singleton.traceService("Payment Credit");
                                    //}
                                    //else
                                    {
                                        oPayment.CashAccount = strValues[0].ToString();
                                        oPayment.CashSum     = Convert.ToDouble(dr["PayAmount"].ToString());
                                        //Singleton.traceService("Payment Cash");
                                    }
                                }
                            }

                            //Singleton.traceService("Payment Adding");
                            try
                            {
                                int intPayment = oPayment.Add();
                                if (intPayment == 0)
                                {
                                    //Singleton.traceService("Payment Successs");
                                    if (oCompany.InTransaction)
                                    {
                                        oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                    }
                                    Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARCreditMemo.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger);
                                }
                                else
                                {
                                    //Singleton.traceService(intPayment.ToString());
                                    Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARCreditMemo.ToString(), "0", "0", 0, intPayment.ToString(), oCompany.GetLastErrorDescription().Replace("'", ""), strLogger);
                                    if (oCompany.InTransaction)
                                    {
                                        oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                if (oCompany.InTransaction)
                                {
                                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                                }
                                Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARCreditMemo.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARCreditMemo.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger);
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }
                throw ex;
            }
            finally
            {
                oHeader  = null;
                oDetails = null;
                oDataSet = null;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoiceR);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oPayment);
            }
        }
        public bool InsertMonitoring(MonitoringEntity monitoring)
        {
            bool success = false;

            try
            {
                oCompService = oCompany.GetCompanyService();
                oCompany.StartTransaction();
                oGeneralService = oCompService.GetGeneralService("UD_INT_MONITORING");

                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(GeneralServiceDataInterfaces.gsGeneralData);

                oGeneralData.SetProperty("Code", monitoring.DocCode);

                oGeneralData.SetProperty("U_SketchInv", monitoring.Sketch_Invoice);

                oGeneralData.SetProperty("U_DocDate", DateTime.Now.ToString("yyyyMMdd"));

                oGeneralData.SetProperty("U_DocTotal", monitoring.DocTot);

                if (monitoring.BL != null)
                {
                    oGeneralData.SetProperty("U_Bl", monitoring.BL);
                }

                if (monitoring.BLId != null)
                {
                    oGeneralData.SetProperty("U_BlId", monitoring.BLId);
                }

                if (monitoring.Draft != null)
                {
                    oGeneralData.SetProperty("U_Draft", monitoring.Draft);
                }

                if (monitoring.Branch != null)
                {
                    oGeneralData.SetProperty("U_Branch", monitoring.Branch);
                }

                if (monitoring.BranchId != null)
                {
                    oGeneralData.SetProperty("U_BranchId", monitoring.BranchId);
                }

                oGeneralData.SetProperty("U_StatusId", monitoring.StatusId);
                oGeneralData.SetProperty("U_Status", monitoring.Status);

                oGeneralData.SetProperty("U_XMLPath", monitoring.XMLPath);
                oGeneralData.SetProperty("U_Message", monitoring.Message);

                oGeneralService.Add(oGeneralData);
            }
            catch (Exception e)
            {
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }

                LogDAL _log = new LogDAL();
                _log.WriteEntry("InsertMonitoring error: " + e.Message);

                throw e;
            }
            if (oCompany.InTransaction)
            {
                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
            }
            return(success);
        }
Esempio n. 9
0
        void IArmada_Sync.Add(string sKey, SAPbobsCOM.Company oCompany, string strLogger, string strWareHouse, string[] strValues, Hashtable htCCdet)
        {
            DataTable oHeader   = null;
            DataTable oDetails  = null;
            DataTable oPayments = null;

            SAPbobsCOM.Documents oInvoice = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(BoObjectTypes.oInvoices);
            SAPbobsCOM.Payments  oPayment = (SAPbobsCOM.Payments)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oIncomingPayments);

            try
            {
                string str_S_OINV = "Exec Armada_Service_S_OINV_s '" + sKey + "'";
                traceService("Query :" + str_S_OINV);
                oDataSet = Singleton.objSqlDataAccess.ExecuteDataSet(str_S_OINV, strLogger);

                if (oDataSet == null && oDataSet.Tables.Count == 0)
                {
                    return;
                }
                else
                {
                    oHeader   = oDataSet.Tables[0];
                    oDetails  = oDataSet.Tables[1];
                    oPayments = oDataSet.Tables[2];
                    traceService("Adding HASRCROD");

                    if (oHeader != null && oHeader.Rows.Count > 0)
                    {
                        traceService("Adding INvoice");
                        oInvoice.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Items;

                        //Header Table
                        oInvoice.CardCode    = oHeader.Rows[0]["Code"].ToString();
                        oInvoice.CardName    = oHeader.Rows[0]["Name"].ToString();
                        oInvoice.DocDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                        oInvoice.NumAtCard   = oHeader.Rows[0]["DocNum"].ToString();
                        oInvoice.DocCurrency = oHeader.Rows[0]["DocCur"].ToString();
                        //oInvoice.DocRate = Convert.ToDouble(oHeader.Rows[0]["DocRate"].ToString());
                        oInvoice.Comments        = oHeader.Rows[0]["Remarks"].ToString();
                        oInvoice.DiscountPercent = Convert.ToDouble(oHeader.Rows[0]["DisPrct"].ToString());
                        oInvoice.UserFields.Fields.Item("U_Z_PAYTYPE").Value = oHeader.Rows[0]["DocType"].ToString();
                        oInvoice.UserFields.Fields.Item("U_Z_CASHIER").Value = oHeader.Rows[0]["Cashier"].ToString();
                        oInvoice.UserFields.Fields.Item("U_Z_DOCTIME").Value = oHeader.Rows[0]["DocTime"].ToString();
                        oInvoice.UserFields.Fields.Item("U_Z_TrnNum").Value  = oHeader.Rows[0]["DocNum"].ToString();

                        if (oDetails.Rows.Count > 0)
                        {
                            traceService("Adding Details");
                            foreach (DataRow dr in oDetails.Rows)
                            {
                                oInvoice.Lines.ItemCode        = dr["ItemCode"].ToString();
                                oInvoice.Lines.ItemDescription = dr["ItemDesc"].ToString();
                                oInvoice.Lines.Quantity        = Convert.ToDouble(dr["Qty"].ToString());
                                oInvoice.Lines.UnitPrice       = Convert.ToDouble(dr["UnitPrice"].ToString());
                                //oInvoice.Lines.Currency = dr["Currency"].ToString();
                                oInvoice.Lines.WarehouseCode = strWareHouse;
                                if (strValues[0] != "")
                                {
                                    oInvoice.Lines.CostingCode = strValues[0];
                                }
                                oInvoice.Lines.Add();
                            }
                            traceService("Details Added");
                        }
                        //oInvoice.DocTotal = Convert.ToDouble(oHeader.Rows[0]["DocTotal"].ToString());

                        if (oCompany.InTransaction)
                        {
                            oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                        }


                        oCompany.StartTransaction();

                        int intError = oInvoice.Add();
                        if (intError != 0)
                        {
                            traceService(oCompany.GetLastErrorDescription());

                            if (oCompany.InTransaction)
                            {
                                oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                            }

                            Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARInvoice.ToString(), "0", "0", 0, oCompany.GetLastErrorCode().ToString(), oCompany.GetLastErrorDescription().Replace("'", ""), strLogger);
                        }
                        else
                        {
                            string strDkey;
                            int    intDocNum = 0;
                            oCompany.GetNewObjectCode(out strDkey);

                            if (oInvoice.GetByKey(Convert.ToInt32(strDkey)))
                            {
                                intDocNum = oInvoice.DocNum;
                            }

                            if (oHeader.Rows[0]["DocType"].ToString() == "P")
                            {
                                oPayment.CardCode    = oHeader.Rows[0]["Code"].ToString();
                                oPayment.DocType     = SAPbobsCOM.BoRcptTypes.rCustomer;
                                oPayment.DocDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                                oPayment.TaxDate     = Convert.ToDateTime(oHeader.Rows[0]["DocDate"].ToString());
                                oPayment.DocCurrency = oHeader.Rows[0]["DocCur"].ToString();

                                oPayment.Invoices.DocEntry    = Convert.ToInt32(strDkey);
                                oPayment.Invoices.InvoiceType = SAPbobsCOM.BoRcptInvTypes.it_Invoice;
                                oPayment.Invoices.SumApplied  = Convert.ToDouble(oHeader.Rows[0]["InvTotal"].ToString());
                                oPayment.Invoices.Add();

                                if (oPayments.Rows.Count > 0)
                                {
                                    foreach (DataRow dr in oPayments.Rows)
                                    {
                                        if (dr["PayMethod"].ToString() == "R")
                                        {
                                            DataRow ccRows = (DataRow)htCCdet[dr["CardType"].ToString()];
                                            if (ccRows != null)
                                            {
                                                oPayment.CreditCards.CreditCard        = Convert.ToInt16(ccRows["U_CREDITCARD"].ToString());
                                                oPayment.CreditCards.CreditCardNumber  = (ccRows["U_CARDNUMBER"].ToString());
                                                oPayment.CreditCards.CardValidUntil    = Convert.ToDateTime(ccRows["U_CARDVALID"].ToString());
                                                oPayment.CreditCards.PaymentMethodCode = Convert.ToInt16(ccRows["U_PAYMENTMETHOD"].ToString());
                                                oPayment.CreditCards.CreditSum         = Convert.ToDouble(dr["PayAmount"].ToString());
                                                oPayment.CreditCards.VoucherNum        = "1111";
                                                oPayment.CreditCards.Add();
                                            }
                                        }
                                        else
                                        {
                                            oPayment.CashSum = Convert.ToDouble(dr["PayAmount"].ToString());
                                        }
                                    }
                                }

                                int intPayment = oPayment.Add();
                                if (intPayment == 0)
                                {
                                    if (oCompany.InTransaction)
                                    {
                                        oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                    }

                                    traceService("Commited");
                                    Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARInvoice.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger);
                                    traceService("Commited Completed..");
                                }
                                else
                                {
                                    Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARInvoice.ToString(), "0", "0", 0, oCompany.GetLastErrorCode().ToString(), oCompany.GetLastErrorDescription().Replace("'", ""), strLogger);
                                    if (oCompany.InTransaction)
                                    {
                                        oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                                    }
                                }
                            }
                            else
                            {
                                if (oCompany.InTransaction)
                                {
                                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                                }

                                traceService("Commited1");
                                Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARInvoice.ToString(), strDkey, intDocNum.ToString(), 1, "", "Armada_Sync Completed Sucessfully", strLogger);
                                traceService("Commited Completed..1");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //Singleton.objSqlDataAccess.UpdateLog(sKey, TransScenerio.ARInvoice.ToString(), "0", "0", 0, "0", ex.Message.ToString(), strLogger);
                if (oCompany.InTransaction)
                {
                    oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_RollBack);
                }
                traceService("Error 1 : " + ex.Message);
                throw ex;
            }
            finally
            {
                oHeader  = null;
                oDetails = null;
                oDataSet = null;
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oInvoice);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oPayment);
            }
        }