Пример #1
0
        public static void formDataAddEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool blBubbleEvent)
        {
            if (objMediosMagneticos == null)
            {
                objMediosMagneticos = new Operations();
            }

            blBubbleEvent = true;
            try
            {
                if (BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == "133" &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD)
                {
                    //SelfWithholdingTax.addSelfWithHoldingTax(BusinessObjectInfo);
                }
            }
            catch (COMException COMException)
            {
                _Logger.Error("", COMException);
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
        }
Пример #2
0
        private static void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo oBusinessObjectInfo, out bool bBubbleEvent)
        {
            bBubbleEvent = true;

            try
            {
                foreach (var assembly in CommonFunctions.GetAssemblies(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "plugins")))
                {
                    foreach (Type type in Assembly.LoadFrom(assembly.FullName).GetTypes().Where(i => i.GetInterface("ISAPBusinessOne") != null))
                    {
                        try
                        {
                            ISAPBusinessOne pluginclass = (ISAPBusinessOne)Activator.CreateInstance(type);
                            pluginclass.SBO_Application_FormDataEvent(ref oBusinessObjectInfo, sbo_company, ref sbo_application, out bBubbleEvent, sessionId);
                            if (!bBubbleEvent)
                            {
                                return;
                            }
                        }
                        catch (Exception ex)
                        {
                            CommonFunctions.LogFile(LogFile, ex.ToString());
                            sbo_application.MessageBox(ex.Message);
                            //sbo_application.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                sbo_application.MessageBox(ex.Message);
            }
        }
        void __app_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try
            {
                if (BusinessObjectInfo.FormTypeEx == "CTIAMDC" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD && BusinessObjectInfo.BeforeAction == false)
                {
                    __Form = __app.Forms.GetForm("CTIAMDC", 0);
                    __Form.EnableMenu("1282", true);
                    //__Form.EnableMenu("1289", true);
                    __Form.Mode = SAPbouiCOM.BoFormMode.fm_VIEW_MODE;
                }

                if (BusinessObjectInfo.FormTypeEx == "CTIAMDC" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD && BusinessObjectInfo.ActionSuccess == true && BusinessObjectInfo.BeforeAction == false)
                {
                    __Form = __app.Forms.GetForm("CTIAMDC", 0);
                    __app.ActivateMenuItem("1289");
                }
            }
            catch (COMException e1)
            {
                __app.MessageBox(e1.Message, 0, "Ok", "", "");
            }
            catch (SqlException e1)
            {
                __app.MessageBox(e1.Message, 0, "Ok", "", "");
            }
            catch (Exception e1)
            {
                __app.MessageBox(e1.Message, 0, "Ok", "", "");
            }
        }
        public static void FacturaProveedores_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BOInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            //Muestra en las Ordenes de Compra (Pedidos Compras) los saldos correspondientes a los pagos relacionados realizados.
            if ((BOInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD) && !(BOInfo.BeforeAction))
            {
                try
                {
                    //oForm = Application.SBO_Application.Forms.Item(BOInfo.FormUID);
                    try
                    {
                        oDataTable = oForm.DataSources.DataTables.Item("DT_SQL");
                    }
                    catch (Exception)
                    {
                        Program.AbiertoDesdeEnlace = true;
                    }
                }

                catch
                {
                    // Application.SBO_Application.MessageBox(ex.ToString(), 1, "Ok", "", "");
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Method for handling Form Data Event
        /// </summary>
        /// <param name="BusinessObjectInfo"></param>
        /// <param name="BubbleEvent"></param>
        static void FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;

            try
            {
                if ((BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD) && BusinessObjectInfo.BeforeAction == false)
                {
                    if (BusinessObjectInfo.FormTypeEx.ToString() == "UDO_FT_BUDGET")
                    {
                        ManageSeries    series = new ManageSeries();
                        SAPbouiCOM.Form oForm  = PublicVariable.oApplication.Forms.ActiveForm;
                        series.Enable(oForm, "20_U_Cb", "@BUDGET", "1_U_E");
                        Budget_FormEventHandler.LoadCopyToList(oForm);
                        Budget_FormEventHandler.LoadDefaults(oForm);
                        oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE;
                    }
                }
            }
            catch (Exception ex)
            {
                App_StatusBarEvent(
                    ex.Message
                    , SAPbouiCOM.BoMessageTime.bmt_Short
                    , SAPbouiCOM.BoStatusBarMessageType.smt_Warning);
            }
        }
Пример #6
0
        private void oApplication_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo oBusinessInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            SAPbouiCOM.Form oForm = null;
            try
            {
                //  oForm = oApplication.Forms.GetForm(oBusinessInfo.FormTypeEx, 0);
                oForm = oApplication.Forms.Item(oBusinessInfo.FormUID);



                // Stock Transfer Shipment
                if (oBusinessInfo.FormTypeEx == "EJ_OSTS")
                {
                    WarehouseTransfer.Inventory.clsStockShipment.clsStockShipment_FormDataEvent(ref oApplication, ref oCompany, oForm, ref oBusinessInfo, ref BubbleEvent);
                }

                // Stock Transfer Receipt
                if (oBusinessInfo.FormTypeEx == "EJ_OSTR")
                {
                    WarehouseTransfer.Inventory.clsStockReceipt.clsStockReceipt_FormDataEvent(ref oApplication, ref oCompany, oForm, ref oBusinessInfo, ref BubbleEvent);
                }
            }
            catch (Exception ex)
            { MessageBox.Show(ex.Message + "\n" + oCompany.GetLastErrorDescription(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
 private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     if (selectedGoodsIssue != null)
     {
         //Update the Flag in the Good Issue Flag
         updateGoodsIssueTransferedFlag(selectedGoodsIssue);
     }
 }
        static void SBO_Application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BOInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.Item(BOInfo.FormUID);
            try
            {
                if ((BOInfo.FormTypeEx == "142"))
                {
                    OrdenCompra.OrdenCompra_FormDataEvent(ref BOInfo, out BubbleEvent);
                }

                if ((BOInfo.FormTypeEx == "141"))
                {
                    FacturaProveedores.FacturaProveedores_FormDataEvent(ref BOInfo, out BubbleEvent);
                }

                int ObjN = Convert.ToInt32(BOInfo.Type);
                //Bloquear o Habilitar Campos de Fechas en la ventanas de UDF en los documentos de Marketing segun iFormularios
                if ((BOInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD) && BOInfo.BeforeAction && Array.Exists(iFormularios, element => element == ObjN))
                {
                    string[] U_Campos = { "U_MIN_FechaVenta", "U_MIN_FinMontaje", "U_MIN_FinDesarr", "U_MIN_FinProduccion", "U_MIN_IniDespacho", "U_MIN_IniMontaje", "U_MIN_FinMontaje", "U_MIN_FechaMulta" };
                    try
                    {
                        oForm = Application.SBO_Application.Forms.GetForm("-" + BOInfo.FormTypeEx, 1);// Item(BOInfo.FormUID);
                        SAPbouiCOM.EditText oEdit;

                        if (Funciones.ConsultaUsuario == false)
                        {
                            SAPbouiCOM.DataTable oDataTable = null;
                            if (!Funciones.DataTableExists(oForm, "DT_SQL"))
                            {
                                oForm.DataSources.DataTables.Add("DT_SQL");
                            }
                            oDataTable = oForm.DataSources.DataTables.Item("DT_SQL");

                            Funciones.IdentificarAccesoUsuario(oDataTable);
                        }

                        foreach (string element in U_Campos)
                        {
                            if (Funciones.ItemExists(oForm, element))
                            {
                                oEdit = (SAPbouiCOM.EditText)oForm.Items.Item(element).Specific;
                                if (oEdit.Item.Enabled == Funciones.Habilitado) // Verifica si ya estan condicionados los campos para no volver a ejecutar el proceso en la pantalla activa
                                {
                                    break;
                                }
                                oEdit.Item.Enabled = Funciones.Habilitado;
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception) { }
        }
Пример #9
0
        private void Form_DataLoadAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
        {
            DataTable rs = Load_Data_KLTT();

            if (rs.Rows.Count == 1)
            {
                double tmp = 0;
                double.TryParse(rs.Rows[0]["SUM_CA_NOVAT"].ToString(), out tmp);
                EditText0.Value = tmp.ToString("N2");
            }
        }
 private void Form_DataUpdateAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     try
     {
         oForm.Freeze(true);
         Matrix0.Columns.Item("Col_2").Editable = false;
         LoadDataMatrix();
     }
     catch (Exception) { }
     finally { oForm.Freeze(false); }
 }
        private void Form_DataUpdateBefore(ref SAPbouiCOM.BusinessObjectInfo pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            SAPbouiCOM.DBDataSource oDBDataSource = oForm.DataSources.DBDataSources.Item("@Z_COMI_COMGRP");

            var ValidaNuevoReg = oDBDataSource.GetValue("U_Codigo", oDBDataSource.Size - 1);

            if (ValidaNuevoReg.Trim().Length == 0)
            {
                oDBDataSource.RemoveRecord(oDBDataSource.Size - 1);
            }
        }
Пример #12
0
        private void Form_DataLoadAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
        {
            //throw new System.NotImplementedException();
            //EditText0.Value = "1999";
            DataTable rs = Load_Data_KLTT();

            if (rs.Rows.Count == 1)
            {
                double tmp = 0;
                double.TryParse(rs.Rows[0]["SUM_CA_NOVAT"].ToString(), out tmp);
                EditText0.Value = tmp.ToString("N2");
            }
        }
Пример #13
0
 private void Form_DataLoadAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     //throw new System.NotImplementedException();
     try
     {
         this.UIAPIRawForm.PaneLevel = 1;
         SAPbouiCOM.Matrix oMtx_S = ((SAPbouiCOM.Matrix) this.GetItem("0_U_G").Specific);
         Visible_Column_Matrix(oMtx_S, int.Parse(this.ComboBox0.Selected.Value));
         SAPbouiCOM.Matrix oMtx_D = ((SAPbouiCOM.Matrix) this.GetItem("1_U_G").Specific);
         Visible_Column_Matrix(oMtx_D, int.Parse(this.ComboBox0.Selected.Value));
     }
     catch { }
     finally { }
 }
        public static ItemEvent ToBusinessObjectInfo(this SAPbouiCOM.BusinessObjectInfo pBO)
        {
            ItemEvent myEvent = new ItemEvent();

            myEvent.ActionSuccess      = pBO.ActionSuccess;
            myEvent.BeforeAction       = pBO.BeforeAction;
            myEvent.EventType          = pBO.EventType.ToEventType();
            myEvent.FormType           = pBO.FormTypeEx.To <Int32>();
            myEvent.FormTypeEx         = pBO.FormTypeEx;
            myEvent.FormUID            = pBO.FormUID;
            myEvent.ObjectKey          = pBO.ObjectKey;
            myEvent.BusinessObjectType = pBO.Type;
            myEvent.ItemUID            = string.Empty;
            return(myEvent);
        }
Пример #15
0
 /// <summary>
 /// Metodo para gestionar los eventos generados por las actividades en los datos.
 /// </summary>
 /// <param name="BusinessObjectInfo">Objeto con la informacion completa del evento</param>
 /// <param name="BubbleEvent">Indicador booleano para detener la cola de eventos generada</param>
 void m_SBO_Appl_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
 {
     BubbleEvent = true;
     try
     {
         /*switch (BusinessObjectInfo.FormTypeEx)
          * {
          *
          * }*/
     }
     catch (Exception ex)
     {
         Msj_Appl.Errores(14, "m_SBO_Appl_DataEvent() > Eventos_SBO.cs " + ex.Message);
     }
 }
Пример #16
0
        private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
        {
            if (((SAPbouiCOM.BusinessObjectInfo)pVal).ActionSuccess)
            {
                SAPbobsCOM.Company   oCom         = ((SAPbobsCOM.Company)(Application.SBO_Application.Company.GetDICompany()));
                SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oR_RecordSet.DoQuery("Select * from [@ADDONCFG]");
                string uid = oR_RecordSet.Fields.Item("Code").Value.ToString();
                string pwd = oR_RecordSet.Fields.Item("Name").Value.ToString();
                //Get ObjectKey has created
                if (!string.IsNullOrEmpty(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey))
                {
                    XmlDocument xmldoc = new XmlDocument();
                    xmldoc.LoadXml(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey);
                    XmlNodeList nodeList   = xmldoc.GetElementsByTagName("DocEntry");
                    string      Object_Key = string.Empty;
                    if (nodeList.Count > 0)
                    {
                        Object_Key = nodeList.Item(0).InnerText;
                    }

                    SqlConnection conn = new SqlConnection(string.Format("Data Source={0}; Initial Catalog={1}; User id={2}; Password={3};", oCom.Server, oCom.CompanyDB, uid, pwd));
                    SqlCommand    cmd  = new SqlCommand("DeleteJournalEntry_InventoryPosting", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DocNum", Object_Key);
                    try
                    {
                        if (conn.State != ConnectionState.Open)
                        {
                            conn.Open();
                        }
                        cmd.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        Application.SBO_Application.MessageBox("Error when delete JournalEntry: " + ex.Message);
                    }
                    finally
                    {
                        conn.Close();
                        cmd.Dispose();
                    }
                }
            }
        }
Пример #17
0
        private void OApplication_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;
            DataRow NewRow;
            int     i;

            NewRow = EventData.Tables[0].NewRow();
            i      = EventData.Tables[0].Rows.Count;

            NewRow[0] = BusinessObjectInfo.ActionSuccess.ToString();
            NewRow[1] = BusinessObjectInfo.BeforeAction.ToString();
            NewRow[2] = BusinessObjectInfo.EventType.ToString();
            NewRow[3] = BusinessObjectInfo.FormTypeEx.ToString();
            NewRow[4] = BusinessObjectInfo.FormUID.ToString();
            NewRow[5] = BusinessObjectInfo.ObjectKey.ToString();
            NewRow[6] = BusinessObjectInfo.Type.ToString();

            EventData.Tables[0].Rows.Add(NewRow);
        }
Пример #18
0
 private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     try
     {
         var ccc = B1Helper.DiCompany.GetNewObjectKey();
         System.Xml.XmlDocument oXmlDoc = new System.Xml.XmlDocument();
         oXmlDoc.LoadXml(pVal.ObjectKey);
         var udoCode = oXmlDoc.SelectSingleNode("//UDO_ItemsTransferParams/DocEntry").InnerText;
         AddonInfoInfo.TransferItemsProcess(Application.SBO_Application, udoCode, SelectedBatchDataSources, SelectedRecBatchDataSources, issTransferItemsList, recTransferItemsList);
     }
     catch (Exception ex)
     {
         Utilities.LogException(ex);
     }
     finally
     {
         ClearListsContents();
         BatchesManaged = null;
     }
 }
Пример #19
0
        void AppSAP_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo businessObjectInfo, out bool bubbleEvent)
        {
            bubbleEvent = true;

            var formUID = businessObjectInfo.FormUID;

            var formOpen = FormOpens.FirstOrDefault(c => c.FormBind.UniqueID == formUID);

            if (formOpen != null)
            {
                try
                {
                    var item = businessObjectInfo.ToBusinessObjectInfo();
                    formOpen.DoEvent(item, out bubbleEvent);
                }
                catch (Exception ex)
                {
                    bubbleEvent = false;
                    Application.GetInstance().SetTextOnStatusBar(ex.InnerException.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error);
                }
            }
        }
Пример #20
0
        private void Form_DataDeleteBefore(ref SAPbouiCOM.BusinessObjectInfo pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            //Get ObjectKey has created
            XmlDocument xmldoc = new XmlDocument();

            xmldoc.LoadXml(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey.Replace("Khối lượng thanh toán", "KLTT"));
            XmlNodeList nodeList   = xmldoc.GetElementsByTagName("DocEntry");
            string      Object_Key = string.Empty;

            if (nodeList.Count > 0)
            {
                Object_Key = nodeList.Item(0).InnerText;
            }
            int DocEntry = 0;

            int.TryParse(Object_Key, out DocEntry);
            if (Check_Approve_KLTT(DocEntry))
            {
                oApp.SetStatusBarMessage("Bill was approved ! Delete failed !", SAPbouiCOM.BoMessageTime.bmt_Medium, true);
                BubbleEvent = false;
            }
        }
Пример #21
0
 public bool HandleFormDataEvents(SAPbouiCOM.BusinessObjectInfo oBusinessObjectInfo)
 {
     return(true);
 }
Пример #22
0
 private void Form_DataUpdateBefore(ref SAPbouiCOM.BusinessObjectInfo pVal, out bool BubbleEvent)
 {
     BubbleEvent = true;
     throw new System.NotImplementedException();
 }
Пример #23
0
 private void Form_DataLoadAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     //throw new System.NotImplementedException();
     this.GetItem("U_TYPE").Enabled = false;
 }
Пример #24
0
 private void Form_DataUpdateBefore(ref SAPbouiCOM.BusinessObjectInfo pVal, out bool BubbleEvent)
 {
     BubbleEvent = true;
     oApp.MessageBox("Update Event");
 }
Пример #25
0
        private void Form_DataAddAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
        {
            if (((SAPbouiCOM.BusinessObjectInfo)pVal).ActionSuccess)
            {
                SAPbobsCOM.Company   oCom         = ((SAPbobsCOM.Company)(Application.SBO_Application.Company.GetDICompany()));
                SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                oR_RecordSet.DoQuery("Select * from [@ADDONCFG]");
                string uid = oR_RecordSet.Fields.Item("Code").Value.ToString();
                string pwd = oR_RecordSet.Fields.Item("Name").Value.ToString();

                //Get ObjectKey has created
                XmlDocument xmldoc = new XmlDocument();
                xmldoc.LoadXml(((SAPbouiCOM.BusinessObjectInfo)pVal).ObjectKey);
                XmlNodeList nodeList   = xmldoc.GetElementsByTagName("DocEntry");
                string      Object_Key = string.Empty;
                if (nodeList.Count > 0)
                {
                    Object_Key = nodeList.Item(0).InnerText;
                }

                SqlCommand    cmd  = null;
                SqlConnection conn = new SqlConnection(string.Format("Data Source={0}; Initial Catalog={1}; User id={2}; Password={3};", oCom.Server, oCom.CompanyDB, uid, pwd));

                //Delete JournalEntry GoodsReceipt PO
                try
                {
                    cmd             = new SqlCommand("DeleteJournalEntry_GoodReceiptPO", conn);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@DocNum", Object_Key);
                    conn.Open();
                    cmd.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    Application.SBO_Application.MessageBox("Delete JournalEntry GoodsReceipt PO Error: " + ex.Message);
                }
                finally
                {
                    conn.Close();
                    cmd.Dispose();
                }

                //Get Info From Goods Receipt PO by UI
                SAPbouiCOM.Form       oForm           = Application.SBO_Application.Forms.ActiveForm;
                string                p_post_date     = ((SAPbouiCOM.EditText)oForm.Items.Item("10").Specific).Value;
                string                p_document_date = ((SAPbouiCOM.EditText)oForm.Items.Item("46").Specific).Value;
                List <Inventory_Item> Inven_Lst       = new List <Inventory_Item>();
                oForm.Freeze(true);
                oForm.PaneLevel = 1;
                try
                {
                    SAPbouiCOM.Matrix oMtx = ((SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific);
                    for (int i = 1; i <= oMtx.RowCount; i++)
                    {
                        if (!String.IsNullOrEmpty(((SAPbouiCOM.EditText)oMtx.Columns.Item(3).Cells.Item(i).Specific).Value))
                        {
                            Inventory_Item tmp = new Inventory_Item();
                            tmp.Item_No = ((SAPbouiCOM.EditText)oMtx.Columns.Item(3).Cells.Item(i).Specific).Value;
                            double.TryParse(((SAPbouiCOM.EditText)oMtx.Columns.Item(13).Cells.Item(i).Specific).Value, out tmp.Quantity);
                            string tmp_unit_price = ((SAPbouiCOM.EditText)oMtx.Columns.Item(20).Cells.Item(i).Specific).Value.Replace(" VND", "");
                            if (!String.IsNullOrEmpty(tmp_unit_price))
                            {
                                double.TryParse(tmp_unit_price.Split(',')[0].Replace('.', ','), out tmp.Unitprice);
                            }
                            tmp.Whse = ((SAPbouiCOM.EditText)oMtx.Columns.Item(32).Cells.Item(i).Specific).Value;
                            Inven_Lst.Add(tmp);
                        }
                    }
                }
                catch
                { }
                finally
                {
                    oForm.Freeze(false);
                }

                //Using DI Create Goods Receipt
                SAPbobsCOM.Documents oGrp = (SAPbobsCOM.Documents)oCom.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInventoryGenEntry);
                oGrp.DocDate    = DateTime.ParseExact(p_document_date, "yyyyMMdd", CultureInfo.InvariantCulture);
                oGrp.TaxDate    = DateTime.ParseExact(p_post_date, "yyyyMMdd", CultureInfo.InvariantCulture);
                oGrp.Reference2 = Object_Key;
                int tmp_i            = 0;
                int FixedAsset_Count = 0;
                foreach (Inventory_Item t in Inven_Lst)
                {
                    tmp_i++;
                    //string str_query = string.Format("Select count(*) as IsFixedAsset from OITM where ItemCode in (Select U_FA from OITM where ItemCode = '{0}')and ItemType ='F'", t.Item_No);
                    string str_query = string.Format("Select a.ItemCode,a.U_FA,(Select b.ItemType from OITM b where b.ItemCode = a.U_FA) as ItemType, a.ItmsGrpCod,(Select b.ItmsGrpCod from OITM b where b.ItemCode = a.U_FA) as ItmsGrpCod_FA  from OITM a where a.U_FA = '{0}'", t.Item_No);
                    oR_RecordSet.DoQuery(str_query);
                    if (oR_RecordSet.RecordCount > 0)
                    {
                        if (oR_RecordSet.Fields.Item("ItemType").Value.ToString() == "F" &&
                            ((oR_RecordSet.Fields.Item("ItmsGrpCod").Value.ToString() == "103" &&
                              oR_RecordSet.Fields.Item("ItmsGrpCod_FA").Value.ToString() == "103") ||
                             (oR_RecordSet.Fields.Item("ItmsGrpCod").Value.ToString() == "105" &&
                              oR_RecordSet.Fields.Item("ItmsGrpCod_FA").Value.ToString() == "105")))
                        {
                            t.FixedAsset_ItemNo = oR_RecordSet.Fields.Item("ItemCode").Value.ToString();
                            if (!string.IsNullOrEmpty(t.FixedAsset_ItemNo))
                            {
                                oGrp.Lines.ItemCode      = t.FixedAsset_ItemNo;
                                oGrp.Lines.Quantity      = t.Quantity;
                                oGrp.Lines.UnitPrice     = 0;
                                oGrp.Lines.Price         = 0;
                                oGrp.Lines.WarehouseCode = t.Whse;
                                t.LineNum = FixedAsset_Count++;
                                if (tmp_i < Inven_Lst.Count)
                                {
                                    oGrp.Lines.Add();
                                }
                            }
                        }
                    }
                }
                if (FixedAsset_Count > 0)
                {
                    int RetVal = oGrp.Add();
                    if (RetVal == 0)
                    {
                        string New_Object_Key = oCom.GetNewObjectKey();
                        //Update Unit Price
                        cmd             = new SqlCommand();
                        cmd.CommandType = CommandType.Text;
                        double receipt_total = 0;

                        //Update IGN1 SQL
                        foreach (Inventory_Item t in Inven_Lst)
                        {
                            if (t.LineNum >= 0)
                            {
                                double tmp_sum = t.Unitprice * t.Quantity;
                                receipt_total += tmp_sum;
                                string update_IGN1_query = string.Format("Update IGN1 set Price={0},LineTotal={1},OpenSum={2},PriceBefDi={3},TotalSumSy={4},OpenSumSys={5},INMPrice={6},StockPrice={7},StockSum={8},StockSumSc={9} where DocEntry={10} and ItemCode='{11}' and LineNum={12};"
                                                                         , t.Unitprice, tmp_sum, tmp_sum, t.Unitprice, tmp_sum, tmp_sum, t.Unitprice, t.Unitprice, tmp_sum, tmp_sum, New_Object_Key, t.FixedAsset_ItemNo, t.LineNum);
                                cmd.CommandText += update_IGN1_query;
                            }
                        }

                        //Update OIGN SQL
                        string update_OIGN_query = string.Format("Update OIGN set DocTotal={0},DocTotalSy={1},Max1099={2} where DocEntry={3};", receipt_total, receipt_total, receipt_total, New_Object_Key);
                        cmd.CommandText += update_OIGN_query;

                        try
                        {
                            cmd.Connection = conn;
                            conn.Open();
                            cmd.ExecuteNonQuery();
                        }
                        catch (Exception ex)
                        {
                            Application.SBO_Application.MessageBox(string.Format("Addon: Error when update GoodsRecipt: {0}", ex.Message));
                        }
                        finally
                        {
                            conn.Close();
                            cmd.Dispose();
                        }
                    }
                    else
                    {
                        int    ErrCode;
                        string ErrMsg;
                        oCom.GetLastError(out ErrCode, out ErrMsg);
                        Application.SBO_Application.StatusBar.SetText(string.Format("Addon: Failed create Good Receipt from Good Receipt PO: {0}|{1}", ErrCode, ErrMsg), SAPbouiCOM.BoMessageTime.bmt_Medium, SAPbouiCOM.BoStatusBarMessageType.smt_Error);
                    }
                }
            }
        }
Пример #26
0
        public static void formDataAddEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool blBubbleEvent)
        {
            if (objReletadParties == null)
            {
                objReletadParties = new Operations();
            }

            blBubbleEvent = true;

            try
            {
                if (
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == Settings._Main.BPFormTypeEx &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD
                    )
                {
                    Instance.BYBRelatedPartiesFolderAdd(BusinessObjectInfo.FormUID);
                    Instance.getRelatedpartyInfo(BusinessObjectInfo);
                }

                if (
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == Settings._Main.BPFormTypeEx &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD
                    )
                {
                    Instance.addRelatedPartyInfo(BusinessObjectInfo);
                    Instance.cleanEditTexts(BusinessObjectInfo.FormUID);
                }
                if (
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == Settings._Main.BPFormTypeEx &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_UPDATE
                    )
                {
                    Instance.updateRelatedPartyInfo(BusinessObjectInfo);
                }

                if (
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.FormTypeEx == Settings._Main.BPFormTypeEx &&
                    !BusinessObjectInfo.BeforeAction &&
                    BusinessObjectInfo.ActionSuccess &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_DELETE
                    )
                {
                    Instance.deleteRelatedPartyInfo(BusinessObjectInfo);
                    Instance.cleanEditTexts(BusinessObjectInfo.FormUID);
                }
            }
            catch (COMException comEx)
            {
                Exception er = new Exception(Convert.ToString("COM Error::" + comEx.ErrorCode + "::" + comEx.Message + "::" + comEx.StackTrace));
                _Logger.Error("FormDataEvent Error", comEx);
            }
            catch (Exception er)
            {
                _Logger.Error("FormDataEvent Error", er);
            }
        }
 private void Form_DataUpdateAfter(ref SAPbouiCOM.BusinessObjectInfo pVal)
 {
     Habilita_Importacion_Anexos();
 }
Пример #28
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);
                     }
                 }
             }
         }
     }
 }
Пример #29
0
        private void ObjApplication_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
        {
            BubbleEvent = true;

            //SAPbobsCOM.Documents objInvoice = null;
            XmlDocument objMatrix = new XmlDocument();

            SAPbouiCOM.Form objForm = null;
            Dictionary <string, ItemInfo> objInfo = new Dictionary <string, ItemInfo>();

            SAPbouiCOM.Matrix objMatrixItem  = null;
            SAPbouiCOM.Item   objItem        = null;
            SAPbouiCOM.Item   objItemRemarks = null;

            try
            {
                if (
                    BusinessObjectInfo.FormTypeEx == "133" &&
                    BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD &&
                    BusinessObjectInfo.BeforeAction
                    )
                {
                    objForm        = MainObject.Instance.B1Application.Forms.Item(BusinessObjectInfo.FormUID);
                    objItem        = objForm.Items.Item("38");
                    objItemRemarks = objForm.Items.Item("16");
                    objMatrixItem  = objItem.Specific;
                    objMatrix.LoadXml(objMatrixItem.SerializeAsXML(SAPbouiCOM.BoMatrixXmlSelect.mxs_All));
                    XmlNodeList objNode = objMatrix.SelectNodes("/Matrix/Rows/Row[./Visible=1]/Columns/Column[./ID=1]/Value");
                    if (objNode.Count > 0)
                    {
                        #region Query Dimension per line
                        foreach (XmlNode xn in objNode)
                        {
                            string strItemCode = xn.InnerText;
                            #region Consulta

                            string strSQL = "select '18' as 'WhsCode','AdmGF' as 'Dim1','CompGVV' as 'Dim2','MercGVN' as 'Dim3', 'CompFIN' as 'Dim4' ";
                            SAPbobsCOM.Recordset objRec = MainObject.Instance.B1Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
                            objRec.DoQuery(strSQL);


                            #endregion Consulta


                            //Hacer la Busqueda para encontrar los centros de costo
                            ItemInfo objTemp = new ItemInfo();
                            objTemp.WareHouse  = objRec.Fields.Item("WhsCode").Value;
                            objTemp.Dimension1 = objRec.Fields.Item("Dim1").Value;
                            objTemp.Dimension2 = objRec.Fields.Item("Dim2").Value;
                            objTemp.Dimension3 = objRec.Fields.Item("Dim3").Value;
                            objTemp.Dimension4 = objRec.Fields.Item("Dim4").Value;

                            objInfo.Add(strItemCode, objTemp);
                        }
                        #endregion

                        objForm.Freeze(true);

                        int intVisualRowCount = objMatrixItem.RowCount;

                        for (int i = 1; i < intVisualRowCount; i++)
                        {
                            SAPbouiCOM.EditText oItem = objMatrixItem.Columns.Item("1").Cells.Item(i).Specific;
                            string   strItemCode      = oItem.Value;
                            ItemInfo oItm             = objInfo[strItemCode];

                            SAPbouiCOM.EditText oTemp = objMatrixItem.Columns.Item("110000310").Cells.Item(i).Specific;
                            oTemp.Value = oItm.Dimension1;

                            oTemp       = objMatrixItem.Columns.Item("10002039").Cells.Item(i).Specific;
                            oTemp.Value = oItm.Dimension2;
                            oTemp       = objMatrixItem.Columns.Item("10002041").Cells.Item(i).Specific;
                            oTemp.Value = oItm.Dimension3;
                            oTemp       = objMatrixItem.Columns.Item("10002043").Cells.Item(i).Specific;
                            oTemp.Value = oItm.Dimension4;
                        }

                        objForm.Freeze(false);



                        //for (int i =0; i < intVisualRowCount; i++)
                        //{
                        //    objMatrixItem.SetCellFocus(i,)


                        //        objInvoice.Lines.SetCurrentLine(i);
                        //    ItemInfo objTemp2 = objInfo[objInvoice.Lines.ItemCode];
                        //    objInvoice.Lines.CostingCode = objTemp2.Dimension1;
                        //    objInvoice.Lines.CostingCode2 = objTemp2.Dimension2;
                        //    objInvoice.Lines.CostingCode3 = objTemp2.Dimension3;
                        //    objInvoice.Lines.CostingCode4 = objTemp2.Dimension4;
                        //}

                        //int intRes = objInvoice.Update();

                        //string strMsg = MainObject.Instance.B1Company.GetLastErrorDescription();

                        //BubbleEvent = false;
                    }
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
            finally
            {
                if (objForm != null)
                {
                    objForm.Freeze(false);
                }
            }
        }
Пример #30
0
 void application_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent)
 {
     BubbleEvent = formOpen[BusinessObjectInfo.FormUID].HandleFormDataEvents(BusinessObjectInfo);
 }