コード例 #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);
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
ファイル: B1_UDO.cs プロジェクト: Fun33/code
       /// <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); 
            }
        }
コード例 #6
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);
                }
            }
        }
コード例 #7
0
ファイル: Operations.cs プロジェクト: andresramirez12/T1B1
        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);
            }
        }