Beispiel #1
0
        //Delete Button
        private void Button3_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService    oGeneralService = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
            SAPbobsCOM.CompanyService    sCmp            = null;
            try
            {
                if (Grid0.Rows.SelectedRows.Count == 1)
                {
                    if (oApp.MessageBox("Are you sure you want to delete this record ?", 2, "Yes", "No") == 1)
                    {
                        int    DocEntry = 0;
                        string t        = Grid0.DataTable.GetValue("Document Number", Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)).ToString();
                        int.TryParse(t, out DocEntry);

                        sCmp            = oCompany.GetCompanyService();
                        oGeneralService = sCmp.GetGeneralService("BILLVP");
                        oGeneralParams  = (SAPbobsCOM.GeneralDataParams)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                        oGeneralParams.SetProperty("DocEntry", DocEntry);
                        oGeneralService.Delete(oGeneralParams);
                        oApp.SetStatusBarMessage("Delete Complete", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                        Load_Grid_Period(EditText0.Value, ComboBox0.Selected.Value);
                    }
                }
                else
                {
                    oApp.MessageBox("Please select record !");
                }
            }
            catch (Exception ex)
            {
                oApp.MessageBox(ex.Message);
            }
        }
Beispiel #2
0
       public string  AddUDORecord(Pair[] src,string sUDOCode)
       {
           string ret="";

           SAPbobsCOM.GeneralService oGeneralService = null;
           SAPbobsCOM.GeneralData oGeneralData = null;
           SAPbobsCOM.GeneralDataParams oGeneralParams = null;
           SAPbobsCOM.CompanyService oCompanyService = null;
           int i = 0;
           try
           {
               oCompanyService = oCompany.GetCompanyService();
               // Get GeneralService (oCmpSrv is the CompanyService)
               oGeneralService = oCompanyService.GetGeneralService(sUDOCode);
               // Create data for new row in main UDO
               oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
               foreach (Pair p in src)
               {
                   //if (p.value.Length > 20)
                   //    oGeneralData.SetProperty(p.key, p.value.Substring(0, 20));
                   //else
                       oGeneralData.SetProperty(p.key, p.value);
               }

               oGeneralParams = oGeneralService.Add(oGeneralData);
               ret = System.Convert.ToString(oGeneralParams.GetProperty("DocEntry"));
           }
           catch (Exception ex)
           {
               throw (ex);
           }
           return ret;
       }
 public void AddLogSap(SAPbobsCOM.Company oCompany, String Comentario, String Archivo, double Cantidad, String Code, String Razon, String Ref1,
                       String Ref2, String Ref4, String Orden, String ItemCode, String ASN, String LPN, String Carton)
 {
     SAPbobsCOM.GeneralService    oGeneralService = null;
     SAPbobsCOM.GeneralData       oGeneralData    = null;
     SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
     SAPbobsCOM.CompanyService    oCompanyService = null;
     try
     {
         oCompanyService = oCompany.GetCompanyService();
         // Get GeneralService (oCmpSrv is the CompanyService)
         oGeneralService = oCompanyService.GetGeneralService("LOGSAP");
         // Create data for new row in main UDO
         oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
         oGeneralData.SetProperty("U_Archivo", Archivo);
         oGeneralData.SetProperty("U_Cantidad", Cantidad);
         oGeneralData.SetProperty("U_Code", Code);
         oGeneralData.SetProperty("U_Razon", Razon);
         oGeneralData.SetProperty("U_Ref1", Ref1);
         oGeneralData.SetProperty("U_Ref2", Ref2);
         oGeneralData.SetProperty("U_Ref4", Ref4);
         oGeneralData.SetProperty("U_Orden", Orden);
         oGeneralData.SetProperty("U_ItemCode", ItemCode);
         oGeneralData.SetProperty("U_ASN", ASN);
         oGeneralData.SetProperty("U_LPN", LPN);
         oGeneralData.SetProperty("U_Carton", Carton);
         oGeneralData.SetProperty("U_Comentario", Comentario);
         oGeneralParams = oGeneralService.Add(oGeneralData);
     }
     catch (Exception ex)
     {
         AddLog(ex.Message + "Error Exception");
     }
 }
Beispiel #4
0
        //No usado
        public static bool eliminar(string codigo)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;

            try
            {
                mService     = Conexion.company.GetCompanyService().GetGeneralService(TipoUsuario.getTabla().nombre);
                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", codigo);
                SAPbobsCOM.GeneralData fObj = mService.GetByParams(searchParams);
                mService.Delete(searchParams);
            }
            catch (Exception ex)
            {
                res = false;
                StatusMessageError("TipoUsuarioDAO > eliminar() > " + ex.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }
            }

            return(res);
        }
Beispiel #5
0
        public static bool actualizar(EquipoBean bean)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;
            SAPbobsCOM.GeneralData       mEquipo      = null;

            try
            {
                mService = Conexion.company.GetCompanyService().GetGeneralService(Movil.getTabla().nombre);
                mEquipo  = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", bean.codigo);

                mEquipo = mService.GetByParams(searchParams);
                mEquipo.SetProperty("Name", bean.descripcion);
                mEquipo.SetProperty("U_MSSM_MOD", bean.modelo);
                mEquipo.SetProperty("U_MSSM_SER", bean.serie);
                mEquipo.SetProperty("U_MSSM_COL", bean.color);
                mEquipo.SetProperty("U_MSSM_IDU", bean.codigoUnico);
                mEquipo.SetProperty("U_MSSM_VAL", bean.verificarId);

                mService.Update(mEquipo);
            }
            catch (Exception e)
            {
                res = false;
                StatusMessageError("EquipoDAO > actualizar() > " + e.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }

                if (mEquipo != null)
                {
                    LiberarObjetoGenerico(mEquipo);
                }
            }

            return(res);
        }
