public ItemAddCost() { ds = this.UIAPIRawForm.DataSources.DBDataSources.Item("@T_HOUSSAM"); ds.Query(null); mtxCost.LoadFromDataSource(); mtxCost.AutoResizeColumns(); }
/// <summary> /// Initialize components. Called by framework after form created. /// </summary> public override void OnInitializeComponent() { this.mtxItems = ((SAPbouiCOM.Matrix)(this.GetItem("mtxItems").Specific)); this.txtDocNo = ((SAPbouiCOM.EditText)(this.GetItem("txtDocNo").Specific)); this.dtTransferItemLines = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines)); this.dpDocDate = ((SAPbouiCOM.EditText)(this.GetItem("dpDocDate").Specific)); this.mtxItems.ChooseFromListBefore += new SAPbouiCOM._IMatrixEvents_ChooseFromListBeforeEventHandler(this.mtxItems_ChooseFromListBefore); this.mtxItems.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.mtxItems_ChooseFromListAfter); this.mtxItems.ClickBefore += new SAPbouiCOM._IMatrixEvents_ClickBeforeEventHandler(this.mtxItems_ClickBefore); this.btnSave = ((SAPbouiCOM.Button)(this.GetItem("1").Specific)); this.btnSave.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.btnSave_ClickBefore); this.btnSave.PressedBefore += new SAPbouiCOM._IButtonEvents_PressedBeforeEventHandler(this.btnSave_PressedBefore); this.btnCancel = ((SAPbouiCOM.Button)(this.GetItem("2").Specific)); this.fldrItems = ((SAPbouiCOM.Folder)(this.GetItem("Item_5").Specific)); this.fldrCosts = ((SAPbouiCOM.Folder)(this.GetItem("Item_6").Specific)); this.mtxCost = ((SAPbouiCOM.Matrix)(this.GetItem("Item_7").Specific)); this.mtxCost.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.mtxCost_ChooseFromListAfter); this.mtxCost.ClickBefore += new SAPbouiCOM._IMatrixEvents_ClickBeforeEventHandler(this.mtxCost_ClickBefore); //this.btnCalculate = ((SAPbouiCOM.Button)(this.GetItem("btnClc").Specific)); //this.btnCalculate.ClickAfter += new SAPbouiCOM._IButtonEvents_ClickAfterEventHandler(this.btnCalculate_ClickAfter); //this.btnCalculate.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.btnCalculate_ClickBefore); this.btnAddRow = ((SAPbouiCOM.Button)(this.GetItem("btnAddRow").Specific)); this.btnAddRow.ClickBefore += btnAddRow_ClickBefore; this.btnAddRow.ClickAfter += btnAddRow_ClickAfter; this.mtxItems.ValidateBefore += mtxItems_ValidateBefore; this.OnCustomInitialize(); }
public void instanciarObjetosUI() { deletedEntries = new List <string>(); dsTipoUsuario = mForm.DataSources.DBDataSources.Item(TB_TIPOUSR_APP); oMatrix = mForm.Items.Item(MATRIZ_PRINCIPAL).Specific; }
public void OutExcel(string file, SAPbouiCOM.DBDataSource oDS) { //get data //System.Data.DataTable dt = GetDT(oDS); CreateFile(file); Insert(file, dt); }
public ItemAddCost() { ds = this.UIAPIRawForm.DataSources.DBDataSources.Item("@T_HOUSSAM"); ds.Query(null); mtxCost.LoadFromDataSource(); mtxCost.AutoResizeColumns(); }
private void Habilita_Importacion_Anexos() { //if (oForm.Mode == SAPbouiCOM.BoFormMode.fm_OK_MODE || oForm.Mode == SAPbouiCOM.BoFormMode.fm_UPDATE_MODE) //{ try { //Verifica si existe al menos una linea con un Documento de Origen SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("PCH1"); string sBaseType = "-1"; for (int i = 0; i < source.Size; i++) { sBaseType = (source.GetValue("BaseType", i)); if (sBaseType.Trim() != "-1") { break; } } if (sBaseType.Trim() != "-1") { Button0.Item.Enabled = true; } else { Button0.Item.Enabled = false; } } catch (Exception) { } //} }
public static void SolicitudCompra_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool bBubbleEvent) { bBubbleEvent = true; try { switch (pVal.BeforeAction) { case true: break; case false: if ((pVal.EventType == SAPbouiCOM.BoEventTypes.et_COMBO_SELECT) && (pVal.ItemUID == "10000329")) { if (oCompany == null) { Funciones.Connect_Application(ref oCompany); } oComboBox = (SAPbouiCOM.ComboBox)oForm.Items.Item(pVal.ItemUID).Specific; businessObject = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); oItems = (SAPbobsCOM.Items)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oItems); int nOrden = 0; int nDocOrd = 0; string sSerie = ""; //string sql = ""; //string itemCode = ""; try { if (oComboBox.Selected.Description == "0") { //Obtener DocEntry de Solicitud de Compra oDBDataSource = oForm.DataSources.DBDataSources.Item("OPRQ"); nOrden = Convert.ToInt32(oDBDataSource.GetValue("DocNum", oDBDataSource.Offset)); //Convert.ToInt32(oEdit.Value); nDocOrd = Convert.ToInt32(oDBDataSource.GetValue("DocEntry", oDBDataSource.Offset)); oComboBox = (SAPbouiCOM.ComboBox)oForm.Items.Item("88").Specific; sSerie = oComboBox.Selected.Description; System.Runtime.InteropServices.Marshal.ReleaseComObject(businessObject); //Abrir Pantalla de Salida de Inventario y agregar lineas de acuerdo a Solicitud try { Application.SBO_Application.ActivateMenuItem("3079"); oForm = Application.SBO_Application.Forms.ActiveForm; SalidaMercancias.Agregar_Items_Desde_Solicitud_Interna(nDocOrd, nOrden, sSerie); } catch (Exception) { } } } catch (Exception) { } } break; } } catch (Exception) { } }
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); } }
public void instanciarObjetosUI() { try { dsEquipo = mForm.DataSources.DBDataSources.Item("@" + Movil.getTabla().nombre); mtxPrincipal = mForm.Items.Item("Item_0").Specific; } catch (Exception ex) { StatusMessageError("instanciarObjetosUI() > " + ex.Message); } }
public static void SetValue(ref SAPbouiCOM.Form oForm, String tableName, String newValue, String fieldIndex, int rowIndex = 0) { try { SAPbouiCOM.DBDataSource dbDataSource = oForm.DataSources.DBDataSources.Item(tableName); dbDataSource.SetValue(fieldIndex, rowIndex, newValue); } catch (Exception ex) { AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace); } }
public void SetValueViaDBS(ref SAPbouiCOM.Form oForm, String table, String field, Object value) { try { SAPbouiCOM.DBDataSource oDBS = oForm.DataSources.DBDataSources.Item(table); oDBS.SetValue(field, 0, value.ToString()); } catch (Exception ex) { AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace); } }
public void AddDataSourceToForm() { //**************************************************************** // every item must be binded to a Data Source // prior of binding the data we must add Data sources to the form //**************************************************************** // Add user data sources to the "International Phone" column in the matrix oUserDataSource = oForm.DataSources.UserDataSources.Add("CÓDIGO", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20); // Add DB data sources for the DB bound columns in the matrix oDBDataSource = oForm.DataSources.DBDataSources.Add("@EDICIONESCOL"); }
public static String GetValue(ref SAPbouiCOM.Form oForm, String tableName, String fieldIndex, int rowIndex = 0) { try { SAPbouiCOM.DBDataSource dbDataSource = oForm.DataSources.DBDataSources.Item(tableName); return(dbDataSource.GetValue(fieldIndex, rowIndex)); } catch (Exception ex) { AddOnUtilities.MsgBoxWrapper(ex.Message + " " + ex.StackTrace); } return(String.Empty); }
/// <summary> /// Method to Set Value /// </summary> /// <param name="oForm"></param> /// <param name="tableName"></param> /// <param name="newValue"></param> /// <param name="fieldIndex"></param> /// <param name="rowIndex"></param> public static void SetValue(SAPbouiCOM.Form oForm, string tableName, string newValue, string fieldIndex, [Optional] int rowIndex) { try { SAPbouiCOM.DBDataSource dbDataSource = oForm.DataSources.DBDataSources.Item(tableName); dbDataSource.SetValue(fieldIndex, rowIndex, newValue); } catch (Exception ex) { PublicVariable.oApplication.StatusBar.SetText(ex.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } }
private static void Cargar_Datos_Matrix() { try { //oForm = Application.SBO_Application.Forms.ActiveForm; oDTTable = oForm.DataSources.DataTables.Item("DT_SQL1"); SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("@ZDFER"); oForm.Freeze(true); string sql = "SELECT * FROM [@ZDFER] ORDER BY U_Fecha"; oDTTable.ExecuteQuery(sql); oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("3").Specific; oMatrix.FlushToDataSource(); source.Clear(); oMatrix.Clear(); for (int i = 0; i < oDTTable.Rows.Count; i++) { source.InsertRecord(source.Size); source.Offset = source.Size - 1; source.SetValue("Code", source.Size - 1, Convert.ToString(oDTTable.GetValue("Code", i))); //DateTime fecha = (DateTime)oDTTable.GetValue("U_Fecha", i); source.SetValue("U_Fecha", source.Size - 1, Convert.ToDateTime(oDTTable.GetValue("U_Fecha", i)).ToString("yyyyMMdd")); source.SetValue("U_Descripcion", source.Size - 1, Convert.ToString(oDTTable.GetValue("U_Descripcion", i))); source.SetValue("DocEntry", source.Size - 1, Convert.ToString(oDTTable.GetValue("DocEntry", i))); } sql = "SELECT MAX(CAST(Code as int)) + 1 as Proximo FROM [@ZDFER]"; oDTTable.ExecuteQuery(sql); source.InsertRecord(source.Size); source.Offset = source.Size - 1; source.SetValue("Code", source.Size - 1, Convert.ToString(oDTTable.GetValue("Proximo", 0))); source.SetValue("DocEntry", source.Size - 1, Convert.ToString(oDTTable.GetValue("Proximo", 0))); oMatrix.LoadFromDataSource(); oMatrix.AutoResizeColumns(); } catch (Exception) { } finally { oForm.Freeze(false); } }
void SetValueviaDBS(SAPbouiCOM.Form oForm, string table, string field, string value) { try { SAPbouiCOM.DBDataSource oDBS = oForm.DataSources.DBDataSources.Item(table); oDBS.SetValue(field, 0, value); } catch (Exception ex) { Events.App_StatusBarEvent( ex.Message , SAPbouiCOM.BoMessageTime.bmt_Short , SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } }
/// <summary> /// Initialize components. Called by framework after form created. /// </summary> public override void OnInitializeComponent() { this.Button0 = ((SAPbouiCOM.Button)(this.GetItem("Item_0").Specific)); this.Button0.ClickAfter += new SAPbouiCOM._IButtonEvents_ClickAfterEventHandler(this.CopyToGoodsIssue); this.GIMatrix = ((SAPbouiCOM.Matrix)(this.GetItem("13").Specific)); this.StaticText0 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_1").Specific)); this.EditTextToBranch = ((SAPbouiCOM.EditText)(this.GetItem("Item_2").Specific)); this.EditTextToWhs = ((SAPbouiCOM.EditText)(this.GetItem("Item_3").Specific)); this.EditTextToWhs.ChooseFromListAfter += new SAPbouiCOM._IEditTextEvents_ChooseFromListAfterEventHandler(this.EditTextWhsUDF_ChooseFromListAfter); this.StaticText1 = ((SAPbouiCOM.StaticText)(this.GetItem("Item_5").Specific)); this.OIGE = this.UIAPIRawForm.DataSources.DBDataSources.Item("OIGE"); this.OnCustomInitialize(); }
private void button1_Click(object sender, EventArgs e) { int iColCount = 0; this.oMatrix = UIHelper.AddMatrixAoFormulario(this.oForm, "Matrix", 10, (this.oForm.ClientWidth - 10), 5, ((this.oForm.ClientHeight / 2) - 10), SAPbouiCOM.BoMatrixSelect.ms_Auto); this.oMatrix.Layout = SAPbouiCOM.BoMatrixLayoutType.mlt_Normal; this.oDBDataSource = oForm.DataSources.DBDataSources.Add("OCRD"); this.oDBDataSource1 = oForm.DataSources.DBDataSources.Add("OITM"); this.oDBDataSource2 = oForm.DataSources.DBDataSources.Add("OINV"); this.oDBDataSource3 = oForm.DataSources.DBDataSources.Add("INV1"); //add coluna 1 MatrixHelper.addoColumn(this.oMatrix, "Col" + iColCount.ToString(), SAPbouiCOM.BoFormItemTypes.it_EDIT, 0 , "#", "", false, false, "", "", false, 1); iColCount++; //add coluna 2 MatrixHelper.addoColumn(this.oMatrix, "Col" + iColCount.ToString(), SAPbouiCOM.BoFormItemTypes.it_EDIT, 70 , "CardCode", "", false, true, "OCRD", "CardCode", true, 0); iColCount++; //add coluna 3 MatrixHelper.addoColumn(this.oMatrix, "Col" + iColCount.ToString(), SAPbouiCOM.BoFormItemTypes.it_EDIT, 100 , "Item - OITM", "ItemCode", false, true, "OITM", "ItemCode", true, 0); iColCount++; //add coluna 4 MatrixHelper.addoColumn(this.oMatrix, "Col" + iColCount.ToString(), SAPbouiCOM.BoFormItemTypes.it_EDIT, 80 , "DocDate", "DocDate", false, true, "OINV", "DocDate", false, 0); iColCount++; //add coluna 5 MatrixHelper.addoColumn(this.oMatrix, "Col" + iColCount.ToString(), SAPbouiCOM.BoFormItemTypes.it_EDIT, 80 , "Numero", "Numero", false, true, "INV1", "LineTotal", false, 0); iColCount++; this.oMatrix.Clear(); this.oMatrix.AutoResizeColumns(); this.oDBDataSource.Query(null); this.oDBDataSource1.Query(null); this.oDBDataSource2.Query(null); this.oDBDataSource3.Query(null); this.oMatrix.LoadFromDataSource(); }
private void LoadDataMatrix() { SAPbouiCOM.DBDataSource oDBDataSource = oForm.DataSources.DBDataSources.Item("@Z_COMI_COMGRP"); oDBDataSource.Query(); oDBDataSource.InsertRecord(oDBDataSource.Size); //MatrixExtensions.AddLineMatrixDBDataSource(Matrix0, oDBDataSource); int nProxCode = UDOExtensions.GetNextCode("Z_COMI_COMGRP", NConexion.Verifica_Conexion(Program.oCompany)); oDBDataSource.SetValue("Code", oDBDataSource.Size - 1, nProxCode.ToString()); oDBDataSource.SetValue("DocEntry", oDBDataSource.Size - 1, nProxCode.ToString()); Matrix0.LoadFromDataSource(); Matrix0.CommonSetting.SetCellEditable(oDBDataSource.Size, 3, true); MatrixExtensions.SelectMatrixRowSetFocus(ref Matrix0, "Col_2", oDBDataSource.Size); }
public void instanciarObjetosUI() { edtCodVendedor = mForm.Items.Item(EDT_COD_VENDEDOR).Specific; edtNomVendedor = mForm.Items.Item(EDT_NOM_VENDEDOR).Specific; edtEquipoAsignado = mForm.Items.Item(EDT_EQUIPO_ASIGNADO).Specific; edtUsuarioMovil = mForm.Items.Item(EDT_USUARIO_MOVIL).Specific; edtPasswrdMovil = mForm.Items.Item(EDT_PASSWRD_MOVIL).Specific; mtxAlmacenes = mForm.Items.Item(MATRIZ_ALMACENES).Specific; cboPerfil = mForm.Items.Item(CBO_PERFIL).Specific; cboSeries = mForm.Items.Item(CBO_SERIE).Specific; //mtxGruposArticulo = mForm.Items.Item(MATRIZ_GRUPOS_ARTICULOS).Specific; //mtxGruposCliente = mForm.Items.Item(MATRIZ_GRUPOS_CLIENTES).Specific; //mtxGruposZona = mForm.Items.Item(MATRIZ_GRUPOS_ZONAS).Specific; dsCabecera = mForm.DataSources.DBDataSources.Item(DS_CABECERA); dsDetAlmacenes = mForm.DataSources.DBDataSources.Item(DS_DETALLE_1); //dsDetalle2 = mForm.DataSources.DBDataSources.Item(DS_DETALLE_2); //dsDetalle3 = mForm.DataSources.DBDataSources.Item(DS_DETALLE_3); }
public static void AddLineMatrixDBDataSource(SAPbouiCOM.Matrix oMatrix, SAPbouiCOM.DBDataSource source, string ColumnaFocus = "") { try { SAPbouiCOM.EditText oEdit; oMatrix.FlushToDataSource(); source.InsertRecord(source.Size); source.Offset = source.Size - 1; oMatrix.LoadFromDataSource(); oMatrix.SelectRow(source.Size, true, false); if (ColumnaFocus.Trim().Length != 0) { oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item(ColumnaFocus).Cells.Item(source.Size).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; } } catch (Exception) { } }
private void OnCustomInitialize() { oApp = (SAPbouiCOM.Application)Application.SBO_Application; oCompany = (SAPbobsCOM.Company)oApp.Company.GetDICompany(); oForm = oApp.Forms.Item("edimatr"); //Start(); oMatrix = ((SAPbouiCOM.Matrix)(oForm.Items.Item("Item_2").Specific)); oDBDataSource = oForm.DataSources.DBDataSources.Item("@EDICIONESCOL"); // Ready Matrix to populate data oMatrix.Clear(); oMatrix.AutoResizeColumns(); // Querying the DB Data source oDBDataSource.Query(); // setting the user data source data oMatrix.LoadFromDataSource(); oMatrix.AutoResizeColumns(); //int i; //for (i = 1; i <= oMatrix.RowCount - 1; i++) ; //{ // SAPbouiCOM.EditText cellID = (SAPbouiCOM.EditText)oMatrix.GetCellSpecific("numer", i); // cellID.String = i.ToString(); //} oForm.Visible = true; }
private void desenharCampos() { oItem = oForm.Items.Item("7"); oNewItem = oForm.Items.Add("Med_Text0", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 110; oNewItem.Height = 19; oNewItem.Width = 350; oNewItem.Left = 25; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Ambiente / Levantamento"; oNewItem = oForm.Items.Add("Med_Text1", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 270; oNewItem.Height = 19; oNewItem.Width = 350; oNewItem.Left = 25; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Conferências de Medições"; oNewItem = oForm.Items.Add("Med_Text2a", SAPbouiCOM.BoFormItemTypes.it_STATIC); oItem = oForm.Items.Item("Grade"); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 25; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Data"; oNewItem = oForm.Items.Add("Med_Text2b", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 120; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Hora"; oNewItem = oForm.Items.Add("Med_Text2c", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 175; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Projetista"; // Comentado campos de ligação com a tabela a partir daqui DBDSflx = oForm.DataSources.DBDataSources.Add("@FLX_FB_MED"); oNewItem = oForm.Items.Add("Med_Data", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 80; oNewItem.Left = 25; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_MED_DATEMED"); oNewItem = oForm.Items.Add("Med_Hora", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 120; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_MED_HORAMED"); oNewItem = oForm.Items.Add("Med_Proj", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 140; oNewItem.Left = 175; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.DisplayDesc = true; oComboItem = ((SAPbouiCOM.ComboBox)(oNewItem.Specific)); DBDSflx = oForm.DataSources.DBDataSources.Add("@FLX_FB_CONFMED"); oNewItem = oForm.Items.Add("Med_Amb", SAPbouiCOM.BoFormItemTypes.it_MATRIX); oNewItem.Left = 25; oNewItem.Width = 500; oNewItem.Top = oItem.Top + 85; oNewItem.Height = 110; oNewItem.FromPane = 10; oNewItem.ToPane = 10; //SBO_Application.MessageBox("PASSO 14", 1, "Ok", "", ""); oMatrix = ((SAPbouiCOM.Matrix)(oNewItem.Specific)); oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto; oColumns = oMatrix.Columns; oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "#"; oColumn.Width = 30; oColumn.Editable = false; oColumn = oColumns.Add("Med_Amb_C0", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Ambiente"; oColumn.Width = 60; oColumn.Editable = false; oColumn = oColumns.Add("Med_Amb_C1", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Levantamento (anexos)"; oColumn.Width = 140; oColumn.Editable = true; oColumn.DataBind.SetBound(true, "@FLX_FB_CONFMED", "U_FLX_FB_CONFMED_PRJ"); oColumn = oColumns.Add("Med_Amb_C2", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "IdAmbiente"; oColumn.Width = 80; oColumn.Editable = true; oColumn.Visible = false; oForm.DataSources.DataTables.Item("oMatrixDT").ExecuteQuery( "SELECT T1.[Num], T1.[Descript], T0.* FROM OPR4 T0 " + "INNER JOIN OOIN T1 ON T1.Num = T0.IntId " + "WHERE T0.[OprId] = '1'"); oColumn = oColumns.Item("Med_Amb_C0"); oColumn.DataBind.Bind("oMatrixDT", "Descript"); oColumn = oColumns.Item("Med_Amb_C1"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_MED_LEVANTA"); oColumn = oColumns.Item("Med_Amb_C2"); oColumn.DataBind.Bind("oMatrixDT", "Line"); oMatrix.LoadFromDataSource(); oNewItem = oForm.Items.Add("NvLev", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 210; oNewItem.Width = 180; oNewItem.Left = 400; oNewItem.Height = 19; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Novo levantamento"; oNewItem = oForm.Items.Add("Med_Cnf", SAPbouiCOM.BoFormItemTypes.it_MATRIX); oNewItem.Left = 25; oNewItem.Width = 300; oNewItem.Top = oItem.Top + 250; oNewItem.Height = 110; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oMatrix = ((SAPbouiCOM.Matrix)(oNewItem.Specific)); oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto; oColumns = oMatrix.Columns; oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "#"; oColumn.Width = 30; oColumn.Editable = false; oColumn = oColumns.Add("Med_Cnf_C0", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Data"; oColumn.Width = 80; oColumn.Editable = true; oColumn = oColumns.Add("med_Cnf_C1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oColumn.TitleObject.Caption = "Conferente"; oColumn.Width = 100; oColumn.Editable = true; oColumn = oColumns.Add("Med_Cnf_C2", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Id"; oColumn.Width = 100; oColumn.Editable = true; oColumn.Visible = false; oNewItem = oForm.Items.Add("Med_Age", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 35; oNewItem.Width = 80; oNewItem.Left = 430; oNewItem.Height = 19; oNewItem.FromPane = 10; oNewItem.ToPane = 10; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Agendar"; oForm.DataSources.DataTables.Add("oDataTable"); oForm.DataSources.DataTables.Item("oDataTable").ExecuteQuery("select * from [@FLX_FB_CONFMED] where U_FLX_FB_CONFMED_ID = '1'"); oColumn = oColumns.Item("Med_Cnf_C0"); oColumn.DataBind.Bind("oDataTable", "U_FLX_FB_CONFMED_DAT"); oColumn = oColumns.Item("med_Cnf_C1"); oColumn.DataBind.Bind("oDataTable", "U_FLX_FB_CONFMED_PRJ"); oColumn = oColumns.Item("Med_Cnf_C2"); oColumn.DataBind.Bind("oDataTable", "Code"); }
//private void OApplication_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent) //{ // BubbleEvent = true; // if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ALL_EVENTS_CLICK) // { // } //} private void button1_Click(object sender, EventArgs e) { this.oDBDataSource = this.oForm.DataSources.DBDataSources.Add("OITM"); this.oUserDataSource = this.oForm.DataSources.UserDataSources.Add("user1", SAPbouiCOM.BoDataType.dt_SHORT_TEXT, 20); this.oItem = this.oForm.Items.Add("matrix1", SAPbouiCOM.BoFormItemTypes.it_MATRIX); this.oItem.Height = Convert.ToInt32(this.oForm.Height * 0.7); this.oItem.Width = Convert.ToInt32(this.oForm.Width * 0.9); this.oItem.Top = 10; this.oMatrix = (SAPbouiCOM.Matrix)oItem.Specific; this.oMatrix.Layout = SAPbouiCOM.BoMatrixLayoutType.mlt_Normal; this.oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto; //col1 this.oColumn = this.oMatrix.Columns.Add("col0", SAPbouiCOM.BoFormItemTypes.it_EDIT); this.oColumn.Editable = false; this.oColumn.TitleObject.Caption = "#"; //col2 this.oColumn = this.oMatrix.Columns.Add("Picture", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); this.oColumn.Width = 60; this.oColumn.Description = "Col1"; this.oColumn.TitleObject.Caption = "Picture"; this.oColumn.DisplayDesc = false; this.oColumn.DataBind.SetBound(true, "", "user1"); SAPbouiCOM.ColumnSetting cs = this.oColumn.ColumnSetting; SAPbouiCOM.BoColumnDisplayType dt = cs.DisplayType; cs.DisplayType = SAPbouiCOM.BoColumnDisplayType.cdt_Picture; dt = cs.DisplayType; //col3 this.oColumn = this.oMatrix.Columns.Add("mergecell", SAPbouiCOM.BoFormItemTypes.it_EDIT); this.oColumn.Width = 60; this.oColumn.Description = "Mer"; this.oColumn.TitleObject.Caption = "MergeCell"; this.oColumn.DataBind.SetBound(true, "OITM", "U_string"); this.oColumn.Editable = false; //col4 this.oColumn = this.oMatrix.Columns.Add("ItemName", SAPbouiCOM.BoFormItemTypes.it_EDIT); this.oColumn.Width = 60; this.oColumn.Description = "col2"; this.oColumn.TitleObject.Caption = "OITM - ItemName"; this.oColumn.DataBind.SetBound(true, "OITM", "ItemName"); this.oColumn.Editable = false; //col5 this.oColumn = this.oMatrix.Columns.Add("ItemCode", SAPbouiCOM.BoFormItemTypes.it_EDIT); this.oColumn.Width = 60; this.oColumn.Description = "col3"; this.oColumn.TitleObject.Caption = "OITM - ItemCode"; this.oColumn.DisplayDesc = false; this.oColumn.DataBind.SetBound(true, "OITM", "ItemCode"); this.oColumn.Editable = false; //col6 this.oColumn = this.oMatrix.Columns.Add("U_total", SAPbouiCOM.BoFormItemTypes.it_EDIT); this.oColumn.Width = 60; this.oColumn.Description = "col4"; this.oColumn.TitleObject.Caption = "Total"; this.oColumn.DataBind.SetBound(true, "OITM", "U_total"); this.oColumn.Editable = false; this.oMatrix.Clear(); this.oMatrix.AutoResizeColumns(); this.oDBDataSource.Query(null); this.oMatrix.LoadFromDataSource(); this.oColumn = this.oMatrix.Columns.Item("Picture"); this.oCombo = (SAPbouiCOM.ComboBox) this.oColumn.Cells.Item(1).Specific; string sPathImage = "C:\\BitMap\\Smile.bmp"; this.oCombo.ValidValues.Add(sPathImage, ""); this.oCombo.ValidValues.Add("T", "Text"); this.oCombo.ValidValues.Add("A", "Alternative"); this.oCombo.ValidValues.Add("S", "SubTotal"); }
public static void Agregar_Items_Desde_Solicitud_Interna(int nDocOrd, int nOrden, string sSerie) { Recordset businessObject = (Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset); Items oItems = (SAPbobsCOM.Items)oCompany.GetBusinessObject(BoObjectTypes.oItems); SAPbouiCOM.Matrix oMatrix = null; SAPbouiCOM.ComboBox oComboBox = null; string itemCode = ""; try { oForm.Freeze(true); SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("IGE1"); Documents oPurchaseRequest = (Documents)oCompany.GetBusinessObject(BoObjectTypes.oPurchaseRequest); double nCantArt = 0; int iSal = 0; if (oPurchaseRequest.GetByKey(nDocOrd)) { oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("13").Specific; for (int i = 0; i < oPurchaseRequest.Lines.Count; i++) { oPurchaseRequest.Lines.SetCurrentLine(i); itemCode = oPurchaseRequest.Lines.ItemCode; if (oItems.GetByKey(itemCode) && oPurchaseRequest.Lines.RemainingOpenQuantity > 0) { oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1").Cells.Item(iSal + 1).Specific; oEdit.String = oPurchaseRequest.Lines.ItemCode; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("9").Cells.Item(iSal + 1).Specific; oEdit.String = Convert.ToString(oPurchaseRequest.Lines.RemainingOpenQuantity); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("231000074").Cells.Item(iSal + 1).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = Convert.ToString(nOrden); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("24").Cells.Item(iSal + 1).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = Convert.ToString(oPurchaseRequest.Lines.LineNum); nCantArt += oPurchaseRequest.Lines.Quantity; iSal += 1; } } //Agregar como Referencia Numero de SCI oEdit = (SAPbouiCOM.EditText)oForm.Items.Item("Item_0").Specific; oEdit.String = sSerie.Trim() + "-" + Convert.ToString(nOrden); oComboBox = (SAPbouiCOM.ComboBox)oForm.Items.Item("30").Specific; oComboBox.Select("SI", SAPbouiCOM.BoSearchKey.psk_ByDescription); SAPbouiCOM.UserDataSource oUds = oForm.DataSources.UserDataSources.Item("UD_SCI"); oUds.ValueEx = nDocOrd.ToString(); oUds = oForm.DataSources.UserDataSources.Item("UD_CANT"); oUds.ValueEx = nCantArt.ToString(); oPurchaseRequest.Lines.SetCurrentLine(iSal - 1); itemCode = oPurchaseRequest.Lines.ItemCode; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("U_FAS_Kilos_Unitario").Cells.Item(iSal).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.Item.Click(); System.Runtime.InteropServices.Marshal.ReleaseComObject(oPurchaseRequest); oPurchaseRequest = null; GC.Collect(); } } catch (Exception) { } finally { oForm.Freeze(false); Application.SBO_Application.SendKeys("{TAB}"); } }
private void desenharCampos() { oItem = oForm.Items.Item("Grade"); oNewItem = oForm.Items.Add("Ent_Text1a", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 27; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 25; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Data"; oNewItem = oForm.Items.Add("Ent_Text1b", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 27; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 120; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Hora"; oNewItem = oForm.Items.Add("Ent_Text1c", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 27; oNewItem.Height = 19; oNewItem.Width = 175; oNewItem.Left = 175; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Responsável"; oNewItem = oForm.Items.Add("Ent_Text1d", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 27; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 330; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Prev. Apresent."; oNewItem = oForm.Items.Add("Ent_Data", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 45; oNewItem.Height = 17; oNewItem.Width = 80; oNewItem.Left = 25; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); //oEditItem.DataBind.SetBound(true, "OOPR", "U_DataEntrevista"); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_ETV_DATE"); oNewItem = oForm.Items.Add("Ent_Hora", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 45; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 120; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); //oEditItem.DataBind.SetBound(true, "OOPR", "U_HoraEntrevista"); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_ETV_HORA"); //SBO_Application.MessageBox("PASSO 11", 1, "Ok", "", ""); DBDSflx = oForm.DataSources.DBDataSources.Add("@FLX_FB_PRJ"); oNewItem = oForm.Items.Add("Ent_Proj", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oNewItem.Top = oItem.Top + 45; oNewItem.Height = 17; oNewItem.Width = 140; oNewItem.Left = 175; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.DisplayDesc = true; oComboItem = ((SAPbouiCOM.ComboBox)(oNewItem.Specific)); //LoadResponsavelComboVals(oComboItem); oNewItem = oForm.Items.Add("Ent_Prev", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 45; oNewItem.Height = 17; oNewItem.Width = 80; oNewItem.Left = 330; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_ETV_PREVAPR"); oNewItem = oForm.Items.Add("Text2", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 105; oNewItem.Height = 17; oNewItem.Width = 120; oNewItem.Left = 25; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Ambiente"; oNewItem = oForm.Items.Add("Ent_Amb", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oNewItem.Top = oItem.Top + 125; oNewItem.Height = 17; oNewItem.Width = 140; oNewItem.Left = 25; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.DisplayDesc = true; //oComboItem.DataBind.SetBound(true, "", "CombSource"); oComboItem = ((SAPbouiCOM.ComboBox)(oNewItem.Specific)); oNewItem = oForm.Items.Add("Text3", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 105; oNewItem.Height = 17; oNewItem.Width = 600; oNewItem.Left = 300; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "DESCRIÇÃO DO AMBIENTE: Móveis Planejados (novos)"; oNewItem = oForm.Items.Add("Ent_Det", SAPbouiCOM.BoFormItemTypes.it_EXTEDIT); oNewItem.Top = oItem.Top + 125; oNewItem.Height = 200; oNewItem.Width = 600; oNewItem.Left = 300; oNewItem.FromPane = 9; oNewItem.ToPane = 9; //oEditItem.DataBind.SetBound(true, "", "EditSource"); oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); //oEditItem.DataBind.SetBound(true, "OPR4", "U_FLX_FB_ETV_PREVAPR"); oNewItem = oForm.Items.Add("Ent_Age", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 43; oNewItem.Width = 80; oNewItem.Left = 430; oNewItem.Height = 19; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Agendar"; oNewItem = oForm.Items.Add("Ent_Imp", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 327; oNewItem.Width = 65; oNewItem.Left = oForm.Width - 100; oNewItem.Height = 19; oNewItem.FromPane = 9; oNewItem.ToPane = 9; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Imprimir"; }
private void Importar_Anexos_Desde_Origen() { try { oForm.Freeze(true); SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("OPOR"); string sDocEntry = source.GetValue("DocEntry", source.Offset); int iAtcEntry = int.TryParse(source.GetValue("AtcEntry", source.Offset), out iAtcEntry) ? iAtcEntry : 0; //SAPbobsCOM.Documents oPurchaseOrders = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders); //oPurchaseOrders.GetByKey(Convert.ToInt32(sDocEntry)); //source = oForm.DataSources.DBDataSources.Item("POR1"); //for (int i = 0; i <= source.Size - 1; i++) //{ // var BaseRef = source.GetValue("BaseRef", i); // var BaseTypex = source.GetValue("BaseType", i); // var BaseEntryx = source.GetValue("BaseEntry", i); //} string BaseType = ""; string TipoLinea = ""; string sql = ""; List <Anexos> lAnexos = new List <Anexos>(); //List<Object> DetallesVoid = new List<Object>(); oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific; // Recorre Matrix, cargar Objeto Anexo e insertar en lista for (int i = 1; i <= oMatrix.RowCount; i++) { try { BaseType = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("43").Cells.Item(i).Specific).Value.Trim(); TipoLinea = ((SAPbouiCOM.ComboBox)oMatrix.Columns.Item("257").Cells.Item(i).Specific).Selected.Value.Trim(); } catch { TipoLinea = "No valido"; BaseType = "-1"; } if (TipoLinea.Trim().Length == 0 && BaseType != "-1") { Anexos oAnexo = new Anexos(); oAnexo.FormID = oForm.UniqueID; oAnexo.ObjType = oForm.TypeEx; oAnexo.BaseRef = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("44").Cells.Item(i).Specific).Value.Trim(); oAnexo.BaseType = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("43").Cells.Item(i).Specific).Value.Trim(); oAnexo.BaseEntry = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("45").Cells.Item(i).Specific).Value.Trim(); lAnexos.Add(oAnexo); //result = FuncionesUDO.InsertRecord("ZANEXOS", oAnexo, "", DetallesVoid); } } //Distict a lista var ListAnexos = lAnexos .GroupBy(p => new { p.BaseRef, p.BaseType, p.BaseEntry }) .Select(g => g.First()) .ToList(); //recorrer lista para insertar en matrix de anexos if (ListAnexos.Count > 0) { foreach (Anexos oAnexo in ListAnexos) { SAPbobsCOM.Recordset oRecordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); SAPbouiCOM.Matrix oMatrix = null; SAPbouiCOM.EditText oEdit = null; string sBaseType = oAnexo.BaseType; string sBaseRef = oAnexo.BaseRef; string sBaseEntry = oAnexo.BaseEntry; string sTable = ""; switch (sBaseType) { case "17": //Pedido sTable = "ORDR"; break; case "1470000113": //Solicitud de Compra sTable = "OPRQ"; break; } if (sTable.Trim().Length > 0) { sql = "SELECT AtcEntry FROM " + sTable + " WHERE AtcEntry is not null AND DocNum = " + sBaseRef; DT_SQL2.ExecuteQuery(sql); if (!DT_SQL2.IsEmpty) { SAPbobsCOM.Attachments2 oAtt = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); oAtt.GetByKey(Convert.ToInt32(DT_SQL2.GetValue("AtcEntry", 0))); //SAPbobsCOM.Attachments2 oAttN = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); //if (iAtcEntry > 0) //{ // oAttN.GetByKey(iAtcEntry); //} oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("1320002138").Specific; int rowNum = oMatrix.RowCount + 1; sql = @"select AttachPath from OADP"; oRecordset.DoQuery(sql); string RutaDestino = oRecordset.Fields.Item(0).Value.ToString(); for (int x = 0; x < oAtt.Lines.Count; x++) { sql = @"SELECT RTRIM(CAST(trgtPath as nvarchar(200)))+'\'+FileName+'.'+FileExt from ATC1 where AbsEntry = " + DT_SQL2.GetValue("AtcEntry", 0) + " AND Line = " + (x + 1).ToString(); oRecordset.DoQuery(sql); string RutaServ = oRecordset.Fields.Item(0).Value.ToString(); oMatrix.AddRow(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = RutaDestino; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000003").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetDirectoryName(RutaServ); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000004").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetFileNameWithoutExtension(RutaServ); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000005").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetExtension(RutaServ).Substring(1); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000007").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = DateTime.Now.ToShortDateString(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000001").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = rowNum.ToString(); //Se vuelve a cargar la primera fila para que no avance el scroll horizontal al final. oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = RutaDestino; rowNum += 1; } System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordset); } } } } //string sql = "select distinct BaseRef,BaseType,BaseEntry from POR1 where docentry = " + sDocEntry; //DT_SQL.ExecuteQuery(sql); //if (!DT_SQL.IsEmpty) //{ // for (int i = 0; i < DT_SQL.Rows.Count; i++) // { // SAPbobsCOM.Recordset oRecordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); // SAPbouiCOM.Matrix oMatrix = null; // SAPbouiCOM.EditText oEdit = null; // string sBaseType = DT_SQL.GetValue("BaseType", i).ToString(); // string sBaseRef = DT_SQL.GetValue("BaseRef", i).ToString(); // string sBaseEntry = DT_SQL.GetValue("BaseEntry", i).ToString(); // string sTable = ""; // switch (sBaseType) // { // case "17": //Pedido // sTable = "ORDR"; // break; // case "1470000113": //Solicitud de Compra // sTable = "OPRQ"; // break; // } // if (sTable.Trim().Length > 0) // { // sql = "SELECT AtcEntry FROM " + sTable + " WHERE AtcEntry is not null AND DocNum = " + sBaseRef; // DT_SQL2.ExecuteQuery(sql); // if (!DT_SQL2.IsEmpty) // { // SAPbobsCOM.Attachments2 oAtt = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); // oAtt.GetByKey(Convert.ToInt32(DT_SQL2.GetValue("AtcEntry", 0))); // //SAPbobsCOM.Attachments2 oAttN = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); // //if (iAtcEntry > 0) // //{ // // oAttN.GetByKey(iAtcEntry); // //} // oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("1320002138").Specific; // int rowNum = oMatrix.RowCount + 1; // sql = @"select AttachPath from OADP"; // oRecordset.DoQuery(sql); // string RutaDestino = oRecordset.Fields.Item(0).Value.ToString(); // for (int x = 0; x < oAtt.Lines.Count; x++) // { // sql = @"SELECT RTRIM(CAST(trgtPath as nvarchar(200)))+'\'+FileName+'.'+FileExt from ATC1 where AbsEntry = " + DT_SQL2.GetValue("AtcEntry", 0) + " AND Line = " + (x + 1).ToString(); // oRecordset.DoQuery(sql); // string RutaServ = oRecordset.Fields.Item(0).Value.ToString(); // oMatrix.AddRow(); // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = RutaDestino; // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000003").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = System.IO.Path.GetDirectoryName(RutaServ); // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000004").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = System.IO.Path.GetFileNameWithoutExtension(RutaServ); // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000005").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = System.IO.Path.GetExtension(RutaServ).Substring(1); // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000007").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = DateTime.Now.ToShortDateString(); // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000001").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = rowNum.ToString(); // //Se vuelve a cargar la primera fila para que no avance el scroll horizontal al final. // oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; // oEdit.Active = true; // oEdit.Item.Enabled = true; // oEdit.String = RutaDestino; // rowNum += 1; // //oAtt.Lines.SetCurrentLine(x); // //oAttN.Lines.Add(); // //oAttN.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(RutaServ); // //oAttN.Lines.FileExtension = System.IO.Path.GetExtension(RutaServ).Substring(1); // //oAttN.Lines.SourcePath = System.IO.Path.GetDirectoryName(RutaServ); // //oAttN.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES; // //if (iAtcEntry > 0) // //{ // // if (oAttN.Update() != 0) // // throw new Exception(oCompany.GetLastErrorDescription()); // //} // //else // //{ // // int iAttEntry = -1; // // if (oAttN.Add() == 0) // // { // // iAttEntry = int.Parse(oCompany.GetNewObjectKey()); // // //Assign the attachment to the GR object (GR is my SAPbobsCOM.Documents object) // // oPurchaseOrders.AttachmentEntry = iAttEntry; // // } // //} // } // System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordset); // } // } // } //} //System.Runtime.InteropServices.Marshal.ReleaseComObject(oPurchaseOrders); //oPurchaseOrders = null; GC.Collect(); } catch (Exception) { } finally { oForm.Freeze(false); } }
public static void Comparar_Lineas_Solicitud(string FormID) { try { oForm = oForm = Application.SBO_Application.Forms.Item(FormID); oDataTable = oForm.DataSources.DataTables.Item("DT_SQL"); oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("38").Specific; string Codigo = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("1").Cells.Item(1).Specific).Value; SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("POR1"); int nNumLineas = 0; int nDiferente = 0; string iBaseEntry = "0"; string iBaseEntryAnt = "0"; string iBaseLine = "0"; string sBaseType = "-1"; string sItemCode = ""; string sDscription = ""; string dQuantity = ""; string dPrice = ""; string dLineTotal = ""; string sql = ""; string sAutorizador = ""; string sDocEntry = ""; string sDocNum = ""; string sDocTotal = ""; string sVatSum = ""; string sDiscSum = ""; string sBrutoSolicitud = ""; string sUserSign = ""; for (int i = 1; i < oMatrix.RowCount; i++) //for (int i = 0; i < source.Size; i++) { sBaseType = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("43").Cells.Item(i).Specific).Value; //(source.GetValue("BaseType", i)); iBaseEntry = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("45").Cells.Item(i).Specific).Value; //(source.GetValue("BaseEntry", i)); iBaseLine = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("46").Cells.Item(i).Specific).Value; //(source.GetValue("BaseLine", i)); sItemCode = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("1").Cells.Item(i).Specific).Value; //(source.GetValue("ItemCode", i)); sDscription = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("3").Cells.Item(i).Specific).Value; //(source.GetValue("Dscription", i)); dQuantity = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("11").Cells.Item(i).Specific).Value; //(source.GetValue("Quantity", i)); dPrice = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("14").Cells.Item(i).Specific).Value.Replace(".", "|").Replace(",", ".").Replace("|", "").Replace("$", ""); //(source.GetValue("Price", i)); dLineTotal = ((SAPbouiCOM.EditText)oMatrix.Columns.Item("21").Cells.Item(i).Specific).Value.Replace(".", "|").Replace(",", ".").Replace("|", "").Replace("$", ""); //(source.GetValue("LineTotal", i)); if (sBaseType.Trim() != "1470000113") // Verifica que las lineas provengan de una solicitud de compra { nDiferente = 1; break; } if (i > 1) { if (iBaseEntryAnt != iBaseEntry) //Verifica que los numeros de Solicitud sean iguales para cada linea { nDiferente = 1; break; } } else { iBaseEntryAnt = iBaseEntry; // Solicitud Base de la primera linea } sql = @"SELECT TM.UserID,(T0.DocTotal-T0.VatSum+T0.DiscSum) as 'Bruto Solicitud' FROM OPRQ T0 JOIN OWDD T1 ON T0.DocEntry = T1.DocEntry AND T0.ObjType = T1.ObjType LEFT JOIN (SELECT AP.WddCode,AP.UserID FROM WDD1 AP JOIN (select wddcode,MAX(StepCode) as Ultimo FROM WDD1 GROUP BY WddCode) MX ON AP.WddCode = MX.WddCode AND AP.StepCode = MX.Ultimo) TM ON T1.WddCode = TM.WddCode JOIN PRQ1 T2 ON T0.DocEntry = T2.DocEntry WHERE T1.Status = 'Y' AND T2.DocEntry = " + iBaseEntry.ToString().Trim() + " AND T2.LineNum = " + iBaseLine.ToString().Trim() + @" AND T2.[ItemCode] = '" + sItemCode + @"' AND RTRIM(LTRIM(T2.[Dscription])) = '" + sDscription + @"' AND T2.[Quantity] = " + dQuantity.ToString().Trim() + @" AND T2.[Price] = " + dPrice.ToString().Trim() + @" AND T2.[LineTotal] = " + dLineTotal.ToString().Trim(); oDataTable.ExecuteQuery(sql); if (!oDataTable.IsEmpty) { nNumLineas += 1; sAutorizador = oDataTable.GetValue("UserID", 0).ToString(); sBrutoSolicitud = oDataTable.GetValue("Bruto Solicitud", 0).ToString(); } else { nDiferente = 1; break; } } if (nNumLineas != oMatrix.RowCount - 1)//(nNumLineas != source.Size) { nDiferente = 1; } source = oForm.DataSources.DBDataSources.Item("OPOR"); sDocEntry = (source.GetValue("DocEntry", 0)) == "" ? "0" : (source.GetValue("DocEntry", 0)); sDocNum = (source.GetValue("DocNum", 0)); sDocTotal = (source.GetValue("DocTotal", 0)); sVatSum = (source.GetValue("VatSum", 0)); sDiscSum = (source.GetValue("DiscSum", 0)); sUserSign = (source.GetValue("UserSign", 0)) == "" ? Convert.ToString(Program.oCompany.UserSignature) : (source.GetValue("UserSign", 0)); //sql = "DELETE FROM [@ZAUTORI] WHERE U_ObjType = 22 AND U_DocNum = ISNULL(" + sDocNum + ",0)"; //oDataTable.ExecuteQuery(sql); oDataTable = NTablaAutoriza.BuscarDatosAutorizacion(oDataTable, "22", sDocNum); if (!oDataTable.IsEmpty) { for (int i = 0; i <= oDataTable.Rows.Count - 1; i++) { string sCodeUDO = oDataTable.GetValue("Code", i).ToString(); NTablaAutoriza.EliminarDatosAutorizacion(sCodeUDO); } } NTablaAutoriza.InsertarDatosAutorizacion("22" , sDocEntry , sDocNum , nDiferente.ToString() , sAutorizador , sUserSign , DateTime.Now.ToString("MMM dd yyyy h:ss tt")); // sql = @" INSERT INTO [dbo].[@ZAUTORI] // ([Code] // ,[Name] // ,[U_ObjType] // ,[U_DocEntry] // ,[U_DocNum] // ,[U_Approved] // ,[U_UserPrevDoc] // ,[U_UserSing] // ,[U_CreateDate]) // VALUES // ((select isnull(max(CAST([Code] as int)),0)+1 as Proximo from [dbo].[@ZAUTORI]) // ,(select isnull(max(CAST([Name] as int)),0)+1 as Proximo from [dbo].[@ZAUTORI]) // ,'22' // ,'" + sDocEntry + @"' // ,'" + sDocNum + @"' // ,'" + nDiferente + @"' // ,'" + sAutorizador + @"' // ,'" + sUserSign + @"' // ,CONVERT(Datetime,GETDATE()))"; // oDataTable.ExecuteQuery(sql); } catch (Exception) {} }
private void Button0_ClickBefore(object sboObject, SAPbouiCOM.SBOItemEventArg pVal, out bool BubbleEvent) { BubbleEvent = true; if (Button0.Item.Enabled) { try { oForm = Application.SBO_Application.Forms.Item(pVal.FormUID); if (!Funciones.DataTableExists(oForm, "DT_SQL")) { oForm.DataSources.DataTables.Add("DT_SQL"); } oDataTable = oForm.DataSources.DataTables.Item("DT_SQL"); oDBDataSource = oForm.DataSources.DBDataSources.Item("OVPM"); string sDocNum = oDBDataSource.GetValue("DocNum", oDBDataSource.Offset).ToString(); string sDocEntry = oDBDataSource.GetValue("DocEntry", 0) == "" ? "0" : (oDBDataSource.GetValue("DocEntry", 0)); string sCardCode = oDBDataSource.GetValue("CardCode", oDBDataSource.Offset).ToString(); double dTrsfrSum = Funciones.GetDoubleFromString(oDBDataSource.GetValue("TrsfrSum", oDBDataSource.Offset).ToString()); double dDocTotal = Funciones.GetDoubleFromString(oDBDataSource.GetValue("DocTotal", oDBDataSource.Offset).ToString()); //PARA AUTORIZAR CHEQUES double dCheckSum = Funciones.GetDoubleFromString(oDBDataSource.GetValue("CheckSum", oDBDataSource.Offset).ToString()); string sCheckAutor = oDBDataSource.GetValue("U_Cheque_Autor", oDBDataSource.Offset).ToString(); if (sCardCode.Trim().Length != 0 && dDocTotal > 0) { string sAprovved = "0"; if (dTrsfrSum == 0) { sAprovved = "1"; } else { sAprovved = "0"; } //PARA AUTORIZAR CHEQUES if (dCheckSum > 0 && sCheckAutor.Trim() == "Si") { sAprovved = "0"; } oDataTable = NTablaAutoriza.BuscarDatosAutorizacion(oDataTable, "46", sDocNum); if (!oDataTable.IsEmpty) { for (int i = 0; i <= oDataTable.Rows.Count - 1; i++) { string sCodeUDO = oDataTable.GetValue("Code", i).ToString(); NTablaAutoriza.EliminarDatosAutorizacion(sCodeUDO); } } NTablaAutoriza.InsertarDatosAutorizacion("46", sDocEntry, sDocNum, sAprovved, "", Convert.ToString(Program.oCompany.UserSignature), DateTime.Now.ToString("MMM dd yyyy h:ss tt")); } } catch (Exception) { } } }
private void desenharCampos() { oItem = oForm.Items.Item("Grade"); oNewItem = oForm.Items.Add("Apr_Text0", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 65; oNewItem.Height = 19; oNewItem.Width = 350; oNewItem.Left = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Ambiente / Análise Crítica"; oNewItem = oForm.Items.Add("Apr_Text1", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 200; oNewItem.Height = 19; oNewItem.Width = 350; oNewItem.Left = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Ambiente / Aprovação"; oNewItem = oForm.Items.Add("Apr_Text2a", SAPbouiCOM.BoFormItemTypes.it_STATIC); oItem = oForm.Items.Item("Grade"); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Data"; oNewItem = oForm.Items.Add("Apr_Text2b", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 120; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Hora"; oNewItem = oForm.Items.Add("Apr_Text2c", SAPbouiCOM.BoFormItemTypes.it_STATIC); oItem = oForm.Items.Item("Grade"); oNewItem.Top = oItem.Top + 17; oNewItem.Height = 19; oNewItem.Width = 400; oNewItem.Left = 175; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Projetista"; oNewItem = oForm.Items.Add("Apr_Data", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 80; oNewItem.Left = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_APS_DATE"); oNewItem = oForm.Items.Add("Apr_Hora", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 120; oNewItem.FromPane = 12; oNewItem.ToPane = 12; //oEditItem.DataBind.SetBound(true, "", "EditSource"); oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oEditItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_APS_HORA"); oNewItem = oForm.Items.Add("Apr_Proj", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oNewItem.Top = oItem.Top + 35; oNewItem.Height = 17; oNewItem.Width = 140; oNewItem.Left = 175; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.DisplayDesc = true; //oComboItem.DataBind.SetBound(true, "", "CombSource"); oComboItem = ((SAPbouiCOM.ComboBox)(oNewItem.Specific)); //oComboItem.DataBind.SetBound(true, "OOPR", "U_FLX_FB_APS_PROJT"); //LoadResponsavelComboVals(oComboItem); oNewItem = oForm.Items.Add("Apr_Ped", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 235; oNewItem.Width = 100; oNewItem.Left = 725; oNewItem.Height = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Pedido (fechamento)"; oNewItem = oForm.Items.Add("Apr_Text3", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 220; oNewItem.Height = 19; oNewItem.Width = 50; oNewItem.Left = 840; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Pedido"; oNewItem = oForm.Items.Add("Apr_Pedido", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 240; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 840; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Enabled = false; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oNewItem = oForm.Items.Add("Apr_LinkPd", SAPbouiCOM.BoFormItemTypes.it_LINKED_BUTTON); oNewItem.Top = oItem.Top + 240; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 810; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oNewItem.Enabled = true; oLink = ((SAPbouiCOM.LinkedButton)(oNewItem.Specific)); //oLink.LinkedObject = "Apr_Pedido"; oNewItem = oForm.Items.Add("Apr_Ctr", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 300; oNewItem.Width = 100; oNewItem.Left = 725; oNewItem.Height = 25; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Gerar Contrato(s)"; oNewItem = oForm.Items.Add("Apr_Text4", SAPbouiCOM.BoFormItemTypes.it_STATIC); oNewItem.Top = oItem.Top + 285; oNewItem.Height = 19; oNewItem.Width = 55; oNewItem.Left = 840; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oTextItem = ((SAPbouiCOM.StaticText)(oNewItem.Specific)); oTextItem.Caption = "Contrato(s)"; oNewItem = oForm.Items.Add("Apr_Contr", SAPbouiCOM.BoFormItemTypes.it_EDIT); oNewItem.Top = oItem.Top + 305; oNewItem.Height = 17; oNewItem.Width = 40; oNewItem.Left = 840; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oEditItem = ((SAPbouiCOM.EditText)(oNewItem.Specific)); oNewItem = oForm.Items.Add("Apr_Amb", SAPbouiCOM.BoFormItemTypes.it_MATRIX); oNewItem.Left = 25; oNewItem.Width = 420; oNewItem.Top = oItem.Top + 85; oNewItem.Height = 110; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oMatrix = ((SAPbouiCOM.Matrix)(oNewItem.Specific)); oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto; oColumns = oMatrix.Columns; oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "#"; oColumn.Width = 30; oColumn.Editable = false; oColumn = oColumns.Add("Apr_Amb_C0", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Ambiente"; oColumn.Width = 80; oColumn.Editable = false; oColumn = oColumns.Add("Apr_Amb_C1", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Detalhamento"; oColumn.Width = 100; oColumn.Editable = true; oColumn = oColumns.Add("Apr_Amb_C2", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Id"; oColumn.Editable = true; oColumn.Visible = false; oForm.DataSources.DataTables.Item("oMatrixDT").ExecuteQuery("SELECT T1.[Num], T1.[Descript], T0.* FROM OPR4 T0 INNER JOIN OOIN T1 ON T1.Num = T0.IntId WHERE T0.[OprId] = '1'"); oColumn = oColumns.Item("Apr_Amb_C0"); oColumn.DataBind.Bind("oMatrixDT", "Descript"); oColumn = oColumns.Item("Apr_Amb_C1"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_ANC_DETALHA"); oColumn = oColumns.Item("Apr_Amb_C2"); oColumn.DataBind.Bind("oMatrixDT", "Line"); oNewItem = oForm.Items.Add("NvAnalise", SAPbouiCOM.BoFormItemTypes.it_BUTTON); oNewItem.Top = oItem.Top + 35; oNewItem.Width = 140; oNewItem.Left = oForm.Width - 270; oNewItem.Height = 21; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oNewItem.Visible = true; oButton = ((SAPbouiCOM.Button)(oNewItem.Specific)); oButton.Caption = "Nova análise crítica"; oNewItem = oForm.Items.Add("Ans_Amb", SAPbouiCOM.BoFormItemTypes.it_MATRIX); SAPbouiCOM.Item teste = oForm.Items.Item("Apr_Amb"); oNewItem.Left = oForm.Width - 270; oNewItem.Width = 200; oNewItem.Top = oItem.Top + 85; oNewItem.Height = 110; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oMatrix = ((SAPbouiCOM.Matrix)(oNewItem.Specific)); oMatrix.SelectionMode = SAPbouiCOM.BoMatrixSelect.ms_Auto; oColumns = oMatrix.Columns; oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "#"; oColumn.Width = 30; oColumn.Editable = false; oColumn = oColumns.Add("Ans_Amb_C0", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Analise Crítica"; oColumn.Width = 120; oColumn.Editable = true; oColumn = oColumns.Add("Ans_Amb_C1", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Id"; oColumn.Editable = true; oColumn.Visible = false; DBDSflx = oForm.DataSources.DBDataSources.Add("@FLX_FB_CONFMED"); oForm.DataSources.DataTables.Add("oDataTableAnalise"); oForm.DataSources.DataTables.Item("oDataTableAnalise").ExecuteQuery("SELECT * FROM [@FLX_FB_ANLCRI] where U_FLX_FB_ANLCRI_ID = '1' and U_FLX_FB_ANLCRI_AMBI = '1'"); oColumn = oColumns.Item("Ans_Amb_C0"); oColumn.DataBind.Bind("oDataTableAnalise", "U_FLX_FB_ANLCRI_ANEX"); oColumn = oColumns.Item("Ans_Amb_C1"); oColumn.DataBind.Bind("oDataTableAnalise", "Code"); oNewItem = oForm.Items.Add("Apv_Amb", SAPbouiCOM.BoFormItemTypes.it_MATRIX); oNewItem.Left = 25; oNewItem.Width = 700; oNewItem.Top = oItem.Top + 220; oNewItem.Height = 110; oNewItem.FromPane = 12; oNewItem.ToPane = 12; oMatrix = ((SAPbouiCOM.Matrix)(oNewItem.Specific)); oColumns = oMatrix.Columns; oColumn = oColumns.Add("#", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "#"; oColumn.Width = 30; oColumn.Editable = false; oColumn = oColumns.Add("Apv_Amb_C0", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Ambiente"; oColumn.Width = 80; oColumn.Editable = false; oColumn = oColumns.Add("Apv_Amb_C1", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX); oColumn.TitleObject.Caption = "Aprovado por"; oColumn.Width = 100; oColumn.Editable = true; oColumn = oColumns.Add("Apv_Amb_C2", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Data Aprovação"; oColumn.Width = 80; oColumn.Editable = true; oColumn = oColumns.Add("Apv_Amb_C3", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "PDFs visto com o cliente"; oColumn.Width = 120; oColumn.Editable = true; oColumn = oColumns.Add("Apv_Amb_C4", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Prancha de Imagem"; oColumn.Width = 120; oColumn.Editable = true; oColumn = oColumns.Add("Apv_Amb_C5", SAPbouiCOM.BoFormItemTypes.it_EDIT); oColumn.TitleObject.Caption = "Memorial Descritivo"; oColumn.Width = 130; oColumn.Editable = true; oForm.DataSources.DataTables.Item("oMatrixDT").ExecuteQuery("SELECT T1.[Num], T1.[Descript], T0.* FROM OPR4 T0 INNER JOIN OOIN T1 ON T1.Num = T0.IntId WHERE T0.[OprId] = '1'"); oColumn = oColumns.Item("Apv_Amb_C0"); oColumn.DataBind.Bind("oMatrixDT", "Descript"); oColumn = oColumns.Item("Apv_Amb_C1"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_APR_APROVAD"); oColumn = oColumns.Item("Apv_Amb_C2"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_APR_DATAAPR"); oColumn = oColumns.Item("Apv_Amb_C3"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_APR_PDFCLIE"); oColumn = oColumns.Item("Apv_Amb_C4"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_APR_PRANIMG"); oColumn = oColumns.Item("Apv_Amb_C5"); oColumn.DataBind.Bind("oMatrixDT", "U_FLX_FB_APR_MEMDESC"); }
/// <summary> /// Initialize components. Called by framework after form created. /// </summary> public override void OnInitializeComponent() { this.mtxItems = ((SAPbouiCOM.Matrix)(this.GetItem("mtxItems").Specific)); this.txtDocNo = ((SAPbouiCOM.EditText)(this.GetItem("txtDocNo").Specific)); this.dtTransferItemLines = this.UIAPIRawForm.DataSources.DBDataSources.Item(string.Format("@{0}", TableNames.TransferItemsLines)); this.dpDocDate = ((SAPbouiCOM.EditText)(this.GetItem("dpDocDate").Specific)); this.mtxItems.ChooseFromListBefore += new SAPbouiCOM._IMatrixEvents_ChooseFromListBeforeEventHandler(this.mtxItems_ChooseFromListBefore); this.mtxItems.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.mtxItems_ChooseFromListAfter); this.mtxItems.ClickBefore += new SAPbouiCOM._IMatrixEvents_ClickBeforeEventHandler(this.mtxItems_ClickBefore); this.btnSave = ((SAPbouiCOM.Button)(this.GetItem("1").Specific)); this.btnSave.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.btnSave_ClickBefore); this.btnSave.PressedBefore += new SAPbouiCOM._IButtonEvents_PressedBeforeEventHandler(this.btnSave_PressedBefore); this.btnCancel = ((SAPbouiCOM.Button)(this.GetItem("2").Specific)); this.fldrItems = ((SAPbouiCOM.Folder)(this.GetItem("Item_5").Specific)); this.fldrCosts = ((SAPbouiCOM.Folder)(this.GetItem("Item_6").Specific)); this.mtxCost = ((SAPbouiCOM.Matrix)(this.GetItem("Item_7").Specific)); this.mtxCost.ChooseFromListAfter += new SAPbouiCOM._IMatrixEvents_ChooseFromListAfterEventHandler(this.mtxCost_ChooseFromListAfter); this.mtxCost.ClickBefore += new SAPbouiCOM._IMatrixEvents_ClickBeforeEventHandler(this.mtxCost_ClickBefore); //this.btnCalculate = ((SAPbouiCOM.Button)(this.GetItem("btnClc").Specific)); //this.btnCalculate.ClickAfter += new SAPbouiCOM._IButtonEvents_ClickAfterEventHandler(this.btnCalculate_ClickAfter); //this.btnCalculate.ClickBefore += new SAPbouiCOM._IButtonEvents_ClickBeforeEventHandler(this.btnCalculate_ClickBefore); this.btnAddRow = ((SAPbouiCOM.Button)(this.GetItem("btnAddRow").Specific)); this.btnAddRow.ClickBefore += btnAddRow_ClickBefore; this.btnAddRow.ClickAfter += btnAddRow_ClickAfter; this.mtxItems.ValidateBefore += mtxItems_ValidateBefore; this.OnCustomInitialize(); }
private void Importar_Anexos_Desde_Origen() { try { oForm.Freeze(true); SAPbouiCOM.DBDataSource source = oForm.DataSources.DBDataSources.Item("OPCH"); string sDocEntry = source.GetValue("DocEntry", source.Offset); int iAtcEntry = int.TryParse(source.GetValue("AtcEntry", source.Offset), out iAtcEntry) ? iAtcEntry : 0; //SAPbobsCOM.Documents oPurchaseOrders = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oPurchaseOrders); //oPurchaseOrders.GetByKey(Convert.ToInt32(sDocEntry)); string sql = "select distinct BaseRef,BaseType,BaseEntry from PCH1 where docentry = " + sDocEntry; DT_SQL.ExecuteQuery(sql); if (!DT_SQL.IsEmpty) { for (int i = 0; i < DT_SQL.Rows.Count; i++) { SAPbobsCOM.Recordset oRecordset = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); SAPbouiCOM.Matrix oMatrix = null; SAPbouiCOM.EditText oEdit = null; string sBaseType = DT_SQL.GetValue("BaseType", i).ToString(); string sBaseRef = DT_SQL.GetValue("BaseRef", i).ToString(); string sBaseEntry = DT_SQL.GetValue("BaseEntry", i).ToString(); string sTable = ""; switch (sBaseType) { case "20": //Orden Compra sql = "select distinct BaseRef,BaseType,BaseEntry from PDN1 where docentry = " + sBaseEntry; DT_SQL3.ExecuteQuery(sql); if (!DT_SQL3.IsEmpty) { sBaseType = DT_SQL3.GetValue("BaseType", 0).ToString(); if (sBaseType == "22") { sTable = "OPOR"; sBaseRef = DT_SQL3.GetValue("BaseRef", 0).ToString(); } } break; case "22": //Orden Compra sTable = "OPOR"; break; case "1470000113": //Solicitud de Compra sTable = "OPRQ"; break; } if (sTable.Trim().Length > 0) { sql = "SELECT AtcEntry FROM " + sTable + " WHERE AtcEntry is not null AND DocNum = " + sBaseRef; DT_SQL2.ExecuteQuery(sql); if (!DT_SQL2.IsEmpty) { SAPbobsCOM.Attachments2 oAtt = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); oAtt.GetByKey(Convert.ToInt32(DT_SQL2.GetValue("AtcEntry", 0))); //SAPbobsCOM.Attachments2 oAttN = (SAPbobsCOM.Attachments2)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oAttachments2); //if (iAtcEntry > 0) //{ // oAttN.GetByKey(iAtcEntry); //} oMatrix = (SAPbouiCOM.Matrix)oForm.Items.Item("1320002138").Specific; int rowNum = oMatrix.RowCount + 1; sql = @"select AttachPath from OADP"; oRecordset.DoQuery(sql); string RutaDestino = oRecordset.Fields.Item(0).Value.ToString(); for (int x = 0; x < oAtt.Lines.Count; x++) { sql = @"SELECT RTRIM(CAST(trgtPath as nvarchar(200)))+'\'+FileName+'.'+FileExt from ATC1 where AbsEntry = " + DT_SQL2.GetValue("AtcEntry", 0) + " AND Line = " + (x + 1).ToString(); oRecordset.DoQuery(sql); string RutaServ = oRecordset.Fields.Item(0).Value.ToString(); oMatrix.AddRow(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = RutaDestino; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000003").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetDirectoryName(RutaServ); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000004").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetFileNameWithoutExtension(RutaServ); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000005").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = System.IO.Path.GetExtension(RutaServ).Substring(1); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000007").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = DateTime.Now.ToShortDateString(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000001").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = rowNum.ToString(); //Se vuelve a cargar la primera fila para que no avance el scroll horizontal al final. oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("1320000002").Cells.Item(rowNum).Specific; oEdit.Active = true; oEdit.Item.Enabled = true; oEdit.String = RutaDestino; rowNum += 1; //oAtt.Lines.SetCurrentLine(x); //oAttN.Lines.Add(); //oAttN.Lines.FileName = System.IO.Path.GetFileNameWithoutExtension(RutaServ); //oAttN.Lines.FileExtension = System.IO.Path.GetExtension(RutaServ).Substring(1); //oAttN.Lines.SourcePath = System.IO.Path.GetDirectoryName(RutaServ); //oAttN.Lines.Override = SAPbobsCOM.BoYesNoEnum.tYES; //if (iAtcEntry > 0) //{ // if (oAttN.Update() != 0) // throw new Exception(oCompany.GetLastErrorDescription()); //} //else //{ // int iAttEntry = -1; // if (oAttN.Add() == 0) // { // iAttEntry = int.Parse(oCompany.GetNewObjectKey()); // //Assign the attachment to the GR object (GR is my SAPbobsCOM.Documents object) // oPurchaseOrders.AttachmentEntry = iAttEntry; // } //} } System.Runtime.InteropServices.Marshal.ReleaseComObject(oRecordset); } } } } //System.Runtime.InteropServices.Marshal.ReleaseComObject(oPurchaseOrders); //oPurchaseOrders = null; GC.Collect(); } catch (Exception) { } finally { oForm.Freeze(false); } }