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

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

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

                    oGeneralService.Add(oGeneralData);
                }

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

                throw e;
            }
        }
예제 #2
0
파일: ObjectDAO.cs 프로젝트: xavl369/UGRS
        /// <summary> Adds pObjRecord. </summary>
        /// <remarks> Ranaya, 26/05/2017. </remarks>
        /// <exception cref="TableException"> Thrown when a Table error condition occurs. </exception>
        /// <param name="pObjRecord"> The Object record to add. </param>

        public void Add(T pObjRecord)
        {
            SAPbobsCOM.GeneralService    lObjGeneralService    = null;
            SAPbobsCOM.GeneralData       lObjGeneralData       = null;
            SAPbobsCOM.GeneralDataParams lObjGeneralDataParams = null;
            SAPbobsCOM.CompanyService    lObjCompanyService    = null;

            try
            {
                //Initialize variables
                lObjCompanyService = DIApplication.Company.GetCompanyService();
                lObjGeneralService = lObjCompanyService.GetGeneralService(GetObjectCode());
                lObjGeneralData    = ((SAPbobsCOM.GeneralData)(lObjGeneralService.GetDataInterface(SAPbobsCOM.GeneralServiceDataInterfaces.gsGeneralData)));

                //Set data
                lObjGeneralData = PopulateGeneralData(lObjGeneralData, pObjRecord);

                //Add data
                lObjGeneralDataParams = lObjGeneralService.Add(lObjGeneralData);
            }
            catch (Exception e)
            {
                throw new TableException(e.Message, e);
            }
            finally
            {
                MemoryUtility.ReleaseComObject(lObjGeneralService, lObjGeneralData, lObjGeneralDataParams, lObjCompanyService);
            }
        }
예제 #3
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);
        }