Beispiel #6
0
        static public void loadDepto()
        {
            SAPbobsCOM.CompanyService          objCompanyService = null;
            SAPbobsCOM.GeneralService          UDOService        = null;
            SAPbobsCOM.GeneralData             headerInfo        = null;
            SAPbobsCOM.GeneralDataParams       addResult         = null;
            SAPbobsCOM.GeneralCollectionParams objList           = null;

            try
            {
                objCompanyService = MainObject.Instance.B1Company.GetCompanyService();
                UDOService        = objCompanyService.GetGeneralService(Settings._Main.loadDeptUDO);
                headerInfo        = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                try
                {
                    objList = UDOService.GetList();
                }
                catch (COMException comEx)
                {
                    if (comEx.ErrorCode == -2028)
                    {
                        objList = null;
                    }
                }
                catch (Exception er)
                {
                    _Logger.Error("", er);
                    objList = null;
                }
                if (objList == null || objList.Count == 0)
                {
                    using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\" + Settings._Main.loadDeptUDO))
                    {
                        while (!sr.EndOfStream)
                        {
                            string   strLine   = sr.ReadLine();
                            string[] strResult = strLine.Split('|');
                            headerInfo.SetProperty("Code", strResult[0].Trim());
                            headerInfo.SetProperty("Name", strResult[1].Trim());
                            addResult = UDOService.Add(headerInfo);
                        }
                    }
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
Beispiel #7
0
        public static bool actualizar(string codigo, string descripcion, string activo, string supervisor, string cobrador)
        {
            var res = true;

            SAPbobsCOM.GeneralService    mService     = null;
            SAPbobsCOM.GeneralDataParams searchParams = null;
            SAPbobsCOM.GeneralData       mTipoUsuario = null;

            try
            {
                mService     = Conexion.company.GetCompanyService().GetGeneralService(TipoUsuario.getTabla().nombre);
                mTipoUsuario = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);

                searchParams = mService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                searchParams.SetProperty("Code", codigo);

                mTipoUsuario = mService.GetByParams(searchParams);
                mTipoUsuario.SetProperty("Name", descripcion);
                mTipoUsuario.SetProperty("U_MSSM_HAB", activo);
                mTipoUsuario.SetProperty("U_MSSM_SUP", supervisor);
                mTipoUsuario.SetProperty("U_MSSM_COB", cobrador);

                mService.Update(mTipoUsuario);
            }
            catch (Exception e)
            {
                res = false;
                StatusMessageError("TipoUsuarioDAO > actualizar() > " + e.Message);
            }
            finally
            {
                if (mService != null)
                {
                    LiberarObjetoGenerico(mService);
                }

                if (searchParams != null)
                {
                    LiberarObjetoGenerico(searchParams);
                }

                if (mTipoUsuario != null)
                {
                    LiberarObjetoGenerico(mTipoUsuario);
                }
            }

            return(res);
        }
Beispiel #8
0
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;

            sCmp            = oCompany.GetCompanyService();
            oGeneralService = sCmp.GetGeneralService("BaseLine");
            //Create data for new row in main UDO
            oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
            //Financial Project
            oGeneralData.SetProperty("U_FProject", FProject);
            //Date
            oGeneralData.SetProperty("U_BaseDate", DateTime.Today);
            //Note
            oGeneralData.SetProperty("U_Note", EditText2.Value.Trim());
            //Add Quy trinh duyet
            DataTable rs = Get_Approve_Process_BASELINE();

            if (rs.Rows.Count > 0)
            {
                oChildren = oGeneralData.Child("BASELINE_APPR");
                foreach (DataRow r in rs.Rows)
                {
                    oChild = oChildren.Add();
                    oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                    oChild.SetProperty("U_Posistion", r["Position"].ToString());
                    oChild.SetProperty("U_DeptName", r["DeptName"].ToString());
                    oChild.SetProperty("U_PosName", r["PosName"].ToString());
                }
            }
            oGeneralParams = oGeneralService.Add(oGeneralData);

            if (!string.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
            {
                int BaseLine_DocEntry = 0;
                int.TryParse(oGeneralParams.GetProperty("DocEntry").ToString(), out BaseLine_DocEntry);
                //Add BaseLine Data
                Add_Data(BaseLine_DocEntry);
                oApp.SetStatusBarMessage("Add Completed - DocEntry: " + oGeneralParams.GetProperty("DocEntry").ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                this.UIAPIRawForm.Close();
            }
        }
Beispiel #9
0
       /// <summary>
       /// add record to udo
       /// </summary>
       /// <param name="oCompany"></param>
       /// <param name="sUDOCode">udo key</param>
       /// <returns></returns>
       //private bool AddUDORecord(string sUDOKey)
       //{
       //    bool ret = false;

       //    SAPbobsCOM.GeneralService oGeneralService = null;
       //    SAPbobsCOM.GeneralData oGeneralData = null;
       //    SAPbobsCOM.GeneralDataParams oGeneralParams = null;
       //    SAPbobsCOM.CompanyService oCompanyService = null;
       //    int i = 0;
       //    try
       //    {
       //        oCompanyService = oCompany.GetCompanyService();
       //        oGeneralService = oCompanyService.GetGeneralService(sUDOKey);
       //        // Create data for new row in main UDO
       //        oGeneralData = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));
       //        oGeneralData.SetProperty("U_ItemCode", "");
       //        oGeneralData.SetProperty("U_Content", "");

       //        oGeneralParams = oGeneralService.Add(oGeneralData);
       //        string txtCode = System.Convert.ToString(oGeneralParams.GetProperty("DocEntry")); 

       //        ret = true;
       //    }
       //    catch (Exception ex)
       //    {
       //        throw (ex);
       //    }
       //    return ret;
       //}

       /// <summary>
       /// del record of udo by docentry
       /// </summary>
       /// <param name="sDocEntry"></param>
       /// <param name="sUDOKey">UDO的key</param>
        public  void DeleteUDORecord(string sDocEntry, string sUDOKey)
        {

            SAPbobsCOM.GeneralService oGeneralService = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams = null;
            SAPbobsCOM.CompanyService sCmp = null;
            sCmp = oCompany.GetCompanyService();
            try
            { 
                oGeneralService = sCmp.GetGeneralService(sUDOKey);
                // Delete UDO record
                oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                oGeneralParams.SetProperty("DocEntry", sDocEntry);
                oGeneralService.Delete(oGeneralParams);
            }
            catch (Exception ex)
            {
                throw (ex); 
            }
        }
Beispiel #10
0
        private void CrearRegistroLog(string codError, string descError, string nroPed)
        {
            SAPbobsCOM.CompanyService oCompanyService = null;
            SAPbobsCOM.GeneralData    oGeneralData    = null;
            SAPbobsCOM.GeneralService oGeneralService = null;

            oCompanyService = oCompany.GetCompanyService();
            oGeneralService = oCompanyService.GetGeneralService("EXXLOGCASTPEDID");
            oGeneralData    = ((SAPbobsCOM.GeneralData)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));

            oGeneralData.SetProperty("U_EXX_CodError", codError);
            oGeneralData.SetProperty("U_EXX_DescError", descError);
            oGeneralData.SetProperty("U_EXX_NroPed", nroPed);
            oGeneralData.SetProperty("U_EXX_Fecha", String.Format("{0:G}", DateTime.Now.ToString()));

            SAPbobsCOM.GeneralDataParams oGeneralParams = null;
            oGeneralParams = oGeneralService.Add(oGeneralData);

            dbSap.LiberarObjeto(oCompanyService);
            dbSap.LiberarObjeto(oGeneralData);
            dbSap.LiberarObjeto(oGeneralService);
            dbSap.LiberarObjeto(oGeneralParams);
        }
Beispiel #11
0
 private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     //throw new System.NotImplementedException();
     if (pVal.ActionSuccess)
     {
         //Get Batch Num has created
         XmlDocument xmldoc = new XmlDocument();
         xmldoc.LoadXml(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey);
         XmlNodeList nodeList = xmldoc.GetElementsByTagName("BatchNum");
         string      BatchNum = string.Empty;
         try
         {
             if (nodeList.Count > 0)
             {
                 BatchNum = nodeList.Item(0).InnerText;
             }
         }
         catch
         {
             BatchNum = string.Empty;
         }
         if (!string.IsNullOrEmpty(BatchNum))
         {
             //Check if exist in JV_APPROVE
             if (!Check_Approve_Process_Exist(BatchNum))
             {
                 //Get Info BatchNum
                 SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                 oR_RecordSet.DoQuery("Select top 1 U_LCP,Project from OBTF where BatchNum=" + BatchNum + " order by TransID desc");
                 string U_LCP = oR_RecordSet.Fields.Item("U_LCP").Value.ToString();
                 //string BCH = oR_RecordSet.Fields.Item("U_CP").Value.ToString();
                 string    FProject   = oR_RecordSet.Fields.Item("Project").Value.ToString();
                 string    Type_JV    = "";
                 DataTable tb_lstappr = null;
                 if (U_LCP == "VP")
                 {
                     Type_JV = "VP";
                 }
                 else if (U_LCP == "BCH")
                 {
                     Type_JV = "BCH";
                 }
                 if (Type_JV == "VP" || Type_JV == "BCH")
                 {
                     if (Check_Accountant())
                     {
                         Button0.Item.Visible = false;
                     }
                 }
                 else
                 {
                     if (Check_Accountant())
                     {
                         Button0.Item.Visible = true;
                     }
                 }
                 tb_lstappr = GetList_Approve(FProject, Type_JV);
                 if (tb_lstappr.Rows.Count > 0)
                 {
                     SAPbobsCOM.GeneralService        oGeneralService = null;
                     SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
                     SAPbobsCOM.CompanyService        sCmp            = null;
                     SAPbobsCOM.GeneralData           oGeneralData    = null;
                     SAPbobsCOM.GeneralData           oChild          = null;
                     SAPbobsCOM.GeneralDataCollection oChildren       = null;
                     sCmp            = oCompany.GetCompanyService();
                     oGeneralService = sCmp.GetGeneralService("JVAPPROVE");
                     //Create data for new row in main UDO
                     oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                     oGeneralData.SetProperty("U_JVBatchNum", int.Parse(BatchNum));
                     oGeneralData.SetProperty("U_Type", Type_JV);
                     //Create data for a row in the child table
                     oChildren = oGeneralData.Child("JV_APROVE_D");
                     foreach (DataRow r in tb_lstappr.Rows)
                     {
                         oChild = oChildren.Add();
                         oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                         oChild.SetProperty("U_Position", r["Position"].ToString());
                     }
                     oGeneralParams = oGeneralService.Add(oGeneralData);
                     if (!String.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
                     {
                         oApp.SetStatusBarMessage("Approve Process Added !!!", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                         if (Check_Accountant())
                         {
                             Button0.Item.Visible = false;
                         }
                     }
                     else
                     {
                         //Close Voucher
                         //SAPbobsCOM.JournalVouchers oVoucher = (SAPbobsCOM.JournalVouchers)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalVouchers);
                     }
                 }
             }
         }
     }
 }
Beispiel #12
0
        //private static void LoadInfo(SAPbouiCOM.Form oForm)
        //{
        //    SAPbobsCOM.Recordset oRecordset = null;
        //    SAPbouiCOM.Matrix oMatrix = null;
        //    SAPbouiCOM.Matrix oMatrixMm = null;

        //    try
        //    {
        //        oForm.Freeze(true);
        //        oRecordset = Conexion_SBO.m_oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
        //        oMatrix = oForm.Items.Item("Mtx1").Specific;
        //        oMatrixMm = oForm.Items.Item("Mtx_Mn").Specific;
        //        oRecordset.DoQuery("SELECT \"DocNum\" FROM \"@SEI_SETVALH\" ");
        //        if (oRecordset.RecordCount > 0 )
        //        {
        //            SAPbouiCOM.EditText oedit = null;
        //            oForm.Mode = SAPbouiCOM.BoFormMode.fm_FIND_MODE;
        //            oedit = oForm.Items.Item("DocNum").Specific;
        //            oedit.Value = "1";
        //            oForm.EnableMenu("1281", false);// 1281 --> Buscar
        //            oForm.EnableMenu("1282", false);// 1282 --> Crear
        //            oForm.Items.Item("1").Click(SAPbouiCOM.BoCellClickType.ct_Regular);
        //            oForm.Items.Item("DocNum").Enabled = false;
        //            oForm.Items.Item("DocNum").Visible = false;

        //        }
        //        else

        //        {
        //            oForm.Mode = SAPbouiCOM.BoFormMode.fm_ADD_MODE;
        //            oMatrix.AddRow(2);
        //            //lines
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(1).Specific)).Value = "Entrada de mercancias";
        //            ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(1).Specific)).Checked = true;
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_2").Cells.Item(1).Specific)).Value = "1";
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(2).Specific)).Value = "Oferta de compra";
        //            ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(2).Specific)).Checked = true;
        //            ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_2").Cells.Item(1).Specific)).Value = "2";

        //            ((SAPbouiCOM.CheckBox)(oForm.Items.Item("cbSentAcep").Specific)).Checked = true;

        //            oMatrixMm.AddRow();
        //            ((SAPbouiCOM.EditText)(oMatrixMm.Columns.Item("Col_0").Cells.Item(1).Specific)).Value = "0";
        //            ((SAPbouiCOM.EditText)(oMatrixMm.Columns.Item("Col_1").Cells.Item(1).Specific)).Value = "0";

        //        }
        //        oForm.Items.Item("Mtx1").Visible = false;
        //        oForm.Freeze(false);

        //    }
        //    catch(Exception ex)
        //    {
        //        oForm.Freeze(false);
        //    }
        //}

        private static void UpdateInfo(SAPbouiCOM.Form oForm)
        {
            SAPbouiCOM.Matrix                oMatrix = null;
            SAPbouiCOM.Matrix                oMatrixMm = null;
            SAPbobsCOM.GeneralService        oDocGeneralService = null;
            SAPbobsCOM.CompanyService        oCompService = null;
            SAPbobsCOM.GeneralData           oDocGeneralData = null;
            SAPbobsCOM.GeneralDataCollection oDocLinesCollection = null;
            SAPbobsCOM.GeneralData           oDocLineGeneralData = null;
            string sDocEntry = null, sCode = null, sDscrp = null;
            bool   Check = false;

            try
            {
                #region fm_UPDATE_MODE Validaciones
                //MODIFICAR Setting Validaciones

                sCode     = oForm.DataSources.DBDataSources.Item("@SEI_SETVALH").GetValue("Code", 0);
                sDocEntry = oForm.DataSources.DBDataSources.Item("@SEI_SETVALH").GetValue("DocEntry", 0);


                SAPbobsCOM.GeneralDataParams oGeneralDataParams = null;
                Conexion_SBO.m_oCompany.StartTransaction();
                oCompService       = Conexion_SBO.m_oCompany.GetCompanyService();
                oDocGeneralService = oCompService.GetGeneralService("SEI_SETVAL");
                oGeneralDataParams = oDocGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                oGeneralDataParams.SetProperty("Code", sCode);
                oDocGeneralData = oDocGeneralService.GetByParams(oGeneralDataParams);


                //oDocGeneralData.SetProperty("U_FechaParada", dtFechP.ToString("yyyy-MM-dd"));
                //oDocGeneralData.SetProperty("U_Turno", strTurP);

                #region Lines validaciones
                oDocLinesCollection = oDocGeneralData.Child("SEI_SETVALL");
                oMatrix             = oForm.Items.Item("Mtx1").Specific;
                for (int reg = 1; reg <= oMatrix.RowCount; reg++)
                {
                    #region Asignacion de Valores
                    sDscrp = ((SAPbouiCOM.EditText)(oMatrix.Columns.Item("Col_0").Cells.Item(reg).Specific)).Value;
                    Check  = ((SAPbouiCOM.CheckBox)(oMatrix.Columns.Item("Col_1").Cells.Item(reg).Specific)).Checked;
                    #endregion Asignacion de Valores

                    #region Crear Lista de validaciones
                    oDocLineGeneralData = oDocLinesCollection.Item(reg - 1);
                    oDocLineGeneralData.SetProperty("U_Dscr", sDscrp);
                    oDocLineGeneralData.SetProperty("U_Validar", (Check == true ?"Y" : "N"));
                    #endregion Crear Lista de validaciones
                }
                //oDocGeneralService.Add(oDocGeneralData);
                #endregion Lines validaciones

                oDocGeneralService.Update(oDocGeneralData);

                if (Conexion_SBO.m_oCompany.InTransaction)
                {
                    Conexion_SBO.m_oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }

                oCompService = null;
                GC.Collect();

                #endregion fm_UPDATE_MODE Validaciones
            }
            catch (Exception ex)
            {
                if (Conexion_SBO.m_oCompany.InTransaction)
                {
                    Conexion_SBO.m_oCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
        }
Beispiel #13
0
        public string SPA_AddIndividual(DataTable dtDatatable)
        {
            string    sFuncName      = string.Empty;
            string    sReturnResult  = string.Empty;
            string    sCode          = string.Empty;
            string    sExistingCheck = string.Empty;
            DataTable ExistingCheck  = new DataTable();

            try
            {
                sFuncName = "SPA_AddIndividual";

                SqlConnection con     = new SqlConnection(ConnectionString);
                SqlCommand    command = con.CreateCommand();
                con.Open();

                command.CommandText = "select Code, DocEntry from [@AE_RELATEDPARTY] WITH (NOLOCK) where U_IDNO_F1 = '" + dtDatatable.Rows[0]["IDNo1"].ToString().Replace("\n", "").ToString() + "'";
                SqlDataAdapter dataAdapter1 = new SqlDataAdapter(command);
                dataAdapter1.Fill(ExistingCheck);

                con.Close();

                if (ExistingCheck.Rows.Count == 0)
                {
                    //if (ExistingCheck.Rows[0][0].ToString().Length == 0)
                    //{
                    DataTable results = new DataTable();
                    command.CommandText = "SELECT REPLICATE('0', (12-LEN(ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)))) " +
                                          " + CONVERT(VARCHAR, ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)) [Code] FROM [@AE_RELATEDPARTY] WITH (NOLOCK)";
                    con.Open();

                    SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
                    dataAdapter.Fill(results);

                    if (results.Rows[0][0].ToString().Length > 0)
                    {
                        sCode = results.Rows[0][0].ToString();
                    }

                    con.Close();

                    if (p_iDebugMode == DEBUG_ON)
                    {
                        oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName);
                    }
                    oDICompany = oLogin.ConnectToTargetCompany(ConnectionString);

                    SAPbobsCOM.GeneralService oGeneralService = null;
                    SAPbobsCOM.GeneralData    oGeneralData;
                    SAPbobsCOM.CompanyService oCompanyService = oDICompany.GetCompanyService();
                    oGeneralService = oCompanyService.GetGeneralService("RELATEDPARTY");

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

                    string[] sIDSplitUp = dtDatatable.Rows[0]["IDNo1"].ToString().Split('-');
                    string   sIDNo2     = dtDatatable.Rows[0]["IDNo1"].ToString();
                    string   sAddressId = dtDatatable.Rows[0]["IDAddress1"].ToString() + System.Environment.NewLine + dtDatatable.Rows[0]["IDAddress2"].ToString() + System.Environment.NewLine
                                          + dtDatatable.Rows[0]["IDAddress3"].ToString() + System.Environment.NewLine +
                                          dtDatatable.Rows[0]["IDAddress4"].ToString() + System.Environment.NewLine + dtDatatable.Rows[0]["IDAddress5"].ToString();
                    string sCorrespondAddressId = dtDatatable.Rows[0]["CorresAddr1"].ToString() + System.Environment.NewLine + dtDatatable.Rows[0]["CorresAddr2"].ToString() + System.Environment.NewLine
                                                  + dtDatatable.Rows[0]["CorresAddr3"].ToString() + System.Environment.NewLine +
                                                  dtDatatable.Rows[0]["CorresAddr4"].ToString() + System.Environment.NewLine + dtDatatable.Rows[0]["CorresAddr5"].ToString();

                    //Adding the Informations
                    oGeneralData.SetProperty("Code", sCode);
                    //oGeneralData.SetProperty("DocEntry", dtDatatable.Rows[0]["DocEntry"].ToString());
                    oGeneralData.SetProperty("U_NAME", dtDatatable.Rows[0]["EmployeeName"].ToString());
                    oGeneralData.SetProperty("U_INDIVIDUAL_TITLE", dtDatatable.Rows[0]["Title"].ToString());
                    oGeneralData.SetProperty("U_GENDER", dtDatatable.Rows[0]["Gender"].ToString());
                    oGeneralData.SetProperty("U_IDNO_F1", dtDatatable.Rows[0]["IDNo1"].ToString());
                    oGeneralData.SetProperty("U_IDNO_F2", sIDNo2.Replace("-", ""));
                    oGeneralData.SetProperty("U_IDNO_F3", dtDatatable.Rows[0]["IDNo3"].ToString());
                    if (sIDSplitUp.Length > 0)
                    {
                        if (sIDSplitUp.Length >= 1)
                        {
                            oGeneralData.SetProperty("U_IDSEC1", sIDSplitUp[0]);
                        }
                        if (sIDSplitUp.Length >= 2)
                        {
                            oGeneralData.SetProperty("U_IDSEC2", sIDSplitUp[1]);
                        }
                        if (sIDSplitUp.Length >= 3)
                        {
                            oGeneralData.SetProperty("U_IDSEC3", sIDSplitUp[2]);
                        }
                    }
                    oGeneralData.SetProperty("U_IDTYPE", "INDIVIDUAL");
                    oGeneralData.SetProperty("U_TAXNOFORMAT1", dtDatatable.Rows[0]["TaxNo"].ToString());
                    oGeneralData.SetProperty("U_CONTACT_MOBILE", dtDatatable.Rows[0]["MobileNo"].ToString());
                    oGeneralData.SetProperty("U_CONTACT_TELEPHONE", dtDatatable.Rows[0]["Telephone"].ToString());
                    oGeneralData.SetProperty("U_SYARIKATNO", dtDatatable.Rows[0]["OfficeNo"].ToString());
                    oGeneralData.SetProperty("U_ADDSEG1", dtDatatable.Rows[0]["IDAddress1"].ToString());
                    oGeneralData.SetProperty("U_ADDSEG2", dtDatatable.Rows[0]["IDAddress2"].ToString());
                    oGeneralData.SetProperty("U_ADDSEG3", dtDatatable.Rows[0]["IDAddress3"].ToString());
                    oGeneralData.SetProperty("U_ADDSEG4", dtDatatable.Rows[0]["IDAddress4"].ToString());
                    oGeneralData.SetProperty("U_ADDSEG5", dtDatatable.Rows[0]["IDAddress5"].ToString());
                    oGeneralData.SetProperty("U_ADDRESS_ID", sAddressId);
                    oGeneralData.SetProperty("U_CADDSEG1", dtDatatable.Rows[0]["CorresAddr1"].ToString());
                    oGeneralData.SetProperty("U_CADDSEG2", dtDatatable.Rows[0]["CorresAddr2"].ToString());
                    oGeneralData.SetProperty("U_CADDSEG3", dtDatatable.Rows[0]["CorresAddr3"].ToString());
                    oGeneralData.SetProperty("U_CADDSEG4", dtDatatable.Rows[0]["CorresAddr4"].ToString());
                    oGeneralData.SetProperty("U_CADDSEG5", dtDatatable.Rows[0]["CorresAddr5"].ToString());
                    oGeneralData.SetProperty("U_ADDRESS_CORRESPOND", sCorrespondAddressId);
                    oGeneralData.SetProperty("U_ADDRESS_TOUSE", dtDatatable.Rows[0]["AddressToUse"].ToString());
                    oGeneralData.SetProperty("U_BANK", "N");
                    oGeneralData.SetProperty("U_DEVELOPER", "N");
                    oGeneralData.SetProperty("U_SOLICITOR", "N");
                    //oGeneralData.SetProperty("LastUpdatedOn", dtDatatable.Rows[0]["LastUpdatedOn"].ToString());
                    oGeneralData.SetProperty("U_IDSCAN1", dtDatatable.Rows[0]["ScanFrontICLocation"].ToString());
                    oGeneralData.SetProperty("U_IDSCAN2", dtDatatable.Rows[0]["ScanBackICLocation"].ToString());
                    oGeneralData.SetProperty("U_MaritalStatus", dtDatatable.Rows[0]["MaritalStatus"].ToString());
                    oGeneralData.SetProperty("U_OCCUPATION", dtDatatable.Rows[0]["Occupation"].ToString());
                    oGeneralData.SetProperty("U_IdentityType", dtDatatable.Rows[0]["IdentityType"].ToString());

                    oGeneralService.Add(oGeneralData);
                    //}

                    //else
                    //{
                    //    SPA_EditIndividual(dtDatatable, ExistingCheck.Rows[0][0].ToString(), ExistingCheck.Rows[0][1].ToString());
                    //}
                }
                else
                {
                    SPA_EditIndividual(dtDatatable, ExistingCheck.Rows[0][0].ToString(), ExistingCheck.Rows[0][1].ToString());
                }
                sReturnResult = "SUCCESS";
            }
            catch (Exception Ex)
            {
                sErrDesc = Ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                }
                throw Ex;
            }

            return(sReturnResult);
        }
