private void TableCreation()
        {
            try
            {
                ____bobCompany.StartTransaction();

                AddTables("AW_B1CZHDR", "B1 Customize Header", SAPbobsCOM.BoUTBTableType.bott_MasterData);
                AddTables("AW_B1CZDTL", "B1 Customize Rows", SAPbobsCOM.BoUTBTableType.bott_MasterDataLines);
                AddFields("@AW_B1CZHDR", "DocEntry", "DocEntry", SAPbobsCOM.BoFieldTypes.db_Numeric, SAPbobsCOM.BoFldSubTypes.st_None, 11, null, null, false, null);

                AddFields("@AW_B1CZDTL", "DocEntry", "DocEntry", SAPbobsCOM.BoFieldTypes.db_Numeric, SAPbobsCOM.BoFldSubTypes.st_None, 11, null, null, false, null);
                AddFields("@AW_B1CZDTL", "AsColNotes", "Collection Notes", SAPbobsCOM.BoFieldTypes.db_Memo, SAPbobsCOM.BoFldSubTypes.st_None, 254, null, null, false, null);
                AddFields("@AW_B1CZDTL", "UpdateDate", "Update Date", SAPbobsCOM.BoFieldTypes.db_Date, SAPbobsCOM.BoFldSubTypes.st_None, 12, null, null, false, null);

                if (-1 == RegisterObject("UDOB1CZHDR", "B1 Customize", "MD", "AW_B1CZHDR", "AW_B1CZDTL", false, false, false, true, true, false, false, "DocEntry", false, "", true))
                {
                    __app.StatusBar.SetText("Object Registration failed.....", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); return;
                }

                if (____bobCompany.InTransaction == true)
                {
                    ____bobCompany.EndTransaction(SAPbobsCOM.BoWfTransOpt.wf_Commit);
                }
            }
            catch (Exception ex)
            {
                __app.SetStatusBarMessage(ex.Message.ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, true);
            }
        }
        private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;

            oUserTable      = oCompany.UserTables.Item("SECCIONESCOL");
            oUserTable.Code = EditText0.Value.ToString();
            oUserTable.Name = EditText0.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_CodigoSEC").Value       = EditText0.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_NombreSEC").Value       = EditText1.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_SupraSeccionSEC").Value = EditText3.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_PrecioSEC").Value       = EditText2.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_ProyectoSEC").Value     = "";
            //oUserTable.Add();

            int i = oUserTable.Add();


            if (i != 0)
            {
                oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
            else
            {
                oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                oForm = oApp.Forms.Item("creasecc");
                oForm.Close();
            }
        }
Example #3
0
        public void Button2_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            try
            {
                if (oGrid.Rows.SelectedRows.Count > 0)   //VERIFICA QUE EXISTA UN ROW SELECCIONADO
                {
                    if (viejaSel != -1)
                    {
                        oGrid.CommonSetting.SetRowFontStyle(viejaSel, SAPbouiCOM.BoFontStyle.fs_Plain);
                    }

                    int nSelecRow = (oGrid.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder));
                    viejaSel = nSelecRow + 1;
                    //oApp.SetStatusBarMessage("El dato es " + oldSelection + nSelecRow);
                    //seleccion  el row y se destaca en negrita
                    oGrid.CommonSetting.SetRowFontStyle(nSelecRow + 1, SAPbouiCOM.BoFontStyle.fs_Bold);
                    sValorGrid = Convert.ToString(oGrid.DataTable.GetValue("Código", nSelecRow));

                    // Button0.Caption = "Update";
                    //if (Button0.Caption=="OK"){

                    Button0.Caption = "Update";

                    //    oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE;

                    //}
                }
            }
            catch (Exception)
            {
                oApp.SetStatusBarMessage("Error  en el boton:  " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, true);
            }
        }
Example #4
0
        private void Button2_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            //oApp = (SAPbouiCOM.Application)Application.SBO_Application;
            //oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany();

            oUserTable      = oCompany.UserTables.Item("EDICIONESCOL");
            oUserTable.Code = EditText4.Value.ToString();
            oUserTable.Name = EditText4.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value   = EditText4.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_NombreEDC").Value   = EditText7.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_ProyectoEDC").Value = EditText5.Value.ToString();
            //oUserTable.Add();

            int i = oUserTable.Add();


            if (i != 0)
            {
                oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
            else
            {
                oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                oForm = oApp.Forms.Item("fmcred");
                oForm.Close();
            }
        }
