Esempio n. 1
0
        //Alteração em tabela customizada por objeto, passar nome da tabela e coleção de parâmetros(Nome do campo e valor)
        protected bool Alterar(string nomeObjeto, string codigo, Dictionary <string, string> parametros)
        {
            bool retorno = false;

            try
            {
                oCompService    = oCompany.GetCompanyService();
                oGeneralService = oCompService.GetGeneralService(nomeObjeto);
                oGeneralParams  = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));

                //Recupera Objeto para alteração
                oGeneralParams.SetProperty("Code", codigo);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);

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

                    oGeneralService.Update(oGeneralData);
                }

                retorno = true;
            }
            catch (Exception e)
            {
                throw e;
            }

            return(retorno);
        }
Esempio n. 2
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. 3
0
        /// <summary> Populate user table. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <param name="pObjGeneralData"> The object user table. </param>
        /// <param name="pObjRecord">      The object record. </param>
        /// <returns> A SAPbobsCOM.UserTable. </returns>

        private SAPbobsCOM.GeneralData PopulateGeneralData(SAPbobsCOM.GeneralData pObjGeneralData, T pObjRecord)
        {
            foreach (PropertyInfo lObjProperty in pObjRecord.GetType().GetProperties().Where(x => x.GetMethod.IsPublic && !x.GetMethod.IsVirtual))
            {
                string lStrFieldName  = string.Format("U_{0}", lObjProperty.Name);
                object lUnkFieldValue = lObjProperty.GetType() == typeof(bool) ? ((bool)lObjProperty.GetValue(pObjRecord, null) ? "Y" : "N") : (lObjProperty.GetValue(pObjRecord, null));

                pObjGeneralData.SetProperty(lStrFieldName, lUnkFieldValue);
            }
            return(pObjGeneralData);
        }
        public static string UpdateRecordHead(string UDO_Name, Object Objeto, string CodigoObj)
        {
            SAPbobsCOM.GeneralService    oGeneralService = null;
            SAPbobsCOM.GeneralData       oGeneralData    = null;
            SAPbobsCOM.GeneralDataParams oGeneralParams  = null;
            SAPbobsCOM.CompanyService    sCmp            = null;
            SAPbobsCOM.Company           SBO_Company     = Conexion.oCompany;

            sCmp = SBO_Company.GetCompanyService();
            string rpta = "N";

            //  This function updates only parent record.
            //  Child records remain as is.
            try
            {
                // Get a handle UDO
                oGeneralService = sCmp.GetGeneralService(UDO_Name);
                // Get UDO record
                oGeneralParams = ((SAPbobsCOM.GeneralDataParams)(oGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralDataParams)));
                oGeneralParams.SetProperty("Code", CodigoObj);
                oGeneralData = oGeneralService.GetByParams(oGeneralParams);
                // Update UDO record
                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) { }
                }
                oGeneralService.Update(oGeneralData);
                rpta = "S";
            }
            catch (Exception) { }
            return(rpta);
        }
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 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);
        }