Beispiel #14
0
        //Add Button
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;
            try
            {
                BpCode = EditText0.Value;
                Get_BpName();

                sCmp            = oCompany.GetCompanyService();
                oGeneralService = sCmp.GetGeneralService("BILLVP");
                //Create data for new row in main UDO
                oGeneralData = (SAPbobsCOM.GeneralData)oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                //Financial Project
                oGeneralData.SetProperty("U_FProject", ComboBox0.Selected.Value);
                //Project Name
                oGeneralData.SetProperty("U_ProjectName", EditText1.Value);
                //BpCode
                oGeneralData.SetProperty("U_BPCode", BpCode);
                //BpName
                oGeneralData.SetProperty("U_BPName", BpName);
                //Bill Type
                int btype = 2;
                int.TryParse(ComboBox1.Selected.Value, out btype);
                oGeneralData.SetProperty("U_BType", btype);
                //Date From
                oGeneralData.SetProperty("U_DateFr", DateTime.ParseExact(EditText3.Value, "yyyyMMdd", CultureInfo.InvariantCulture));
                //Date To
                oGeneralData.SetProperty("U_DateTo", DateTime.ParseExact(EditText4.Value, "yyyyMMdd", CultureInfo.InvariantCulture));
                //Period
                oGeneralData.SetProperty("U_Period", EditText2.Value);
                //Remarks
                oGeneralData.SetProperty("Remark", EditText7.Value);
                //Add Bill Tam ung
                if (ComboBox1.Selected.Value == "1")
                {
                    Double tmp_tu = 0;
                    Double.TryParse(EditText5.Value, out tmp_tu);
                    oGeneralData.SetProperty("U_Tamung", tmp_tu);
                }
                //Add Bill thanh toan
                else if (ComboBox1.Selected.Value == "2")
                {
                    //Khau tru tam ung
                    Double tmp_ktu = 0;
                    Double.TryParse(EditText6.Value, out tmp_ktu);
                    oGeneralData.SetProperty("U_KhautruTU", tmp_ktu);

                    DataTable rs = Get_Data_BILLVP(ComboBox0.Selected.Value, DateTime.ParseExact(EditText4.Value, "yyyyMMdd", CultureInfo.InvariantCulture), BpCode);
                    Double    t  = 0;
                    if (rs.Rows.Count > 0)
                    {
                        //Create data for a row in the child table
                        oChildren = oGeneralData.Child("BILLVP1");
                        foreach (DataRow r in rs.Rows)
                        {
                            oChild = oChildren.Add();
                            //So chung tu
                            oChild.SetProperty("U_GRPO_Key", int.Parse(r["GRPOKey"].ToString()));
                            //Line details
                            oChild.SetProperty("U_GRPO_Line", int.Parse(r["GRPORowKey"].ToString()));
                            //Ma phong ban
                            oChild.SetProperty("U_DistRule", r["MaPB"].ToString());
                            //Ten phong ban
                            oChild.SetProperty("U_DisRule_Name", r["TenPB"].ToString());
                            //Du an
                            oChild.SetProperty("U_Project", r["DA"].ToString());
                            //Level 1
                            oChild.SetProperty("U_Level1", r["U_ParentID1"].ToString());
                            //Level 1 Name
                            oChild.SetProperty("U_Level1Name", r["Name1"].ToString());
                            //Level 2
                            oChild.SetProperty("U_Level2", r["U_ParentID2"].ToString());
                            //Level 2 Name
                            oChild.SetProperty("U_Level2Name", r["Name2"].ToString());
                            //Level 3
                            oChild.SetProperty("U_Level3", r["U_ParentID3"].ToString());
                            //Level 3 Name
                            oChild.SetProperty("U_Level3Name", r["Name3"].ToString());
                            //Level 4
                            oChild.SetProperty("U_Level4", r["U_ParentID4"].ToString());
                            //Level 4 Name
                            oChild.SetProperty("U_Level4Name", r["Name4"].ToString());
                            //Level 5
                            oChild.SetProperty("U_Level5", r["U_ParentID5"].ToString());
                            //Level 5 Name
                            oChild.SetProperty("U_Level5Name", r["Name5"].ToString());
                            //Ma CP
                            oChild.SetProperty("U_MaCP", r["MaCP"].ToString());
                            //Ten CP
                            oChild.SetProperty("U_TenCP", r["TenCP"].ToString());
                            //Noi dung
                            oChild.SetProperty("U_Noidung", r["DetailsName"].ToString());
                            //GT
                            t = 0;
                            Double.TryParse(r["Gross_Total"].ToString(), out t);
                            oChild.SetProperty("U_GrossTotal", t);
                            //GT no VAT
                            t = 0;
                            Double.TryParse(r["Total"].ToString(), out t);
                            oChild.SetProperty("U_Total", t);
                        }
                    }
                }
                //Add Quy trinh duyet
                DataTable rs2 = Get_Approve_Process_BILLVP();
                if (rs2.Rows.Count > 0)
                {
                    oChildren = oGeneralData.Child("BILLVP2");
                    foreach (DataRow r in rs2.Rows)
                    {
                        oChild = oChildren.Add();
                        oChild.SetProperty("U_Level", r["LEVEL"].ToString());
                        oChild.SetProperty("U_Position", r["Position"].ToString());
                        oChild.SetProperty("U_DeptName", r["DeptName"].ToString());
                        oChild.SetProperty("U_PosName", r["PosName"].ToString());
                    }
                }
                //Add UDO
                oGeneralParams = oGeneralService.Add(oGeneralData);
                if (!string.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
                {
                    oApp.SetStatusBarMessage("Add Completed - DocEntry: " + oGeneralParams.GetProperty("DocEntry").ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    Load_Grid_Period(BpCode, ComboBox0.Selected.Value);
                    CheckBox0.Checked = false;
                }
            }
            catch (Exception ex)
            {
                oApp.MessageBox(ex.Message, 1, "OK");
            }
        }
Beispiel #15
0
        public string SPA_AddPropertyEnquiry(DataTable dtDatatable)
        {
            string sFuncName     = string.Empty;
            string sReturnResult = string.Empty;
            //int sCode = 1;
            string sCode = string.Empty;

            try
            {
                sFuncName = "SPA_AddPropertyEnquiry";

                DataTable     results = new DataTable();
                SqlConnection con     = new SqlConnection(ConnectionString);
                SqlCommand    command = con.CreateCommand();
                //command.CommandText = "select Count(CODE) from [@AE_PROPERTY]";
                command.CommandText = "SELECT REPLICATE('0', (12-LEN(ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)))) " +
                                      " + CONVERT(VARCHAR, ISNULL(MAX(SUBSTRING(Code,4,LEN(Code)))+1,1)) [Code] FROM [@AE_PROPERTY] WITH (NOLOCK)";
                con.Open();

                SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
                dataAdapter.Fill(results);

                if (results.Rows[0][0].ToString().Length > 0)
                {
                    //sCode = Convert.ToInt32(results.Rows[0][0].ToString()) + 1;
                    sCode = results.Rows[0][0].ToString();
                }

                con.Close();

                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToDebugLogFile("Connecting to target company ", sFuncName);
                }
                oDICompany = oLogin.ConnectToTargetCompany(ConnectionString);

                SAPbobsCOM.GeneralService oGeneralService = null;
                SAPbobsCOM.GeneralData    oGeneralData;
                SAPbobsCOM.CompanyService oCompanyService = oDICompany.GetCompanyService();
                oGeneralService = oCompanyService.GetGeneralService("PROPERTY");

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

                //Adding the Informations
                oGeneralData.SetProperty("Code", sCode.ToString());
                oGeneralData.SetProperty("U_TITLETYPE", dtDatatable.Rows[0]["TITLETYPE"].ToString());
                oGeneralData.SetProperty("U_TITLENO", dtDatatable.Rows[0]["TITLENO"].ToString());
                oGeneralData.SetProperty("U_LOTTYPE", dtDatatable.Rows[0]["LOTTYPE"].ToString());
                oGeneralData.SetProperty("U_LOTNO", dtDatatable.Rows[0]["LOTNO"].ToString());
                oGeneralData.SetProperty("U_FORMERLY_KNOWN_AS", dtDatatable.Rows[0]["FORMERLY_KNOWN_AS"].ToString());
                oGeneralData.SetProperty("U_BPM", dtDatatable.Rows[0]["BPM"].ToString());
                oGeneralData.SetProperty("U_STATE", dtDatatable.Rows[0]["STATE"].ToString());
                oGeneralData.SetProperty("U_AREA", dtDatatable.Rows[0]["AREA"].ToString());
                oGeneralData.SetProperty("U_LOTAREA", dtDatatable.Rows[0]["LOTAREA"].ToString());
                //oGeneralData.SetProperty("U_LASTUPDATEDON", dtDatatable.Rows[0]["LASTUPDATEDON"].ToString());
                oGeneralData.SetProperty("U_DEVELOPER", dtDatatable.Rows[0]["DEVELOPER"].ToString());
                oGeneralData.SetProperty("U_DVLPR_CODE", dtDatatable.Rows[0]["DVLPR_CODE"].ToString());
                oGeneralData.SetProperty("U_PROJECT_CODE", dtDatatable.Rows[0]["PROJECT_CODE"].ToString());
                oGeneralData.SetProperty("U_PROJECTNAME", dtDatatable.Rows[0]["PROJECTNAME"].ToString());
                if (dtDatatable.Rows[0]["DEVLICNO"].ToString() != strSelect.ToString())
                {
                    oGeneralData.SetProperty("U_DEVLICNO", dtDatatable.Rows[0]["DEVLICNO"].ToString());
                }
                oGeneralData.SetProperty("U_DEVSOLICTOR", dtDatatable.Rows[0]["DEVSOLICTOR"].ToString());
                oGeneralData.SetProperty("U_DVLPR_SOL_CODE", dtDatatable.Rows[0]["DVLPR_SOL_CODE"].ToString());
                oGeneralData.SetProperty("U_DVLPR_LOC", dtDatatable.Rows[0]["DVLPR_LOC"].ToString());
                oGeneralData.SetProperty("U_LSTCHG_BANKCODE", dtDatatable.Rows[0]["LSTCHG_BANKCODE"].ToString());
                oGeneralData.SetProperty("U_LSTCHG_BANKNAME", dtDatatable.Rows[0]["LSTCHG_BANKNAME"].ToString());
                oGeneralData.SetProperty("U_LSTCHG_BRANCH", dtDatatable.Rows[0]["LSTCHG_BRANCH"].ToString());
                oGeneralData.SetProperty("U_LSTCHG_PANO", dtDatatable.Rows[0]["LSTCHG_PANO"].ToString());
                oGeneralData.SetProperty("U_LSTCHG_PRSTNO", dtDatatable.Rows[0]["LSTCHG_PRSTNO"].ToString());
                if (dtDatatable.Rows[0]["PROPERTYCHARGED"].ToString() == "Y")
                {
                    oGeneralData.SetProperty("U_PROPERTY_CHARGED", "Y");
                    oGeneralData.SetProperty("U_PROPERTY_FREE", "N");
                }
                else
                {
                    oGeneralData.SetProperty("U_PROPERTY_CHARGED", "N");
                    oGeneralData.SetProperty("U_PROPERTY_FREE", "Y");
                }
                oGeneralService.Add(oGeneralData);

                sReturnResult = "SUCCESS";
            }
            catch (Exception Ex)
            {
                sErrDesc = Ex.Message.ToString();
                oLog.WriteToErrorLogFile(sErrDesc, sFuncName);
                if (p_iDebugMode == DEBUG_ON)
                {
                    oLog.WriteToDebugLogFile("Completed With ERROR  ", sFuncName);
                }
                throw Ex;
            }

            return(sReturnResult);
        }