Example #5
0
        private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;


            oUserTable = oCompany.UserTables.Item("SECCIONESCOL");
            //hago un getbykey para obtener el valor key necesario para actualizar los datos
            if (oUserTable.GetByKey(EditText0.Value.ToString()))
            {
                // oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value = EditText0.Value.ToString();
                oUserTable.UserFields.Fields.Item("U_NombreSEC").Value = EditText1.Value.ToString();
            }
            oUserTable.UserFields.Fields.Item("U_SupraSeccionSEC").Value = EditText2.Value.ToString();
            oUserTable.UserFields.Fields.Item("U_PrecioSEC").Value       = EditText4.Value.ToString();


            //oUserTable.Update();


            int i = oUserTable.Update();

            //oApp.SetStatusBarMessage("valor"+ i);
            if (i != 0)
            {
                oApp.SetStatusBarMessage("Error en la actualización: " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
            else
            {
                oApp.SetStatusBarMessage("Exito en la actualizacón", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                //oForm = oApp.Forms.Item("fmacted");
                //oForm.Close();
            }
        }
        //private void OApplication_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent)
        //{
        //    throw;
        //}

        private void OApplication_MenuEvent(ref SAPbouiCOM.MenuEvent pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            if (pVal.BeforeAction)
            {
                oApplication.SetStatusBarMessage("Menu Item: " + pVal.MenuUID + "Enviou o evento ANTES do SAP B1 processa-lo",
                                                 SAPbouiCOM.BoMessageTime.bmt_Long, true);
            }
            else
            {
                oApplication.SetStatusBarMessage("Menu Item: " + pVal.MenuUID + "Enviou o evento DEPOIS do SAP B1 processa-lo!",
                                                 SAPbouiCOM.BoMessageTime.bmt_Long, true);
            }
        }
Example #7
0
        //Approve Button
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            if (DocEntry_ODRF > 0)
            {
                SAPbobsCOM.ApprovalRequestsService oApprovalRequestsService = (SAPbobsCOM.ApprovalRequestsService)oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.ApprovalRequestsService);
                SAPbobsCOM.ApprovalRequestsParams  oApprovalRequestsParams  = (SAPbobsCOM.ApprovalRequestsParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestsParams);
                SAPbobsCOM.ApprovalRequest         oApprovalRequest         = (SAPbobsCOM.ApprovalRequest)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequest);
                SAPbobsCOM.ApprovalRequestParams   oApprovalRequestParams   = (SAPbobsCOM.ApprovalRequestParams)oApprovalRequestsService.GetDataInterface(SAPbobsCOM.ApprovalRequestsServiceDataInterfaces.arsApprovalRequestParams);

                oApprovalRequestParams.Code = WddCode;

                //Approve request
                oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams);
                oApprovalRequest.ApprovalRequestDecisions.Add();
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Remarks = EditText0.Value;
                oApprovalRequest.ApprovalRequestDecisions.Item(0).Status  = SAPbobsCOM.BoApprovalRequestDecisionEnum.ardApproved;
                try
                {
                    oApprovalRequestsService.UpdateRequest(oApprovalRequest);
                    oApp.MessageBox("Phê duyệt thành công");
                    oApprovalRequest = oApprovalRequestsService.GetApprovalRequest(oApprovalRequestParams);
                    if (oApprovalRequest.Status == SAPbobsCOM.BoApprovalRequestStatusEnum.arsApproved)
                    {
                        try
                        {
                            //Approved Document Add to Valid Document
                            SAPbobsCOM.Documents oDraft = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oDrafts);
                            oDraft.GetByKey(oApprovalRequest.ObjectEntry);
                            int ErrorCode = oDraft.SaveDraftToDocument();
                            if (ErrorCode == 0)
                            {
                                oApp.SetStatusBarMessage("Document added successfully", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                            }
                            else
                            {
                                oApp.SetStatusBarMessage(ErrorCode.ToString() + "|" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, true);
                            }
                        }
                        catch
                        {
                        }
                    }
                }
                catch (Exception ex)
                {
                    oApp.MessageBox("Phê duyệt không thành công |" + ex.Message);
                }
            }
        }
Example #8
0
 private void OnCustomInitialize()
 {
     this.CheckBox0.ValOff = "0";
     this.CheckBox0.ValOn  = "1";
     this.oApp             = (SAPbouiCOM.Application)SAPbouiCOM.Framework.Application.SBO_Application;
     this.oCompany         = (SAPbobsCOM.Company)oApp.Company.GetDICompany();
     //Create Connection SQL
     SAPbobsCOM.Recordset oR_RecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
     oR_RecordSet.DoQuery("Select * from [@ADDONCFG]");
     if (oR_RecordSet.RecordCount > 0)
     {
         string uid = oR_RecordSet.Fields.Item("Code").Value.ToString();
         string pwd = oR_RecordSet.Fields.Item("Name").Value.ToString();
         conn = new SqlConnection(string.Format("Data Source={0}; Initial Catalog={1}; User id={2}; Password={3};", oCompany.Server, oCompany.CompanyDB, uid, pwd));
     }
     else
     {
         oApp.MessageBox("Can't connect DB !");
     }
     //Get MenuUID KLTT
     MenuUID = Get_MenuUID_BILLVP();
     if (string.IsNullOrEmpty(MenuUID))
     {
         oApp.SetStatusBarMessage("Can't find MenuUID for BILLVP", SAPbouiCOM.BoMessageTime.bmt_Short, true);
     }
     Load_Financial_Project();
 }
Example #9
0
        /// <summary>
        /// Connect sap using UI API.
        /// </summary>
        /// <param name="connString">If you not define the string connection, the string connection will be default</param>
        public static void Connect(string connString = null)
        {
            try
            {
                SAPbouiCOM.SboGuiApi SboGuiApi = null;
                string sConnectionString       = null;

                SboGuiApi = new SAPbouiCOM.SboGuiApi();

                sConnectionString = connString ?? sap.ui.E.ConnString;
                SboGuiApi.Connect(sConnectionString);
                conn = SboGuiApi.GetApplication(-1);

                var debug = false;
#if DEBUG
                debug = true;
#endif

                if (R.DebugMode && !debug)
                {
                    conn.MessageBox("Addon is connected as debug mode.");
                }
                else
                {
                    conn.SetStatusBarMessage($"{R.CompanyName} addon is connected.", SAPbouiCOM.BoMessageTime.bmt_Short, false);
                }
            }
            catch (Exception ex)
            {
                k.Diagnostic.Error(LOG, ex);
                throw new Exception($"Error to connect SAP using DI UIAPI.", ex);
            }
        }
        public void SetApplication()
        {
            SAPbouiCOM.SboGuiApi SboGuiApi = null;
            string sConnectionString       = null;

            SboGuiApi         = new SAPbouiCOM.SboGuiApi();
            sConnectionString = System.Convert.ToString(Environment.GetCommandLineArgs().GetValue(1));
            // connect to a running SBO Application
            try
            {
                SboGuiApi.Connect(sConnectionString);
                // get an initialized application object
                SBO_Application = SboGuiApi.GetApplication();
                SBO_Application.SetStatusBarMessage("Se ha iniciado el Add-on de FE_DIAN", SAPbouiCOM.BoMessageTime.bmt_Short, false);

                oCompany = new SAPbobsCOM.Company();
                //get DI company (via UI)
                oCompany = (SAPbobsCOM.Company)SBO_Application.Company.GetDICompany();
            }
            catch (Exception ex)
            { //  Connection failed
                System.Windows.Forms.MessageBox.Show("Error al iniciar el Add-on de Youse" + ex.Message, "Error de conexión",
                                                     System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Error,
                                                     System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly);
                System.Environment.Exit(0);
            }
        }
        private void Button2_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;

            if (Grid0.Rows.SelectedRows.Count > 0)   //VERIFICA QUE EXISTA UN ROW SELECCIONADO
            {
                int    nSelecRow  = (Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder));
                String sValorGrid = Convert.ToString(Grid0.DataTable.GetValue("CÓDIGO", nSelecRow));
                // oApp.SetStatusBarMessage("codigo" + sValorGrid);
                actua_secc crear_form = new actua_secc(sValorGrid);
                crear_form.Show();
            }
            else
            {
                oApp.SetStatusBarMessage("Error, no has seleccionado una fila", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
        }
Example #12
0
 private void oApplication_AppEvent(SAPbouiCOM.BoAppEventTypes EventType)
 {
     if (EventType == SAPbouiCOM.BoAppEventTypes.aet_CompanyChanged || EventType == SAPbouiCOM.BoAppEventTypes.aet_LanguageChanged || EventType == SAPbouiCOM.BoAppEventTypes.aet_ServerTerminition || EventType == SAPbouiCOM.BoAppEventTypes.aet_ShutDown)
     {
         //string strFileName = (System.Windows.Forms.Application.StartupPath).ToString() + @"\" + "Remove Menus.xml";
         //clsSBO.LoadFromXML(ref strFileName, oApplication);
         oApplication.SetStatusBarMessage("eOrderEntry Addon Disconnected successfully - SAP", SAPbouiCOM.BoMessageTime.bmt_Short, false);
         GC.Collect();
         System.Windows.Forms.Application.Exit();
         TmpThread.Start();
     }
 }
Example #13
0
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;

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

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

            if (!string.IsNullOrEmpty(oGeneralParams.GetProperty("DocEntry").ToString()))
            {
                int BaseLine_DocEntry = 0;
                int.TryParse(oGeneralParams.GetProperty("DocEntry").ToString(), out BaseLine_DocEntry);
                //Add BaseLine Data
                Add_Data(BaseLine_DocEntry);
                oApp.SetStatusBarMessage("Add Completed - DocEntry: " + oGeneralParams.GetProperty("DocEntry").ToString(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                this.UIAPIRawForm.Close();
            }
        }
        private void SaveAsXML()
        {
            System.Xml.XmlDocument oXmlDoc = null;
            oXmlDoc = new System.Xml.XmlDocument();
            string sXmlString = null;

            sXmlString = oForm.GetAsXML();

            oXmlDoc.LoadXml(sXmlString);

            string sPath = null;

            sPath = System.IO.Directory.GetParent(Application.StartupPath).ToString();

            oXmlDoc.Save(sPath + @"\FormSimples.xml");

            oApplication.SetStatusBarMessage("Dir:" + sPath, SAPbouiCOM.BoMessageTime.bmt_Short, false);
        }
Example #15
0
        internal static void removeTable(UserTablesMD ut, string name, SAPbouiCOM.Application app,
                                         SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (ut.GetByKey(name))
            {
                ret = ut.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage("Error removing table " + name, SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage("Removed table " + name,
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
Example #16
0
        internal static void removeUDO(UserObjectsMD uo, string name,
                                       SAPbouiCOM.Application app, SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (uo.GetByKey(name))
            {
                ret = uo.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage(string.Format("Error removing object {0}", name),
                                            SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage(string.Format("Removed field {0}", name),
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
Example #17
0
        internal static void removeField(UserFieldsMD uf, string tableName, int fieldID,
                                         SAPbouiCOM.Application app, SAPbobsCOM.Company company)
        {
            int    ret;
            string errMsg;

            if (uf.GetByKey(tableName, fieldID))
            {
                ret = uf.Remove();
                if (ret != 0)
                {
                    company.GetLastError(out ret, out errMsg);
                    app.SetStatusBarMessage(string.Format("Error removing field {0}-{1}",
                                                          tableName, fieldID), SAPbouiCOM.BoMessageTime.bmt_Short, true);
                    throw new Exception(errMsg);
                }
                app.StatusBar.SetSystemMessage(string.Format("Removed field {0}-{1}",
                                                             tableName, fieldID),
                                               SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Success);
            }
        }
        public void crearForma()
        {
            //se comprueba que la forma no este creada para poder
            //crear una forma
            try
            {
                forma = app.Forms.Item("FSDC");
            }
            catch
            {
                // se carga el archivo desde el xml
                string xmlCargado = Config.getConfig().cargarDesdeXML("FSolicitud de compra.srf");
                app.LoadBatchActions(ref xmlCargado);
                forma = app.Forms.Item("FSDC");

                crearChooseFromList();
                llenarComboBox();
                setFecha();
                setMatrix();
                setImpuesto();

                // se posiciona el campo proveedor como
                // el primer campo activo de la forma
                forma.ActiveItem = "txtCodProv";

                // el browseby activa las flechas de navegacion
                // para navegar entre documentos ya procesados
                forma.DataBrowser.BrowseBy = "txtDcEntry";

                // se asigna el indice a la columna
                setColCount();
                forma.Visible = true;
                app.SetStatusBarMessage("Se inicializado del Add-On", SAPbouiCOM.BoMessageTime.bmt_Short, false);

                // se guarda el elemento xml
                Config.getConfig().guardarComoXML(forma.GetAsXML(), "FSolicitud de compra.xml");
            }
            app.ItemEvent += new SAPbouiCOM._IApplicationEvents_ItemEventEventHandler(app_ItemEvent);
        }
Example #19
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;
            }
        }
Example #20
0
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            //Thiet bi
            if (pVal.FormMode == 1)
            {
                //Get DATA SUM CCM
                int       DocEntry  = int.Parse(((SAPbouiCOM.EditText)(this.GetItem("0_U_E").Specific)).Value);
                string    Project   = ((SAPbouiCOM.EditText)(this.GetItem("20_U_E").Specific)).Value;
                DataTable Sum_DUTRU = Load_Data_DUTRU_TB(Project, DocEntry);

                oApp.ActivateMenuItem("DUTRU");
                SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.ActiveForm;
                //Get DocNum CTG
                try
                {
                    ((SAPbouiCOM.EditText)oForm.Items.Item("20_U_E").Specific).Value = DocEntry.ToString();
                    try
                    {
                        //Select Type DUTRU
                        ((SAPbouiCOM.ComboBox)oForm.Items.Item("21_U_Cb").Specific).Select("2", SAPbouiCOM.BoSearchKey.psk_ByValue);
                    }
                    catch (Exception ex)
                    {
                        oApp.MessageBox(ex.Message);
                    }
                    oForm.Freeze(true);
                    oForm.PaneLevel = 1;
                    SAPbouiCOM.Matrix oMtx = (SAPbouiCOM.Matrix)oForm.Items.Item("0_U_G").Specific;
                    for (int i = 0; i < Sum_DUTRU.Rows.Count; i++)
                    {
                        oApp.SetStatusBarMessage(string.Format("Creating DUTRU TB: {0}", (i + 1) + "/" + Sum_DUTRU.Rows.Count), SAPbouiCOM.BoMessageTime.bmt_Short, false);
                        DataRow r = Sum_DUTRU.Rows[i];
                        //Subproject Code
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_2").Cells.Item(i + 1).Specific).Value = r["High_Level_SUM"].ToString();
                        //Subproject Description
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_3").Cells.Item(i + 1).Specific).Value = r["High_Level_Name"].ToString();
                        //CP Mua ban
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_8").Cells.Item(i + 1).Specific).Value = r["CP_MB"].ToString();
                        //CP Thue
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_9").Cells.Item(i + 1).Specific).Value = r["CP_THUE"].ToString();
                        //CP Van hanh
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_10").Cells.Item(i + 1).Specific).Value = r["CP_VH"].ToString();
                        //CP VC
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_11").Cells.Item(i + 1).Specific).Value = r["CP_VC"].ToString();

                        if (i < Sum_DUTRU.Rows.Count - 1)
                        {
                            oMtx.AddRow();
                            ((SAPbouiCOM.EditText)oMtx.Columns.Item(1).Cells.Item(i + 2).Specific).Value = (i + 2).ToString();
                        }
                    }
                    oForm.Freeze(false);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    oForm.Freeze(false);
                }
            }
            else
            {
                Application.SBO_Application.MessageBox("Function works only on View Mode");
            }
        }
Example #21
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);
                     }
                 }
             }
         }
     }
 }
Example #22
0
        //Add Button
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            SAPbobsCOM.GeneralService        oGeneralService = null;
            SAPbobsCOM.GeneralDataParams     oGeneralParams  = null;
            SAPbobsCOM.CompanyService        sCmp            = null;
            SAPbobsCOM.GeneralData           oGeneralData    = null;
            SAPbobsCOM.GeneralData           oChild          = null;
            SAPbobsCOM.GeneralDataCollection oChildren       = null;
            try
            {
                BpCode = EditText0.Value;
                Get_BpName();

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

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

            SAPbouiCOM.Form oForm = oApp.Forms.ActiveForm;
            switch (oForm.Mode)
            {
            case SAPbouiCOM.BoFormMode.fm_ADD_MODE:

                oUserTable      = oCompany.UserTables.Item("EDICIONESCOL");
                oUserTable.Code = EditText0.Value.ToString();
                oUserTable.Name = EditText0.Value.ToString();
                oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value   = EditText0.Value.ToString();
                oUserTable.UserFields.Fields.Item("U_NombreEDC").Value   = EditText1.Value.ToString();
                oUserTable.UserFields.Fields.Item("U_ProyectoEDC").Value = EditText2.Value.ToString();
                oUserTable.Add();

                int i = oUserTable.Add();
                if (i != 0)
                {
                    oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                }
                else
                {
                    oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    oForm = oApp.Forms.Item("edm");
                    oForm.Close();
                }

                break;

            case SAPbouiCOM.BoFormMode.fm_UPDATE_MODE:

                oUserTable = oCompany.UserTables.Item("EDICIONESCOL");
                //hago un getbykey para obtener el valor key necesario para actualizar los datos
                if (oUserTable.GetByKey(EditText0.Value.ToString()))
                {
                    // oUserTable.UserFields.Fields.Item("U_CodigoEDC").Value = EditText0.Value.ToString();
                    oUserTable.UserFields.Fields.Item("U_NombreEDC").Value = EditText1.Value.ToString();
                }
                oUserTable.UserFields.Fields.Item("U_ProyectoEDC").Value = EditText2.Value.ToString();

                //oUserTable.Update();


                int J = oUserTable.Update();

                //oApp.SetStatusBarMessage("valor"+ i);
                if (J != 0)
                {
                    oApp.SetStatusBarMessage("Error en la actualización: " + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                }
                else
                {
                    oApp.SetStatusBarMessage("Exito en la actualizacón", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    //oForm = oApp.Forms.Item("fmacted");
                    //oForm.Close();
                }


                break;

            case SAPbouiCOM.BoFormMode.fm_FIND_MODE:



                break;
            }
        }
Example #24
0
        private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            try
            {
                DateTime frdate = DateTime.Today;
                DateTime todate = DateTime.Today;
                if (string.IsNullOrEmpty(EditText0.Value))
                {
                    oApp.MessageBox("Please Enter From Date !");
                    return;
                }
                else
                {
                    frdate = DateTime.ParseExact(EditText0.Value, "yyyyMMdd", CultureInfo.InvariantCulture);
                }

                if (string.IsNullOrEmpty(EditText1.Value))
                {
                    oApp.MessageBox("Please Enter To Date !");
                    return;
                }
                else
                {
                    todate = DateTime.ParseExact(EditText1.Value, "yyyyMMdd", CultureInfo.InvariantCulture);
                }

                if (string.IsNullOrEmpty(EditText2.Value))
                {
                    oApp.MessageBox("Please Enter Level !");
                    return;
                }
                else
                {
                    int.TryParse(EditText2.Value.Trim(), out Level);
                }
                DataTable result = Get_Data(Level, frdate, todate);
                this.UIAPIRawForm.Freeze(true);
                Grid0.DataTable = Convert_SAP_DataTable(result);
                Grid0.AutoResizeColumns();
                for (int i = 0; i < Grid0.Columns.Count; i++)
                {
                    if (i >= 4)
                    {
                        Grid0.Columns.Item(i).RightJustified = true;
                    }
                }
                for (int i = 0; i < Grid0.Rows.Count; i++)
                {
                    int t_level = 0;
                    int.TryParse(Grid0.DataTable.GetValue("Cap", i).ToString(), out t_level);
                    if (t_level < Level)
                    {
                        //Dark Gray
                        Grid0.CommonSetting.SetRowBackColor(i + 1, 14277081);
                    }
                    else
                    {
                        //White Color
                        Grid0.CommonSetting.SetRowBackColor(i + 1, 16777215);
                    }
                }
                Grid0.Columns.Item(0).Visible = false;
                Grid0.Columns.Item(3).Visible = false;
                Grid0.AutoResizeColumns();
                oApp.SetStatusBarMessage("Load Data Completed !", SAPbouiCOM.BoMessageTime.bmt_Medium, false);
            }
            catch (Exception ex)
            {
                oApp.MessageBox(ex.Message);
            }
            finally
            {
                this.UIAPIRawForm.Freeze(false);
            }
        }
Example #25
0
        private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent)
        {
            BubbleEvent = true;
            oUserTable  = oCompany.UserTables.Item("SUPRASECCIONESCOL");
            if (oForm.Mode.Equals(SAPbouiCOM.BoFormMode.fm_OK_MODE) || (Grid0.Rows.SelectedRows.Count == 0))
            {
                Button0.Caption = "OK";
            }

            else
            {
                //if (Grid2.Rows.SelectedRows.Count > 0)   //VERIFICA QUE EXISTA UN ROW SELECCIONADO
                //{


                int nRow = Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder);
                oApp.SendKeys("({TAB})");//aca aplico tabular para que tome el campo para actualizar



                //Grid2.Rows.SelectedRows.Equals(nRow);
                String sValorGrid = Convert.ToString(Grid0.DataTable.GetValue("Código", nRow));

                // Grid2.Columns.Item("CODE").Click();
                //bool num = (Grid2.Rows.SelectedRows.Count > 0);
                if (oUserTable.GetByKey(sValorGrid.ToString())) // Esto devuelve true si existe el registro
                {
                    //

                    string nom = (string)(Grid0.DataTable.GetValue("Nombre", nRow));



                    // oCompany.StartTransaction();
                    oUserTable.Code = sValorGrid;
                    oUserTable.Name = sValorGrid;
                    oUserTable.UserFields.Fields.Item("U_CodigoSS").Value = sValorGrid;
                    oUserTable.UserFields.Fields.Item("U_NombreSS").Value = nom;


                    int i = oUserTable.Update();

                    if (i != 0)
                    {
                        oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    }
                    else
                    {
                        oApp.SetStatusBarMessage("Exito en la Actualización", SAPbouiCOM.BoMessageTime.bmt_Medium, false);

                        oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE;
                        oForm.DataSources.DataTables.Item(0).ExecuteQuery("SELECT U_CodigoSS AS 'Código',U_NombreSS AS 'Nombre' FROM  [@SUPRASECCIONESCOL]");
                        Grid0.DataTable = oForm.DataSources.DataTables.Item("DTSPSEC");

                        Grid0.DataTable.Rows.Add(1);
                        for (int j = 1; j <= this.Grid0.DataTable.Rows.Count; j += 1)
                        {
                            if (j < this.Grid0.DataTable.Rows.Count)
                            {
                                Grid0.Rows.SelectedRows.Add(j);
                            }
                        }

                        RowNumberGrid(Grid0);
                        BubbleEvent = false;
                    }
                }


                //si no existe el dato, lo agregara
                else
                {
                    //   Button0.Caption = "Agregar";
                    //   oUserTable = oCompany.UserTables.Item("EDICIONESCOL");
                    int    nRow2       = Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder);
                    String sValorGrid2 = Convert.ToString(Grid0.DataTable.GetValue("Código", nRow2));
                    //string nNOM2 = (string)Grid2.DataTable.GetValue("NOM", nRow2);
                    // string cod2 = (string)(Grid2.DataTable.GetValue("Código", nRow2));
                    string nom2 = (string)(Grid0.DataTable.GetValue("Nombre", nRow2));


                    oUserTable.Code = sValorGrid2;
                    oUserTable.Name = sValorGrid2;
                    oUserTable.UserFields.Fields.Item("U_CodigoSS").Value = sValorGrid2;
                    oUserTable.UserFields.Fields.Item("U_NombreSS").Value = nom2;

                    int j = oUserTable.Add();

                    if (j != 0)
                    {
                        oApp.SetStatusBarMessage("Error" + oCompany.GetLastErrorDescription(), SAPbouiCOM.BoMessageTime.bmt_Medium, false);
                    }
                    else
                    {
                        oApp.SetStatusBarMessage("Exito en la inserción", SAPbouiCOM.BoMessageTime.bmt_Medium, false);

                        oForm.Mode = SAPbouiCOM.BoFormMode.fm_OK_MODE;

                        Grid0.DataTable.Rows.Add(1);

                        oForm.DataSources.DataTables.Item(0).ExecuteQuery("SELECT U_CodigoSS AS 'Código',U_NombreSS AS 'Nombre' FROM  [@SUPRASECCIONESCOL]");
                        Grid0.DataTable = oForm.DataSources.DataTables.Item("DTSPSEC");

                        for (int i = 1; i <= this.Grid0.DataTable.Rows.Count; i += 1)
                        {
                            if (i < this.Grid0.DataTable.Rows.Count)
                            {
                                Grid0.Rows.SelectedRows.Add(i);
                            }
                        }

                        RowNumberGrid(Grid0);
                        BubbleEvent = false;
                    }
                }
            }
        }
Example #26
0
        private void Button1_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
        {
            //throw new System.NotImplementedException();
            if (pVal.FormMode == 1)
            {
                //Get DATA SUM CCM
                int       DocEntry  = int.Parse(((SAPbouiCOM.EditText)(this.GetItem("0_U_E").Specific)).Value);
                string    Project   = ((SAPbouiCOM.EditText)(this.GetItem("20_U_E").Specific)).Value;
                DataTable Sum_DUTRU = Load_Data_DUTRU(Project, DocEntry);

                oApp.ActivateMenuItem("DUTRU");
                SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.ActiveForm;
                //Get DocNum CTG
                try
                {
                    ((SAPbouiCOM.EditText)oForm.Items.Item("20_U_E").Specific).Value = DocEntry.ToString();
                    oForm.Freeze(true);
                    oForm.PaneLevel = 1;
                    SAPbouiCOM.Matrix oMtx = (SAPbouiCOM.Matrix)oForm.Items.Item("0_U_G").Specific;
                    for (int i = 0; i < Sum_DUTRU.Rows.Count; i++)
                    {
                        oApp.SetStatusBarMessage(string.Format("Creating DUTRU: {0}", (i + 1) + "/" + Sum_DUTRU.Rows.Count), SAPbouiCOM.BoMessageTime.bmt_Short, false);
                        DataRow r = Sum_DUTRU.Rows[i];
                        //Subproject Code
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_2").Cells.Item(i + 1).Specific).Value = r["High_Level_SUM"].ToString();
                        //Subproject Description
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_3").Cells.Item(i + 1).Specific).Value = r["High_Level_Name"].ToString();
                        //CP NCC
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_4").Cells.Item(i + 1).Specific).Value = r["CP_NCC"].ToString();
                        //CP NTP
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_5").Cells.Item(i + 1).Specific).Value = r["CP_NTP"].ToString();
                        //CP DTC
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_6").Cells.Item(i + 1).Specific).Value = r["CP_DTC"].ToString();
                        //CP VTP
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_7").Cells.Item(i + 1).Specific).Value = r["CP_VTP"].ToString();
                        //CP VC
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_8").Cells.Item(i + 1).Specific).Value = r["CP_VC"].ToString();
                        //CP CN
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_9").Cells.Item(i + 1).Specific).Value = r["CP_CN"].ToString();
                        //CP DP
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_10").Cells.Item(i + 1).Specific).Value = r["CP_DP"].ToString();
                        //CP DP2
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_11").Cells.Item(i + 1).Specific).Value = r["CP_DP2"].ToString();
                        //CP PRELIM
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_12").Cells.Item(i + 1).Specific).Value = r["CP_PRELIM"].ToString();
                        //CP TB
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_13").Cells.Item(i + 1).Specific).Value = r["CP_TB"].ToString();
                        //CP Khac
                        ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_14").Cells.Item(i + 1).Specific).Value = r["CP_Khac"].ToString();
                        if (i < Sum_DUTRU.Rows.Count - 1)
                        {
                            oMtx.AddRow();
                            ((SAPbouiCOM.EditText)oMtx.Columns.Item(1).Cells.Item(i + 2).Specific).Value = (i + 2).ToString();
                        }
                    }
                    oForm.Freeze(false);
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    oForm.Freeze(false);
                }
            }
            else
            {
                Application.SBO_Application.MessageBox("Function works only on View Mode");
            }
        }
Example #27
0
        static public void BankfileArchive_DO(ref SAPbouiCOM.Application application, ref SAPbobsCOM.Company company)
        {
            SAPbouiCOM.Form form = application.Forms.ActiveForm;

            string vcardFolder = @"\\core.com\core\Shared\Accounting\Accounts Payable\Virtual Card\TEST\HUNT-VIRTUAL_VCARD\HUNT_Vcard";
            string achfolder   = @"\\core.com\core\Shared\Accounting\Accounts Payable\Virtual Card\TEST\HUNT-VIRTUAL_VCARD\HUNT_ACH";
            string toFolder    = @"\\core.com\core\Shared\Accounting\Accounts Payable\Virtual Card\TEST\HUNT-VIRTUAL_VCARD\Archive";
            string currentDTM  = DateTime.Now.ToString("yyyyMMdd_HHmmss");

            string achfromfile   = "";
            string vcardfromfile = "";
            string vcarddestFile = "";
            string achdestFile   = "";

            int vcardcount = 0;
            int achcount   = 0;
            int choice     = 0;

            string showmsg = "";


            //Get varcfile

            if (System.IO.Directory.Exists(vcardFolder))
            {
                string[] files = System.IO.Directory.GetFiles(vcardFolder);

                foreach (string s in files)
                {
                    if (System.IO.Path.GetExtension(s).ToUpper() == ".CSV")
                    {
                        showmsg = showmsg + "Vcard file : " + System.IO.Path.GetFileNameWithoutExtension(s) + " Last Modified " + System.IO.File.GetLastWriteTime(s).ToString() + "\r\n";
                        vcardcount++;
                    }
                }
            }

            //get achfile

            if (System.IO.Directory.Exists(achfolder))
            {
                string[] files = System.IO.Directory.GetFiles(achfolder);

                foreach (string s in files)
                {
                    if (System.IO.Path.GetExtension(s).ToUpper() == ".CSV")
                    {
                        showmsg = showmsg + "ACH file : " + System.IO.Path.GetFileNameWithoutExtension(s) + " Last Modified " + System.IO.File.GetLastWriteTime(s).ToString() + "\r\n";
                        achcount++;
                    }
                }
            }
            //show user and choose
            if (showmsg != "")
            {
                showmsg = showmsg + " Please choose which file you want to archive";
                choice  = application.MessageBox(showmsg, 3, "vcard", "ACH", "Both");
            }



            try
            {
                if (choice == 1 || choice == 3)
                {
                    application.MessageBox("run vcard", 1, "OK", "", "");
                    //vcard file conversion.
                    if (System.IO.Directory.Exists(vcardFolder))
                    {
                        string[] files = System.IO.Directory.GetFiles(vcardFolder);

                        foreach (string s in files)
                        {
                            if (System.IO.Path.GetExtension(s).ToUpper() == ".CSV")
                            {
                                vcardfromfile = "VCARD_" + System.IO.Path.GetFileNameWithoutExtension(s) + "_" + currentDTM + System.IO.Path.GetExtension(s);
                                vcarddestFile = System.IO.Path.Combine(toFolder, vcardfromfile);
                                System.IO.File.Copy(s, vcarddestFile, true);
                            }
                        }
                    }
                }
                if (choice == 2 || choice == 3)
                {
                    application.MessageBox("run ACH", 1, "OK", "", "");
                    //ach file conversion.
                    if (System.IO.Directory.Exists(achfolder))
                    {
                        string[] files = System.IO.Directory.GetFiles(achfolder);

                        foreach (string s in files)
                        {
                            if (System.IO.Path.GetExtension(s).ToUpper() == ".CSV")
                            {
                                achfromfile = "ACH_" + System.IO.Path.GetFileNameWithoutExtension(s) + "_" + currentDTM + System.IO.Path.GetExtension(s);
                                achdestFile = System.IO.Path.Combine(toFolder, achfromfile);
                                System.IO.File.Copy(s, achdestFile, true);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                application.SetStatusBarMessage("File Archived Failed" + ex.Message.ToString(), SAPbouiCOM.BoMessageTime.bmt_Short, true);
            }
        }