Beispiel #16
0
        static public void loadGenericUDO()
        {
            SAPbobsCOM.CompanyService objCompanyService = null;
            SAPbobsCOM.GeneralService UDOService        = null;
            SAPbobsCOM.GeneralData    headerInfo        = null;

            SAPbobsCOM.GeneralDataParams       oResult = null;
            SAPbobsCOM.GeneralCollectionParams objList = null;
            XmlDocument oXMLLod = new XmlDocument();

            try
            {
                if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\AutomaticLoad.xml"))
                {
                    oXMLLod.Load(AppDomain.CurrentDomain.BaseDirectory + "LoadData\\AutomaticLoad.xml");
                    XmlNodeList oList = oXMLLod.SelectNodes("/LoadFiles/File");
                    if (oList != null && oList.Count > 0)
                    {
                        foreach (XmlNode oFileNode in oList)
                        {
                            string strFilePath = oFileNode.SelectSingleNode("definition/location").InnerText;
                            string strUDOName  = oFileNode.SelectSingleNode("definition/UDO").InnerText;

                            objCompanyService = MainObject.Instance.B1Company.GetCompanyService();
                            UDOService        = objCompanyService.GetGeneralService(strUDOName);
                            headerInfo        = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                            try
                            {
                                objList = UDOService.GetList();
                            }

                            catch (COMException comEx)
                            {
                                if (comEx.ErrorCode == -2028)
                                {
                                    objList = null;
                                    _Logger.Error("The UDO with name " + strUDOName + " was not found");
                                }
                            }
                            catch (Exception er)
                            {
                                _Logger.Error("", er);
                                objList = null;
                            }

                            using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + strFilePath))
                            {
                                while (!sr.EndOfStream)
                                {
                                    string   strLine   = sr.ReadLine();
                                    string[] strResult = strLine.Split('|');
                                    bool     runAdd    = false;

                                    string strCode = "";

                                    for (int i = 0; i < strResult.Length; i++)
                                    {
                                        string strPropertyName = oFileNode.SelectSingleNode("mapping/column[@index='" + i.ToString() + "']") != null?oFileNode.SelectSingleNode("mapping/column[@index='" + i.ToString() + "']/@property").InnerText : "";

                                        if (i == 0)
                                        {
                                            oResult = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams);
                                            strCode = strResult[i];
                                            oResult.SetProperty("Code", strResult[i]);
                                            try
                                            {
                                                headerInfo = UDOService.GetByParams(oResult);
                                            }
                                            catch (COMException comEx)
                                            {
                                                if (comEx.ErrorCode == -2028)
                                                {
                                                    runAdd     = true;
                                                    headerInfo = UDOService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData);
                                                    headerInfo.SetProperty("Code", strResult[i].Trim());
                                                }
                                                else
                                                {
                                                    headerInfo = null;
                                                }
                                            }
                                            catch (Exception er)
                                            {
                                                _Logger.Error("", er);
                                                headerInfo = null;
                                            }
                                        }
                                        else
                                        {
                                            if (strPropertyName.Trim().Length > 0 && headerInfo != null)
                                            {
                                                headerInfo.SetProperty(strPropertyName, strResult[i].Trim());
                                            }
                                        }
                                    }
                                    if (runAdd)
                                    {
                                        oResult = UDOService.Add(headerInfo);
                                        _Logger.Info(strCode + " added OK");
                                    }
                                    else
                                    {
                                        try
                                        {
                                            UDOService.Update(headerInfo);
                                            _Logger.Info(strCode + " updated OK");
                                        }
                                        catch (COMException comEx)
                                        {
                                            _Logger.Error("Could not update value " + strCode + " of UDO " + strUDOName, comEx);
                                        }
                                        catch (Exception er)
                                        {
                                            _Logger.Error("Could not update value " + strCode + " of UDO " + strUDOName, er);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }