public override void etAfterCfl(ref ItemEvent pVal, ref bool BubbleEvent) { base.etAfterCfl(ref pVal, ref BubbleEvent); SAPbouiCOM.IChooseFromListEvent oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pVal; SAPbouiCOM.DataTable dtSel = oCFLEvento.SelectedObjects; if (pVal.ItemUID == txCode.Item.UniqueID) { if (dtSel.Rows.Count > 0) { string strCode = ""; string strName = ""; if (oCFLEvento.ChooseFromListUID == "cflCode") { strCode = dtSel.GetValue("ItemCode", 0).ToString(); strName = dtSel.GetValue("ItemName", 0).ToString(); } if (oCFLEvento.ChooseFromListUID == "cflGroup") { strCode = dtSel.GetValue("ItmsGrpCod", 0).ToString(); strName = dtSel.GetValue("ItmsGrpNam", 0).ToString(); } dtHead.SetValue("Code", 0, strCode); dtHead.SetValue("Name", 0, strName); } } }
private Boolean ValidarDataTable(String Cuenta) { try { for (Int32 i = 0; i < odt.Rows.Count; i++) { if (((System.String)odt.GetValue("U_CtaSAP", i)) != "") { if (((System.String)odt.GetValue("U_CtaSAP", i)).Trim() == Cuenta) { FSBOApp.StatusBar.SetText("Cuenta " + Cuenta + " ya se encuentra ingresada en el formulario", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); return(false); } } } return(true); } catch (Exception a) { FSBOApp.StatusBar.SetText("ValidarDataTable: " + a.Message + " ** Trace: " + a.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("ValidarDataTable: " + a.Message + " ** Trace: " + a.StackTrace); return(false); } }
public override void etAfterClick(ref ItemEvent pVal, ref bool BubbleEvent) { base.etAfterClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == "1") { Program.objHrmsUI.SaveSetting("WebCardCode", Convert.ToString(dtHead.GetValue("CardCode", 0))); Program.objHrmsUI.SaveSetting("WebSlpCode", Convert.ToString(dtHead.GetValue("slp", 0))); Program.objHrmsUI.SaveSetting("WebBranch", Convert.ToString(dtHead.GetValue("branch", 0))); Program.objHrmsUI.SaveSetting("Warehouse", Convert.ToString(dtHead.GetValue("Whs", 0))); } }
}//fin InitForm public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent) { Int32 nErr; String sErr; base.FormEvent(FormUID, ref pVal, ref BubbleEvent); try { if (pVal.ItemUID == "3") { if ((pVal.ColUID == "Code") && (!pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_COMBO_SELECT)) { if (pVal.Row == oDataTable.Rows.Count - 1) { if ((System.String)(oDataTable.GetValue("Code", oDataTable.Rows.Count - 1)) != "") { oDataTable.Rows.Add(1); oDataTable.SetValue("Code", oDataTable.Rows.Count - 1, ""); oDataTable.SetValue("Name", oDataTable.Rows.Count - 1, ""); } } } } if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (pVal.BeforeAction)) { var paso = false; if ((pVal.ItemUID == "1") && ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE))) { BubbleEvent = false; if (LimpiarGrid()) { paso = CrearDatos(); } if ((paso) && (oForm.Mode != BoFormMode.fm_OK_MODE)) { oForm.Mode = BoFormMode.fm_OK_MODE; } } else if ((pVal.ItemUID == "1") && (oForm.Mode == BoFormMode.fm_OK_MODE)) { BubbleEvent = true; } } } catch (Exception e) { FCmpny.GetLastError(out nErr, out sErr); FSBOApp.StatusBar.SetText("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace); } }//fin FormEvent
public override void etAfterClick(ref ItemEvent pVal, ref bool BubbleEvent) { base.etAfterClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == mtWO.Item.UniqueID) { if (pVal.ColUID == "V_3" && pVal.Row == 0) { selectAllWO(); } } if (pVal.ItemUID == "btSync") { SyncCompanyItem(); } if (pVal.ItemUID == btGet.Item.UniqueID) { if (txFrom.Value.ToString() == "") { return; } if (txTo.Value.ToString() == "") { return; } getOrders(); } if (pVal.ItemUID == "btST") { // addShipment( Convert.ToString( dtORDR.GetValue("WBID", 0))); } if (pVal.ItemUID == mtWO.Item.UniqueID && pVal.ColUID == "V_-1" && pVal.Row > 0 && pVal.Row <= mtWO.RowCount) { string incrementId = Convert.ToString(dtWebO.GetValue("WebNum", pVal.Row - 1)); addWebOrder(incrementId); } if (pVal.ItemUID == "btPost") { int confirm = oApplication.MessageBox("Are you sure you want to Post Order To SBO", 2, "Yes", "No"); if (confirm != 1) { return; } ProcessPosting(); //postDocument(); } }
private void mtxInvoices_LinkPressedAfter(object sboObject, SBOItemEventArg pVal) { try { if (pVal.ColUID == "C_Fact") { string lStrDocEntry = DtMatrixInvoice.GetValue("C_DocEntry", pVal.Row - 1).ToString(); SAPbouiCOM.Framework.Application.SBO_Application.OpenForm(BoFormObjectEnum.fo_Invoice, "", lStrDocEntry); } } catch (Exception ex) { } }
public static String CrearXMLDiccionario(String Periodo, SAPbouiCOM.DataTable odt, SAPbouiCOM.Application FSBOApp) { String NomCol; try { s = @"<LceCoCierre version=""1.0""><LceDiccionario version=""1.0""><DocumentoDiccionario ID=""DICC{0}"">"; s = String.Format(s, Periodo.Replace("-", ".")); NomCol = odt.Columns.Item(0).Name; var Col = NomCol.Split('/'); s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[0], Col[1], ((System.String)odt.GetValue(0, 0)).Trim()); NomCol = odt.Columns.Item(1).Name; Col = NomCol.Split('/'); s = s + @"<{1}>{2}</{1}></{0}>"; s = String.Format(s, Col[0], Col[1], ((System.String)odt.GetValue(1, 0)).Trim()); for (Int32 i = 0; i < odt.Rows.Count; i++) { NomCol = odt.Columns.Item(2).Name; Col = NomCol.Split('/'); var sFin = Col[0]; s = s + @"<{0}>"; s = String.Format(s, sFin); for (Int32 c = 2; c < odt.Columns.Count - 1; c++) { NomCol = odt.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[1], ((System.String)odt.GetValue(c, i)).Trim()); } s = s + @"</{0}>"; s = String.Format(s, sFin); } s = s + @"</DocumentoDiccionario></LceDiccionario></LceCoCierre>"; return(s); } catch (Exception z) { FSBOApp.StatusBar.SetText(z.Message + " ** Trace: " + z.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); //OutLog("CrearXMLDiccionario: " + z.Message + " ** Trace: " + z.StackTrace); return(""); } }
}//fin MenuEvent private void BorrarLinea() { Int32 sCode; Boolean bPaso; try { bPaso = false; ogrid = ((Grid)oForm.Items.Item("ogrid").Specific); odt = ogrid.DataTable; for (Int32 iCont_1 = 0; iCont_1 < odt.Rows.Count; iCont_1++) { if (((System.String)odt.GetValue("U_CardCode", iCont_1)).Length > 0) { if (ogrid.Rows.IsSelected(iCont_1)) { sCode = ((System.Int32)odt.GetValue("DocEntry", iCont_1)); if (sCode != 0) { if (Funciones.DelDataSource("D", "VID_FELISTANE", "", sCode)) { odt.Rows.Remove(iCont_1); oForm.Mode = BoFormMode.fm_OK_MODE; FSBOApp.StatusBar.SetText("Linea eliminada correctamente", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); bPaso = true; break; } } else { odt.Rows.Remove(iCont_1); FSBOApp.StatusBar.SetText("Linea eliminada correctamente", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); bPaso = true; } } } } if (bPaso == false) { FSBOApp.StatusBar.SetText("Debe seleccionar una linea", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); } } catch (Exception g) { FSBOApp.StatusBar.SetText(g.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("BorrarLinea: " + g.Message + " ** Trace: " + g.StackTrace); } }
public override void etAfterCfl(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterCfl(ref pVal, ref BubbleEvent); SAPbouiCOM.IChooseFromListEvent oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pVal; SAPbouiCOM.DataTable dtSel = oCFLEvento.SelectedObjects; if (pVal.ItemUID == txDfltExp.Item.UniqueID) { if (dtSel != null && dtSel.Rows.Count > 0) { string strCode = dtSel.GetValue("AcctCode", 0).ToString(); string strName = dtSel.GetValue("AcctName", 0).ToString(); dtSetting.SetValue("dfltExp", 0, strCode); oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE; } } }
private void CargarGrid() { try { ogrid = ((Grid)oForm.Items.Item("ogrid").Specific); odt = ogrid.DataTable; if (GlobalSettings.RunningUnderSQLServer) { s = @"SELECT DocEntry, U_CardCode, U_CardName, U_Activado FROM [@VID_FELISTANE]"; } else { s = @"SELECT ""DocEntry"", ""U_CardCode"", ""U_CardName"", ""U_Activado"" FROM ""@VID_FELISTANE"" "; } ogrid.DataTable.ExecuteQuery(s); ogrid.Columns.Item("DocEntry").Type = BoGridColumnType.gct_EditText; var oColumn = ((GridColumn)ogrid.Columns.Item("DocEntry")); ((EditTextColumn)oColumn).Editable = false; ((EditTextColumn)oColumn).TitleObject.Caption = "DocEntry"; ((EditTextColumn)oColumn).Visible = false; ogrid.Columns.Item("U_CardCode").Type = BoGridColumnType.gct_EditText; oColumn = ((GridColumn)ogrid.Columns.Item("U_CardCode")); ((EditTextColumn)oColumn).Editable = true; ((EditTextColumn)oColumn).TitleObject.Caption = "Codigo SN"; ((EditTextColumn)oColumn).Visible = true; ((EditTextColumn)oColumn).LinkedObjectType = "2"; ((EditTextColumn)oColumn).ChooseFromListUID = "CFL0"; ((EditTextColumn)oColumn).ChooseFromListAlias = "CardCode"; ogrid.Columns.Item("U_CardName").Type = BoGridColumnType.gct_EditText; oColumn = ((GridColumn)ogrid.Columns.Item("U_CardName")); ((EditTextColumn)oColumn).Editable = false; ((EditTextColumn)oColumn).TitleObject.Caption = "Razón Social"; ((EditTextColumn)oColumn).Visible = true; ogrid.Columns.Item("U_Activado").Type = BoGridColumnType.gct_CheckBox; var oColumnchx = ((GridColumn)ogrid.Columns.Item("U_Activado")); ((CheckBoxColumn)oColumnchx).Editable = true; ((CheckBoxColumn)oColumnchx).TitleObject.Caption = "Activo"; ((CheckBoxColumn)oColumnchx).Visible = true; ogrid.AutoResizeColumns(); if (((System.String)odt.GetValue("U_CardCode", 0)).Trim() != "") { odt.Rows.Add(); } FSBOApp.StatusBar.SetText("Lista Negra cargada", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); } catch (Exception e) { FSBOApp.StatusBar.SetText(e.Message, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("CargarGrid: " + e.Message + " ** Trace: " + e.StackTrace); } }
public override void etAfterCfl(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterCfl(ref pVal, ref BubbleEvent); SAPbouiCOM.IChooseFromListEvent oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pVal; SAPbouiCOM.DataTable dtSel = oCFLEvento.SelectedObjects; if (pVal.ItemUID == "txCode") { string CardCode = ""; string CardName = ""; if (dtSel != null && dtSel.Rows.Count > 0) { for (int i = 0; i < dtSel.Rows.Count; i++) { CardCode = dtSel.GetValue("CardCode", i).ToString(); CardName = dtSel.GetValue("CardName", i).ToString(); } // mtCus.SetLineData(pVal.Row); dtHead.Rows.Remove(0); dtHead.Rows.Add(1); dtHead.SetValue("CardCode", 0, CardCode); dtHead.SetValue("CardName", 0, CardName); AddNewCardSche(CardCode); getSchedule(); } } if (pVal.ItemUID == "txICode") { if (dtSel != null && dtSel.Rows.Count > 0) { string ItemCode = "", ItemName = ""; for (int i = 0; i < dtSel.Rows.Count; i++) { ItemCode = dtSel.GetValue("ItemCode", i).ToString(); ItemName = dtSel.GetValue("ItemName", i).ToString(); } // mtCus.SetLineData(pVal.Row); dtHead.SetValue("ItemCode", 0, ItemCode); dtHead.SetValue("ItemName", 0, ItemName); } } if (pVal.ItemUID == "txOICODE") { if (dtSel != null && dtSel.Rows.Count > 0) { string ItemCode = "", ItemName = ""; for (int i = 0; i < dtSel.Rows.Count; i++) { ItemCode = dtSel.GetValue("ItemCode", i).ToString(); ItemName = dtSel.GetValue("ItemName", i).ToString(); } // mtCus.SetLineData(pVal.Row); dtHead.SetValue("OSCNCode", 0, ItemCode); dtHead.SetValue("OSCNName", 0, ItemName); } } }
public override void etAfterCfl(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterCfl(ref pVal, ref BubbleEvent); SAPbouiCOM.IChooseFromListEvent oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pVal; SAPbouiCOM.DataTable dtSel = oCFLEvento.SelectedObjects; try { if (pVal.ItemUID == txSupplier.Item.UniqueID) { if (dtSel != null && dtSel.Rows.Count > 0) { string strCode = dtSel.GetValue("CardCode", 0).ToString(); string strName = dtSel.GetValue("CardName", 0).ToString(); oForm.DataSources.UserDataSources.Item("txSupplier").ValueEx = strCode; oForm.DataSources.UserDataSources.Item("txPD").ValueEx = DateTime.Now.Date.ToString("yyyyMMdd"); // oForm.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE; } } } catch { } }
private void ChooseFromListAfterEvent(ItemEvent pObjValEvent) { try { if (pObjValEvent.Action_Success) { SAPbouiCOM.IChooseFromListEvent lObjCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pObjValEvent; if (lObjCFLEvento.SelectedObjects != null) { SAPbouiCOM.DataTable lObjDataTable = lObjCFLEvento.SelectedObjects; if (lObjDataTable != null) { this.UIAPIRawForm.DataSources.UserDataSources.Item(lObjDataTable.UniqueID).ValueEx = System.Convert.ToString(lObjDataTable.GetValue(0, 0)); switch (lObjDataTable.UniqueID) { case "CFL_Area": string lStrArea = lObjDataTable.GetValue(0, 0).ToString(); this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Area").ValueEx = lStrArea; this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Employ").ValueEx = ""; AddConditionChoseFromListEmployee(mObjCFLEmployee, mObjPurchasesServiceFactory.GetPurchaseService().GetDepartment(lStrArea)); break; case "CFL_Employ": this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Employ").ValueEx = lObjDataTable.GetValue(2, 0).ToString() + " " + lObjDataTable.GetValue(3, 0).ToString() + lObjDataTable.GetValue(1, 0).ToString(); mStrEmployeId = lObjDataTable.GetValue(0, 0).ToString(); break; } } } } } catch (Exception ex) { LogService.WriteError("frmSearchRefunds (ChooseFromListAfterEvent) " + ex.Message); LogService.WriteError(ex); } }
private void updateModuleSetup() { mtAddon.FlushToDataSource(); string updateAddon = ""; for (int i = 0; i < dtHead.Rows.Count; i++) { updateAddon += "Update [@B1_MODULES] set U_LicenseKey='" + dtHead.GetValue("LK", i).ToString() + "',U_Enabled='" + dtHead.GetValue("Active", i).ToString() + "' where Code='" + dtHead.GetValue("AC", i).ToString() + "' ;"; } int result = Program.objHrmsUI.ExecQuery(updateAddon, "Updating Module Setup"); saveSettings(); Program.objHrmsUI.createConfigurationTables(); Program.objHrmsUI.loadSettings(); Program.objHrmsUI.loadAddons(); }
private void ChooseFromListAfterEvent(SAPbouiCOM.ItemEvent pObjValEvent) { if (pObjValEvent.Action_Success) { SAPbouiCOM.IChooseFromListEvent lObjCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pObjValEvent; SAPbouiCOM.DataTable lObjDataTable = lObjCFLEvento.SelectedObjects; if (lObjCFLEvento.SelectedObjects == null) { return; } if (lObjDataTable.UniqueID == "CFL_Item") { txtCode.Value = Convert.ToString(lObjDataTable.GetValue(0, 0)); this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Item").ValueEx = Convert.ToString(lObjDataTable.GetValue(1, 0)); requireBagsField = lObjDistributionDAO.GetIsBagRequired(txtCode.Value); } else if (lObjDataTable.UniqueID == "CFL_Whs") { this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Whs").ValueEx = Convert.ToString(lObjDataTable.GetValue(0, 0)); } } }
public override void etAfterCmbSelect(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterCmbSelect(ref pVal, ref BubbleEvent); if (pVal.ItemUID == cbPWHS.Item.UniqueID) { int selListRow = mtSelRow(mtList); if (selListRow > 0) { string IGcode = Convert.ToString(dtList.GetValue("Code", selListRow - 1)); string strUpdate = "UPDATE \"@B1_QA_OUSR\" SET \"U_PWHS\" = '" + cbPWHS.Selected.Value.ToString().Trim() + "' WHERE \"Code\" = '" + IGcode + "'"; Program.objHrmsUI.ExecQuery(strUpdate, "Update Production WHS"); } else { oApplication.MessageBox("Please select User"); } } }
}//fin InitForm public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent) { SAPbouiCOM.DataTable oDataTable; SAPbouiCOM.IChooseFromListEvent oCFLEvento = null; String sValue; String sValue2; base.FormEvent(FormUID, ref pVal, ref BubbleEvent); try { if (pVal.EventType == BoEventTypes.et_ITEM_PRESSED) { if (pVal.BeforeAction == true) { if (((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)) && (pVal.ItemUID == "1")) { BubbleEvent = false; if (Validar()) { Guardar_Registros(); } } } if ((pVal.BeforeAction == false) && (pVal.ItemUID == "btn_Borrar")) { BorrarLinea(); } } if ((pVal.EventType == BoEventTypes.et_CHOOSE_FROM_LIST) && (!pVal.BeforeAction)) { oForm.Freeze(true); if (pVal.ColUID == "U_CardCode") { oCFLEvento = (SAPbouiCOM.IChooseFromListEvent)(pVal); oDataTable = oCFLEvento.SelectedObjects; if (oDataTable != null) { sValue = ((System.String)oDataTable.GetValue("CardCode", 0)).Trim(); sValue2 = ((System.String)oDataTable.GetValue("CardName", 0)).Trim(); for (Int32 iCont_1 = 0; iCont_1 < odt.Rows.Count; iCont_1++) { if (((System.String)odt.GetValue("U_CardCode", iCont_1)).Length > 0) { var CardCode = ((System.String)odt.GetValue("U_CardCode", iCont_1)); if (CardCode == sValue) { FSBOApp.StatusBar.SetText("Proveedor ya se encuentra en la lista Negra", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); return; } } } if (GlobalSettings.RunningUnderSQLServer) { s = @"SELECT COUNT(*) 'count' FROM [@VID_FELISTABL] WHERE U_CardCode = '{0}'"; } else { s = @"SELECT COUNT(*) ""count"" FROM ""@VID_FELISTABL"" WHERE ""U_CardCode"" = '{0}'"; } s = String.Format(s, sValue); oRecordSet.DoQuery(s); if (((System.Int32)oRecordSet.Fields.Item("count").Value) > 0) { FSBOApp.StatusBar.SetText("Codigo Proveedor se encuentra en la lista blanca, no se puede seleccionar -> Codigo " + sValue, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); return; } odt.SetValue("U_CardCode", pVal.Row, sValue); odt.SetValue("U_CardName", pVal.Row, sValue2); odt.SetValue("U_Activado", pVal.Row, "Y"); if ((odt.Rows.Count - 1 == pVal.Row) && (sValue != "")) { odt.Rows.Add(1); } ogrid.AutoResizeColumns(); if (oForm.Mode == BoFormMode.fm_OK_MODE) { oForm.Mode = BoFormMode.fm_UPDATE_MODE; } } } } } catch (Exception e) { if (FCmpny.InTransaction) { FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack); } FSBOApp.StatusBar.SetText(e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace); } finally { if (oForm != null) { oForm.Freeze(false); } } }//fin FormEvent
public override void etAfterClick(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == mtOSCN.Item.UniqueID) { if (pVal.ColUID == "Id" && pVal.Row > 0) { getOSCNDetail(); } } if (pVal.ItemUID == mtOSCN.Item.UniqueID) { if (pVal.ColUID == "Id" && pVal.Row > 0) { getOSCNDetail(); } } if (pVal.ItemUID == "btUC") { updateOSCN(); } if (pVal.ItemUID == "btOAdd") { addOSCN(); } if (pVal.ItemUID == "btImg") { addAttacment(); } if (pVal.ItemUID == "tbTS") { currentTab = "TS"; getSchedule(); } if (pVal.ItemUID == "tbSO") { currentTab = "SO"; getSchedule(); } if (pVal.ItemUID == "1") { updateSchedule(); } if (pVal.ItemUID == "btAddDt") { string cardCode = Convert.ToString(dtHead.GetValue("CardCode", 0)); addMODT(cardCode); } if (pVal.ItemUID == "btRemDt") { string cardCode = Convert.ToString(dtHead.GetValue("CardCode", 0)); remMODT(cardCode); } if (pVal.ItemUID == "btAddWD") { string cardCode = Convert.ToString(dtHead.GetValue("CardCode", 0)); addMODay(cardCode); } if (pVal.ItemUID == "btRemWD") { string cardCode = Convert.ToString(dtHead.GetValue("CardCode", 0)); remMODay(cardCode); } if (pVal.ItemUID == "btAdd") { addSOItem(); } if (pVal.ItemUID == "btOTAdd") { string cardCode = Convert.ToString(dtHead.GetValue("CardCode", 0)); string otDT = Convert.ToString(dtHead.GetValue("otDT", 0)); if (cardCode == "") { oApplication.MessageBox("Select Customer"); return; } if (otDT == "") { oApplication.MessageBox("Select Date"); return; } addOT(cardCode); } if (pVal.ItemUID == "btRem") { int selRow = mtSelRow(mtItem); string rowId = Convert.ToString(dtItem.GetValue("Id", selRow - 1)); dtItem.Rows.Remove(selRow - 1); mtItem.LoadFromDataSource(); string strInsert = " Delete From [@B1_SO] where Code='" + rowId + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Delete SO Item"); } if (pVal.ItemUID == "btOTRem") { int selRow = mtSelRow(mtOT); string rowId = Convert.ToString(dtOT.GetValue("Id", selRow - 1)); dtOT.Rows.Remove(selRow - 1); mtOT.LoadFromDataSource(); string strInsert = " Delete From [@B1_SCHOT] where Code='" + rowId + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Delete OT Date"); } }
public override void etAfterActClick(ref ItemEvent pVal, ref bool BubbleEvent) { base.etAfterActClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == "btFinal") { int confirm = oApplication.MessageBox("Are you sure you want to post stock?", 2, "Yes", "No"); if (confirm == 1) { int postingStatus = -1; int trsnsferResult = -1; int selRow = mtSelRow(mtDocs); if (selRow > 0) { string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string docType = Convert.ToString(dtDoc.GetValue("DT", selRow - 1)); if (docType == "Offer for Inspection") { string strProdNum = "SELECT \"U_B1_QA_INSP_PN\" FROM \"OIGN\" WHERE \"DocEntry\" ='" + dn + "'"; System.Data.DataTable dtProdNum = Program.objHrmsUI.getDataTable(strProdNum, "ProdNum"); if (dtProdNum != null && dtProdNum.Rows.Count > 0) { if (dtProdNum.Rows[0]["U_B1_QA_INSP_PN"] != DBNull.Value && Convert.ToInt32(dtProdNum.Rows[0]["U_B1_QA_INSP_PN"]) > 0) { postingStatus = ReleaseInspaction(dn); } } } else { postingStatus = PostTransfer(strCode, dn); } string strDocCode = strCode + "-" + dn; if (strCode.Trim() != "" && postingStatus != -1) { string strInsert = "UPDATE \"@B1_QA_DOC\" SET \"U_Date\" = '" + DateTime.Now.ToString("yyyyMMdd") + "' , \"U_Final\"='Y' , \"U_WTRentry\" = '" + postingStatus + "' WHERE \"Code\" = '" + strDocCode + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Finalllizing Inspaction"); } } // _iniForm(); getDocs(); } } if (pVal.ItemUID == "btPrint") { SAPbouiCOM.Menus mnus = oApplication.Menus; if (mnus.Exists(printMenuId) && printMenuId != "") { int selRow = mtSelRow(mtDocs); string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); mnus.Item(printMenuId).Activate(); SAPbouiCOM.Form prmForm = oApplication.Forms.ActiveForm; EditText objType = (SAPbouiCOM.EditText)prmForm.Items.Item("1000003").Specific; EditText DocKey = (SAPbouiCOM.EditText)prmForm.Items.Item("1000009").Specific; SAPbouiCOM.Button ok = (SAPbouiCOM.Button)prmForm.Items.Item("1").Specific; // SAPbouiCOM.Button cancel = (SAPbouiCOM.Button)prmForm.Items.Item("2").Specific; objType.Value = strCode; DocKey.Value = dn; prmForm.ActiveItem = ok.Item.UniqueID; objType.Item.Enabled = false; // DocKey.Item.Enabled = false; ok.Item.Click(); // prmForm.Select(); // cancel.Item.Click(); } else { oApplication.MessageBox("Please upload \"Inspection Report\" in production report menu"); } } if (pVal.ItemUID == "txAtt") { try { // txAtt.ClickPicker(); System.Diagnostics.Process.Start(dtHead.GetValue("Att", 0).ToString()); } catch (Exception ex) { string errmsg = ex.Message; } } if (pVal.ItemUID == btAtt.Item.UniqueID) { string strFileName = Program.objHrmsUI.addAttacment(""); if (strFileName != "") { dtHead.SetValue("Att", 0, strFileName); int selRow = mtSelRow(mtDocs); string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string strDocCode = strCode + "-" + dn; string strInsert = "UPDATE \"@B1_QA_DOC\" SET \"U_Att\" = '" + strFileName + "' WHERE \"Code\" = '" + strDocCode + "'"; Program.objHrmsUI.ExecQuery(strInsert, "Finalllizing Inspaction"); } } if (pVal.ItemUID == "1000001") { string RC = Convert.ToString(dtHead.GetValue("RC", 0)); string SBC = Convert.ToString(dtHead.GetValue("SBC", 0)); string strCode = RC + "-" + SBC; saveReport(strCode); } if (pVal.ItemUID == mtDocs.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtDocs.RowCount) { mtDocs.SelectRow(pVal.Row, true, false); int selRow = pVal.Row; if (selRow > 0) { string strCode = Convert.ToString(dtDoc.GetValue("OT", selRow - 1)); string dn = Convert.ToString(dtDoc.GetValue("DE", selRow - 1)); string tbl = Convert.ToString(dtDoc.GetValue("Tbl", selRow - 1)); if (strCode.Trim() != "") { string strDocCode = strCode + "-" + dn; string strExist = "SELECT * from \"@B1_QA_DOC\" where \"Code\" = '" + strDocCode + "'"; System.Data.DataTable dtExist = Program.objHrmsUI.getDataTable(strExist, "DocDetExist"); if (dtExist.Rows.Count == 0) { string strInsert = "INSERT INTO \"@B1_QA_DOC\" (\"Code\",\"Name\",\"U_ObjType\",\"U_DocEntry\",\"U_Date\")"; strInsert += " VALUES ('" + strDocCode + "','" + strDocCode + "','" + strCode + "','" + dn + "','" + DateTime.Now.ToString("yyyyMMdd") + "')"; Program.objHrmsUI.ExecQuery(strInsert, "Rpt Doc Entry into UDT"); } else { dtHead.SetValue("Att", 0, dtExist.Rows[0]["U_Att"].ToString()); } getRows(tbl, dn); } } else { oApplication.MessageBox("Please select a document before inspaction"); } } if (pVal.ItemUID == mtDocRows.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtDocRows.RowCount) { mtDocRows.SelectRow(pVal.Row, true, false); int selRow = pVal.Row;// mtSelRow(mtDocRows); if (selRow > 0) { string strCode = Convert.ToString(dtRow.GetValue("ItemCode", selRow - 1)); string MM = Convert.ToString(dtRow.GetValue("MM", selRow - 1)); string OBT = Convert.ToString(dtRow.GetValue("OBT", selRow - 1)); string LN = Convert.ToString(dtRow.GetValue("LN", selRow - 1)); string ItemCode = Convert.ToString(dtRow.GetValue("ItemCode", selRow - 1)); string Qty = Convert.ToString(dtRow.GetValue("Quantity", selRow - 1)); int DocselRow = mtSelRow(mtDocs); string DE = Convert.ToString(dtDoc.GetValue("DE", DocselRow - 1)); dtHead.SetValue("RC", 0, OBT + "-" + DE + "-" + LN); dtHead.SetValue("MM", 0, MM); dtHead.SetValue("OBT", 0, OBT); dtHead.SetValue("LN", 0, LN); dtHead.SetValue("DE", 0, DE); dtHead.SetValue("Qty", 0, Qty); dtHead.SetValue("ItemCode", 0, ItemCode); if (strCode.Trim() != "") { getAttributes(strCode); fillSerilaOrBatch(Qty, DE, LN, OBT, MM); } } else { oApplication.MessageBox("Please select an item before inspaction"); } } if (pVal.ItemUID == mtSB.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtSB.RowCount) { mtSB.SelectRow(pVal.Row, true, false); int selRow = pVal.Row;// mtSelRow(mtSB); if (selRow > 0) { string RC = Convert.ToString(dtHead.GetValue("RC", 0)); string MM = Convert.ToString(dtHead.GetValue("MM", 0)); string OBT = Convert.ToString(dtHead.GetValue("OBT", 0)); string LN = Convert.ToString(dtHead.GetValue("LN", 0)); string DE = Convert.ToString(dtHead.GetValue("DE", 0)); string ItemCode = Convert.ToString(dtHead.GetValue("ItemCode", 0)); string Qty = Convert.ToString(dtHead.GetValue("Qty", 0)); string strCode = Convert.ToString(dtSB.GetValue("Code", selRow - 1)); string strQty = Convert.ToString(dtSB.GetValue("Qty", selRow - 1)); dtHead.SetValue("SBC", 0, strCode); getReport(RC + "-" + strCode, OBT, DE, LN, MM, strQty, ItemCode, strCode); } } }
}//fin InitForm public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent) { base.FormEvent(FormUID, ref pVal, ref BubbleEvent); try { if ((pVal.ItemUID == "1") && (pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)) { if ((oForm.Mode == BoFormMode.fm_ADD_MODE) || (oForm.Mode == BoFormMode.fm_UPDATE_MODE)) { BubbleEvent = false; if (ValidarDatos()) { GuardarDatos(); } } } if ((pVal.ItemUID == "btnCtaSAP") && (!pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)) { var bpaso = false; for (Int32 iCant = 0; iCant <= oGrid.Rows.Count - 1; iCant++) { if (oGrid.Rows.IsSelected(iCant)) { bpaso = true; if (((System.Int32)oDataTable.GetValue("DocEntry", iCant)) == 0) { FSBOApp.StatusBar.SetText("Debe guardar registro de Plan de Cuentas SII", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); } else { CuentaSAP(iCant); break; } } } if (!bpaso) { FSBOApp.StatusBar.SetText("Debe seleccionar una linea", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); } } if ((pVal.ItemUID == "btnCrear") && (!pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)) { if (!oForm.Items.Item("Cuenta").Visible) { oForm.Items.Item("Cuenta").Visible = true; oForm.Items.Item("Descr").Visible = true; } else { if (CrearNuevaCta()) { oForm.Freeze(true); oForm.DataSources.UserDataSources.Item("Cuenta").Value = ""; oForm.DataSources.UserDataSources.Item("Descr").Value = ""; //((EditText)oForm.Items.Item("Cuenta").Specific).Value = ""; //((EditText)oForm.Items.Item("Descr").Specific).Value = ""; s = "XXX"; oForm.Items.Item("XXX").Click(BoCellClickType.ct_Regular); oForm.Items.Item("Cuenta").Visible = false; oForm.Items.Item("Descr").Visible = false; CargarGrilla(); } } } if ((pVal.ItemUID == "btnBorrar") && (!pVal.BeforeAction) && (pVal.EventType == BoEventTypes.et_ITEM_PRESSED)) { BorrarCta(); } if ((pVal.ItemUID == "grid") && (pVal.ColUID == "Cuenta") && (pVal.EventType == BoEventTypes.et_VALIDATE) && (!pVal.BeforeAction)) { ValidarDataTable(((System.String)oDataTable.GetValue("Cuenta", pVal.Row)), pVal.Row); } } catch (Exception e) { if (FCmpny.InTransaction) { FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack); } FSBOApp.StatusBar.SetText(e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace); } finally { oForm.Freeze(false); } }//fin FormEvent
private void LoadFormReceipt() { try { if (mIntRowSelected > 0 && mtxCosts.IsRowSelected(mIntRowSelected)) { string pStrRowCode = DtMatrix.GetValue("C_Folio", mIntRowSelected - 1).ToString(); //List<Vouchers> lObjVouchers = mObjPurchasesDAO.GetVouches(pStrRowCode); //if (lObjVouchers.Count() > 0) //{ // frmReceipts lObjfrmReceipts = new frmReceipts(pStrRowCode); // lObjfrmReceipts.Show(); //} //else //{ string lStrArea = DtMatrix.GetValue("C_Area", mIntRowSelected - 1).ToString(); string lStrEmployee = DtMatrix.GetValue("C_Employe", mIntRowSelected - 1).ToString(); string lStrFolio = DtMatrix.GetValue("C_Folio", mIntRowSelected - 1).ToString(); string lStrEmpId = DtMatrix.GetValue("C_EmpId", mIntRowSelected - 1).ToString(); string lStrStatus = DtMatrix.GetValue("C_Status", mIntRowSelected - 1).ToString(); string lStrCode = mObjPurchasesServiceFactory.GetPurchaseCheeckingCostService().CheckingCost(lStrFolio); if (string.IsNullOrEmpty(lStrStatus) && !string.IsNullOrEmpty(lStrCode)) { UIApplication.ShowMessageBox("Ya existe un comprobante registrado"); } else if (!string.IsNullOrEmpty(lStrCode)) { frmReceipts lObjfrmReceipts = new frmReceipts(lStrCode, TypeEnum.Type.Voucher); lObjfrmReceipts.UIAPIRawForm.Left = 500; lObjfrmReceipts.UIAPIRawForm.Top = 10; lObjfrmReceipts.Show(); } else { frmReceipts lObjfrmReceipts = new frmReceipts(lStrArea, lStrEmployee, lStrEmpId, lStrFolio, TypeEnum.Type.Voucher); lObjfrmReceipts.UIAPIRawForm.Left = 500; lObjfrmReceipts.UIAPIRawForm.Top = 10; lObjfrmReceipts.Show(); } //} } else { UIApplication.ShowMessageBox("Favor de seleccionar una linea"); } } catch (Exception ex) { LogService.WriteError("(btnEdit_ClickBefore): " + ex.Message); LogService.WriteError(ex); } }
public string postJe() { long jdtNum = 0; int errnum = 0; string errDesc = ""; string outStr = ""; if (!chkPost.Checked) { Program.objHrmsUI.oApplication.SetStatusBarMessage("You need to check the approved box before posting"); return("Error"); } if (txDN.Value == "") { Program.objHrmsUI.oApplication.SetStatusBarMessage("Select a transaction to post!"); return("Error"); } SAPbobsCOM.JournalEntries vJE = (SAPbobsCOM.JournalEntries)Program.objHrmsUI.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oJournalEntries); string Remarks = txRem.Value.ToString(); DateTime postingDate = DateTime.ParseExact(txDD.Value, "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None); try { vJE.ReferenceDate = postingDate; vJE.TaxDate = postingDate; vJE.DueDate = postingDate; if (Remarks.Length > 20) { vJE.Memo = Remarks.Substring(0, 20); // dgSales[3, i].Value.ToString().Substring(0, 20); } else { vJE.Memo = Remarks; } vJE.Reference = txRef1.Value; vJE.Reference2 = txRef2.Value; // vJE.TransactionCode = "JP"; vJE.Reference3 = "JP_" + txDN.Value.ToString(); for (int i = 0; i < mtDet.RowCount; i++) { string codetype = dtDet.GetValue("cType", i); string acctcode = dtDet.GetValue("cCode", i); string acctname = dtDet.GetValue("cName", i); string debit = Convert.ToString(dtDet.GetValue("cDebit", i)); string credit = Convert.ToString(dtDet.GetValue("cCredit", i)); string project = dtDet.GetValue("cProject", i); string ocr1 = dtDet.GetValue("cOcr1", i); string ocr2 = dtDet.GetValue("cOcr2", i); string ocr3 = dtDet.GetValue("cOcr3", i); string ocr4 = dtDet.GetValue("cOcr4", i); string ocr5 = dtDet.GetValue("cOcr5", i); if (codetype == "GL") { vJE.Lines.AccountCode = acctcode; } else { vJE.Lines.ShortName = acctcode; } vJE.Lines.Credit = Convert.ToDouble(credit); vJE.Lines.Debit = Convert.ToDouble(debit); vJE.Lines.DueDate = postingDate; vJE.Lines.ReferenceDate1 = postingDate; vJE.Lines.TaxDate = postingDate; vJE.Lines.Reference1 = vJE.Reference; vJE.Lines.Reference2 = vJE.Reference2; vJE.Lines.ProjectCode = project; vJE.Lines.CostingCode = ocr1; vJE.Lines.CostingCode2 = ocr2; vJE.Lines.CostingCode3 = ocr3; vJE.Lines.CostingCode4 = ocr4; vJE.Lines.CostingCode5 = ocr5; vJE.Lines.Add(); } } catch (Exception ex) { outStr = ex.Message; } if (vJE.Add() != 0) { int erroCode = 0; string errDescr = ""; Program.objHrmsUI.oCompany.GetLastError(out erroCode, out errDescr); outStr = "Error:" + errDescr + outStr; Program.objHrmsUI.oApplication.SetStatusBarMessage(outStr); } else { outStr = Convert.ToString(Program.objHrmsUI.oCompany.GetNewObjectKey()); string strObjJe = txDN.Value.ToString(); string strUpdate = " UPDATE \"@ABGP\" SET \"Status\" ='C' , \"U_Ref3\"= '" + outStr + "' WHERE \"DocNum\"='" + strObjJe + "'"; Program.objHrmsUI.ExecQuery(strUpdate, "Updating after posting"); Program.objHrmsUI.oApplication.SetStatusBarMessage("Journal Entry Created. JE # " + outStr, BoMessageTime.bmt_Medium, false); iniUI(); } return(outStr); }
public static void clsSupplierPurchaseHistory_ItemEvent(ref SAPbouiCOM.Application oApplication, ref SAPbobsCOM.Company oCompany, SAPbouiCOM.Form oSetupForm, ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { if (oForm != null) { oForm = oSetupForm; SAPbouiCOM.Grid oGrid; oGrid = (SAPbouiCOM.Grid)oForm.Items.Item("4").Specific; oMatrix = (SAPbouiCOM.Matrix)oSOForm.Items.Item("38").Specific; if (pVal.BeforeAction) { switch (pVal.EventType) { //case BoEventTypes.et_FORM_CLOSE: // BubbleEvent = false; // oForm.Visible = false; // break; case BoEventTypes.et_DOUBLE_CLICK: if (pVal.ItemUID == "4") { string strSelCol = ""; strSelCol = oGrid.Columns.Item(pVal.ColUID).TitleObject.Caption.ToString(); string[] words = strSelCol.Split('-'); string[] words1; if (words.Length == 2) { oForm.Freeze(true); for (int i = 0; i < oGrid.Rows.Count; i++) { if (oGrid.DataTable.GetValue(strSelCol, i).ToString().Trim() != "") { if (oGrid.DataTable.GetValue(strSelCol, i).ToString().Trim() != "0") { words1 = oGrid.DataTable.GetValue(strSelCol, i).ToString().Trim().Split(' '); if (words1[0].Trim() != "") { oGrid.DataTable.SetValue("Order Qty", i, words1[0].Trim()); } } } } oForm.Freeze(false); } } break; case BoEventTypes.et_ITEM_PRESSED: if (pVal.ItemUID == "2") { BubbleEvent = false; oForm.Visible = false; } if (pVal.ItemUID == "3") { flushAll(); BubbleEvent = false; oForm.Visible = false; return; oMatrix.Clear(); int j = oMatrix.RowCount; if (j == 0) { oMatrix.AddRow(1, -1); } j = oMatrix.RowCount; for (int i = 0; i < oGrid.Rows.Count; i++) { if (oGrid.DataTable.GetValue("Order Qty", i).ToString().Trim() != "") { if (oGrid.DataTable.GetValue("Order Qty", i).ToString().Trim() != "0") { string strItemCode = oGrid.DataTable.GetValue("ItemCode", i).ToString().Trim(); string strQty = oGrid.DataTable.GetValue("Order Qty", i).ToString().Trim(); string strPrice = oGrid.DataTable.GetValue("Current Purchase Price", i).ToString().Trim(); string strUoM = oGrid.DataTable.GetValue("UoM", i).ToString().Trim(); try { ((SAPbouiCOM.EditText)oMatrix.Columns.Item("1").Cells.Item(j).Specific).Value = strItemCode; ((SAPbouiCOM.EditText)oMatrix.Columns.Item("11").Cells.Item(j).Specific).Value = strQty; try { ((SAPbouiCOM.EditText)oMatrix.Columns.Item("1470002145").Cells.Item(j).Specific).Value = strUoM; } catch (Exception) { } try { ((SAPbouiCOM.EditText)oMatrix.Columns.Item("14").Cells.Item(j).Specific).Value = strPrice; } catch (Exception) { } j++; } catch (Exception) { j++; } } } } //oForm.Close(); oForm.Visible = false; } break; case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST: if (pVal.ItemUID == "4") { if (pVal.ColUID == "UoM") { if (oGrid.DataTable.GetValue("ItemCode", pVal.Row).ToString().Trim() != "") { string squery = "Select T2.\"UomCode\",T2.\"UomName\" From OITM T0 Inner Join UGP1 T1 On T0.\"UgpEntry\" = T1.\"UgpEntry\" Inner Join OUOM T2 On T1.\"UomEntry\" = T2.\"UomEntry\" Where T0.\"ItemCode\" = '" + oGrid.DataTable.GetValue("ItemCode", pVal.Row).ToString().Trim() + "'"; Utilities.UtilitiesCls.CFLConditionQuery(ref oApplication, ref oCompany, oForm, ref pVal, squery, "UomCode", "10010198", "UomCode", false, true, "4", "UoM", false); } } if (pVal.ColUID == "ItemCode") { SAPbouiCOM.ChooseFromListCollection oCFLs = null; SAPbouiCOM.Conditions oCons = null; SAPbouiCOM.Condition oCon = null; oCFLs = oForm.ChooseFromLists; SAPbouiCOM.ChooseFromList oCFL = null; oCFL = oCFLs.Item("CFL_2"); oCons = new Conditions(); oCFL.SetConditions(oCons); oCons = oCFL.GetConditions(); oCon = oCons.Add(); oCon.Alias = "PrchseItem"; oCon.Operation = SAPbouiCOM.BoConditionOperation.co_EQUAL; oCon.CondVal = "Y"; oCon.Relationship = BoConditionRelationship.cr_AND; oCon = oCons.Add(); oCon.Alias = "frozenFor"; oCon.Operation = SAPbouiCOM.BoConditionOperation.co_NOT_EQUAL; oCon.CondVal = "Y"; int intCnt = 2; for (int i = 0; i < oGrid.Rows.Count; i++) { if (oGrid.DataTable.GetValue("ItemCode", i).ToString().Trim() != "") { if (intCnt > 0) { oCon.Relationship = BoConditionRelationship.cr_AND; } oCon = oCons.Add(); oCon.Alias = "ItemCode"; oCon.Operation = SAPbouiCOM.BoConditionOperation.co_NOT_EQUAL; oCon.CondVal = oGrid.DataTable.GetValue("ItemCode", i).ToString().Trim(); intCnt += 1; } } oCFL.SetConditions(oCons); } } break; default: break; } } else if (pVal.BeforeAction == false) { switch (pVal.EventType) { case BoEventTypes.et_ITEM_PRESSED: break; case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST: if (oForm.Mode != SAPbouiCOM.BoFormMode.fm_FIND_MODE) { if (pVal.ItemUID == "4") { if (pVal.ColUID == "ItemCode") { oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset); string strQry = ""; string strItemCode = ""; oDataTable = UtilitiesCls.DataTable(ref oApplication, ref oCompany, oForm, ref pVal); if (oDataTable != null) { strItemCode = oDataTable.GetValue("ItemCode", 0).ToString(); } if (strItemCode != "") { strQry = " Exec EJ_LoadBPItemDetails '" + ((SAPbouiCOM.EditText)oForm.Items.Item("6").Specific).Value.Trim() + "', '" + strItemCode + "'"; oRecordSet.DoQuery(strQry); if (!oRecordSet.EoF) { oGrid.DataTable.SetValue("ItemCode", pVal.Row, strItemCode); oGrid.DataTable.SetValue("ItemName", pVal.Row, oRecordSet.Fields.Item("ItemName").Value.ToString()); oGrid.DataTable.SetValue("Order Qty", pVal.Row, ""); oGrid.DataTable.SetValue("UoM", pVal.Row, oRecordSet.Fields.Item("UoM").Value.ToString()); oGrid.DataTable.SetValue("Current Purchase Price", pVal.Row, oRecordSet.Fields.Item("Current Price").Value.ToString()); } } oGrid.DataTable.SetValue("ItemCode", pVal.Row, strItemCode); int j = oGrid.Rows.Count; if (j == oGrid.Rows.Count) { oGrid.DataTable.Rows.Add(); } } if (pVal.ColUID == "UoM") { oRecordSet = (SAPbobsCOM.Recordset)oCompany.GetBusinessObject(BoObjectTypes.BoRecordset); string strUoMCode = ""; oDataTable = UtilitiesCls.DataTable(ref oApplication, ref oCompany, oForm, ref pVal); if (oDataTable != null) { strUoMCode = oDataTable.GetValue("UomCode", 0).ToString(); } oGrid.DataTable.SetValue("UoM", pVal.Row, strUoMCode); string strQry = " Exec EJ_LoadUoMPrice '" + ((SAPbouiCOM.EditText)oForm.Items.Item("6").Specific).Value.Trim() + "','" + oGrid.DataTable.GetValue("ItemCode", pVal.Row).ToString().Trim() + "' ,'" + strUoMCode + "'"; oRecordSet.DoQuery(strQry); if (!oRecordSet.EoF) { oGrid.DataTable.SetValue("Current Purchase Price", pVal.Row, oRecordSet.Fields.Item("Current Price").Value.ToString()); } } } } break; case BoEventTypes.et_COMBO_SELECT: break; case BoEventTypes.et_FORM_CLOSE: oForm = null; break; default: break; } } } }
private void ChooseFromListAfterEvent(SAPbouiCOM.ItemEvent pObjValEvent) { if (pObjValEvent.Action_Success) { SAPbouiCOM.IChooseFromListEvent lObjCFLEvento = (SAPbouiCOM.IChooseFromListEvent)pObjValEvent; SAPbouiCOM.DataTable lObjDataTable = lObjCFLEvento.SelectedObjects; if (lObjCFLEvento.SelectedObjects == null) { return; } this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Client").ValueEx = Convert.ToString(lObjDataTable.GetValue(0, 0)); } }
public override void etAfterClick(ref SAPbouiCOM.ItemEvent pVal, ref bool BubbleEvent) { base.etAfterClick(ref pVal, ref BubbleEvent); if (pVal.ItemUID == opG.Item.UniqueID || pVal.ItemUID == opI.Item.UniqueID) { if (opI.Selected) { txCode.ChooseFromListUID = "cflCode"; txCode.ChooseFromListAlias = "CardCode"; } else { txCode.ChooseFromListUID = "cflGroup"; txCode.ChooseFromListAlias = "ItmsGrpCod"; } getCodes(); } if (pVal.ItemUID == btAdd.Item.UniqueID) { string code = Convert.ToString(dtHead.GetValue("Code", 0)); string name = Convert.ToString(dtHead.GetValue("Name", 0)); string codeType = opG.Selected ? "Group" : "Item"; string strCode = Program.objHrmsUI.getMaxId("@B1_QA_ATTR_CODES", "Code").ToString(); if (code != "") { string strInsert = "INSERT INTO \"@B1_QA_ATTR_CODES\" (\"Code\",\"Name\",\"U_Descr\",\"U_CodeType\") VALUES ('" + strCode + "','" + code + "','" + name + "','" + codeType + "')"; Program.objHrmsUI.ExecQuery(strInsert, "Insert New Code"); dtHead.SetValue("Code", 0, ""); dtHead.SetValue("Name", 0, ""); getCodes(); } else { oApplication.MessageBox("Please select Code"); } } if (pVal.ItemUID == btAddA.Item.UniqueID) { int selListRow = mtSelRow(mtList); string IGcode = Convert.ToString(dtList.GetValue("Code", selListRow - 1)); string codeType = opG.Selected ? "Group" : "Item"; int selRow = mtSelRow(mtA); if (selRow > 0) { string strCode = Convert.ToString(dtA.GetValue("Code", selRow - 1)); string strNCode = Program.objHrmsUI.getMaxId("@B1_QA_CODES_ATTR", "Code").ToString(); string strInsert = "INSERT INTO \"@B1_QA_CODES_ATTR\" (\"Code\",\"Name\",\"U_IGCode\") VALUES ('" + strNCode + "','" + strCode + "','" + IGcode + "')"; Program.objHrmsUI.ExecQuery(strInsert, "Insert New Code"); getCodesAttr(IGcode); } else { oApplication.MessageBox("Please select Code"); } } if (pVal.ItemUID == btDelA.Item.UniqueID) { int selListRow = mtSelRow(mtList); string IGcode = Convert.ToString(dtList.GetValue("Code", selListRow - 1)); string codeType = opG.Selected ? "Group" : "Item"; int selRow = mtSelRow(mtS); if (selRow > 0) { string strCode = Convert.ToString(dtS.GetValue("Code", selRow - 1)); string strInsert = "DELETE FROM \"@B1_QA_CODES_ATTR\" WHERE \"Name\" = '" + strCode + "' AND \"U_IGCode\" = '" + IGcode + "'"; Program.objHrmsUI.ExecQuery(strInsert, "REMOVE Code"); getCodesAttr(IGcode); } else { oApplication.MessageBox("Please select Code"); } } if (pVal.ItemUID == mtList.Item.UniqueID && pVal.Row > 0 && pVal.Row <= mtList.RowCount) { mtList.SelectRow(pVal.Row, true, false); int selRow = pVal.Row;// mtSelRow(mtList); if (selRow > 0) { string strCode = Convert.ToString(dtList.GetValue("Code", selRow - 1)); if (strCode.Trim() != "") { getCodesAttr(strCode); } } else { oApplication.MessageBox("Please select rule to delete"); } } if ((pVal.ItemUID == mtA.Item.UniqueID) && pVal.Row > 0 && pVal.Row <= mtA.RowCount) { mtA.SelectRow(pVal.Row, true, false); } if ((pVal.ItemUID == mtS.Item.UniqueID) && pVal.Row > 0 && pVal.Row <= mtS.RowCount) { mtS.SelectRow(pVal.Row, true, false); } }
public static String CrearXMLLibroDiarioMayor(String Periodo, SAPbouiCOM.DataTable odt, SAPbouiCOM.DataTable odt2, SAPbouiCOM.Application FSBOApp) { String NomCol; String NomCol2; Int32 i; Int32 c = 0; Boolean bIden; String[] Col2; try { s = odt.GetAsXML(); s = @"<LceCoCierre version=""1.0""><LceDiarioRes version=""1.0""><DocumentoDiarioRes ID=""DIARIO_RES_{0}"">"; s = String.Format(s, Periodo.Replace(".", "-")); NomCol = odt.Columns.Item(0).Name; var Col = NomCol.Split('/'); s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[0], Col[1], ((System.String)odt.GetValue(0, 0)).Trim()); NomCol = odt.Columns.Item(1).Name; Col = NomCol.Split('/'); s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[1], Col[2], ((System.String)odt.GetValue(1, 0)).Trim()); NomCol = odt.Columns.Item(2).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}></{2}></{3}>"; //[Identificacion/PeriodoTributario/Final] s = String.Format(s, Col[2], ((System.String)odt.GetValue(2, 0)).Trim(), Col[1], Col[0]); //RegistroDiario for (i = 0; i < odt.Rows.Count; i++) { NomCol = odt.Columns.Item(3).Name; Col = NomCol.Split('/'); var sFin = Col[0]; s = s + @"<{0}>"; s = String.Format(s, sFin); for (c = 3; c < odt.Columns.Count; c++) { NomCol = odt.Columns.Item(c).Name; Col = NomCol.Split('/'); if (Col[0] != sFin) { break; } s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[1], ((System.String)odt.GetValue(c, i)).Trim()); } s = s + @"</{0}>"; s = String.Format(s, sFin); } //Cierre for (Int32 x = 0; x == 0; x++) { NomCol = odt.Columns.Item(c).Name; Col = NomCol.Split('/'); var sFin = Col[0]; s = s + @"<{0}>"; s = String.Format(s, sFin); for (Int32 z = c; z < odt.Columns.Count; z++) { NomCol = odt.Columns.Item(z).Name; Col = NomCol.Split('/'); if (Col[0] != sFin) { break; } s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[1], ((System.String)odt.GetValue(z, x)).Trim()); } s = s + @"</{0}>"; s = String.Format(s, sFin); } s = s + @"</DocumentoDiarioRes></LceDiarioRes>"; //</LceCoCierre>"; //Inicia Libro Mayor s = s + @"<LceMayorRes version=""1.0""><DocumentoMayorRes ID=""MAYOR_RES_{0}"">"; s = String.Format(s, Periodo.Replace(".", "-")); //Identificacion NomCol = odt2.Columns.Item(0).Name; Col = NomCol.Split('/'); s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[0], Col[1], ((System.String)odt2.GetValue(0, 0)).Trim()); NomCol = odt2.Columns.Item(1).Name; Col = NomCol.Split('/'); s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[1], Col[2], ((System.String)odt2.GetValue(1, 0)).Trim()); NomCol = odt2.Columns.Item(2).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}></{2}></{3}>"; //[Identificacion/PeriodoTributario/Final] s = String.Format(s, Col[2], ((System.String)odt2.GetValue(2, 0)).Trim(), Col[1], Col[0]); //Cuenta for (i = 0; i < odt2.Rows.Count; i++) { NomCol = odt2.Columns.Item(3).Name; Col = NomCol.Split('/'); var sFin = Col[0]; s = s + @"<{0}>"; s = String.Format(s, sFin); for (c = 3; c < odt2.Columns.Count; c++) { NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); if (Col[0] != sFin) { break; } if (Col.Count() == 2) { s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[1], ((System.String)odt2.GetValue(c, i)).Trim()); } else { var ff = Col[1]; s = s + @"<{0}>"; s = String.Format(s, ff);//coloca Inicio Cierre //MontosPeriodo - Debe s = s + @"<{0}><{1}>{2}</{1}>"; s = String.Format(s, Col[2], Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca Debe c++; //MontosPeriodo - Haber NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca Haber c++; //MontosPeriodo - Deudor if (((System.String)odt2.GetValue(c, i)).Trim() != "0") { NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca Deudor } c++; //MontosPeriodo - Acreedor if (((System.String)odt2.GetValue(c, i)).Trim() != "0") { NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim()); //coloca Acreedor } s = s + @"</{0}>"; //Coloca Final MontosPeriodo s = String.Format(s, Col[2]); c++; //**Agrega Montos Acumulados NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>"; s = String.Format(s, Col[2]);//coloca Inicio MontosAcumulado //MontosAcumulado - Debe s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca Debe c++; //MontosAcumulado - Haber NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca Haber c++; if (((System.String)odt2.GetValue(c, i)).Trim() != "0") { NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim());//coloca SaldoDeudor } c++; if (((System.String)odt2.GetValue(c, i)).Trim() != "0") { NomCol = odt2.Columns.Item(c).Name; Col = NomCol.Split('/'); s = s + @"<{0}>{1}</{0}>"; s = String.Format(s, Col[3], ((System.String)odt2.GetValue(c, i)).Trim()); //coloca SaldoAcreedor } s = s + @"</{0}>"; //Coloca Final MontosAcumulado s = String.Format(s, Col[2]); c++; s = s + @"</{0}>"; //Coloca Final Cierre s = String.Format(s, ff); } } s = s + @"</{0}>"; s = String.Format(s, sFin); //Cierra Cuenta } //[Cuenta/CodigoCuenta] //[Cuenta/Cierre/MontosPeriodo/Deudor] s = s + @"</DocumentoMayorRes></LceMayorRes></LceCoCierre>"; return(s); } catch (Exception z) { FSBOApp.StatusBar.SetText(z.Message + " ** Trace: " + z.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); //OutLog("CrearXMLDiccionario: " + z.Message + " ** Trace: " + z.StackTrace); return(""); } }
private static void flushAll() { SAPbouiCOM.Grid oGrid; oGrid = (SAPbouiCOM.Grid)oForm.Items.Item("4").Specific; SAPbouiCOM.DataTable dtHistory = oGrid.DataTable; oSOForm.Freeze(true); try { using (var progress = SboProgressBar.Create("Please Wait while system prepare sales order for selected item(s) ", 100, oForm, 400)) { System.Data.DataTable dtSelItems = new System.Data.DataTable(); dtSelItems.Columns.Add("ItemCode"); dtSelItems.Columns.Add("Quantity"); dtSelItems.Columns.Add("Price"); dtSelItems.Columns.Add("UOM"); int rowCount = 1; for (int dtrown = 0; dtrown < dtHistory.Rows.Count; dtrown++) { string strQty = dtHistory.GetValue("Order Qty", dtrown).ToString().Trim(); if (strQty != "0" && strQty != "") { string strItemCode = oGrid.DataTable.GetValue("ItemCode", dtrown).ToString().Trim(); string strPrice = oGrid.DataTable.GetValue("Current Purchase Price", dtrown).ToString().Trim(); string strUoM = oGrid.DataTable.GetValue("UoM", dtrown).ToString().Trim(); dtSelItems.Rows.Add(strItemCode, strQty, strPrice, strUoM); rowCount++; } } if (dtSelItems.Rows.Count > 0) { for (int m = oMatrix.RowCount; m >= 1; m--) { oMatrix.DeleteRow(1); } progress.Value += 10; rowCount = 1; oMatrix.AddRow(dtSelItems.Rows.Count); int incrmentVal = 90 / dtSelItems.Rows.Count; foreach (System.Data.DataRow dr in dtSelItems.Rows) { if (progress.Value <= 100) { progress.Value += incrmentVal; } progress.Text = "Please Wait while system prepare document for selected item(s) " + dr["ItemCode"].ToString(); ((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("1", rowCount)).Value = dr["ItemCode"].ToString(); ((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("11", rowCount)).Value = dr["Quantity"].ToString(); try { ((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("1470002145", rowCount)).Value = dr["UOM"].ToString(); } catch (Exception) { } try { ((SAPbouiCOM.EditText)oMatrix.GetCellSpecific("14", rowCount)).Value = dr["Price"].ToString(); } catch (Exception) { } rowCount++; } } } } catch (Exception ex) { } finally { oSOForm.Freeze(false); } }
}//fin InitForm public new void FormEvent(String FormUID, ref SAPbouiCOM.ItemEvent pVal, ref Boolean BubbleEvent) { IvkFormInterface oFormVk; String oUid; String prmKey; SAPbouiCOM.EditTextColumn oEditColumn; base.FormEvent(FormUID, ref pVal, ref BubbleEvent); try { if ((pVal.EventType == BoEventTypes.et_MATRIX_LINK_PRESSED) && (pVal.BeforeAction) && (pVal.ItemUID == "grid")) { s = (System.String)(oDataTable.GetValue("ObjType", pVal.Row)); oColumn = (GridColumn)(oGrid.Columns.Item("DocEntry")); oEditColumn = (EditTextColumn)(oColumn); oEditColumn.LinkedObjectType = s; } if ((pVal.EventType == BoEventTypes.et_ITEM_PRESSED) && (!pVal.BeforeAction)) { if (pVal.ItemUID == "ActGrilla") { CargarDatosPE(); } if (pVal.ItemUID == "chk_Todo") { CargarDatosPE(); } if (pVal.ItemUID == "Rechazados") { CargarDatosPE(); } if (pVal.ItemUID == "Pendientes") { CargarDatosPE(); } if (pVal.ItemUID == "Aceptados") { CargarDatosPE(); } if (pVal.ItemUID == "DadoBaja") { CargarDatosPE(); } if (pVal.ItemUID == "Errores") { CargarDatosPE(); } } if ((pVal.EventType == BoEventTypes.et_VALIDATE) && (pVal.BeforeAction) && (pVal.ItemUID == "FechaD")) { oEditText = (EditText)(oForm.Items.Item("FechaD").Specific); if ((System.String)(oEditText.Value) == "") { FSBOApp.StatusBar.SetText("Debe ingresar una fecha desde", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); BubbleEvent = false; } } if ((pVal.EventType == BoEventTypes.et_VALIDATE) && (pVal.BeforeAction) && (pVal.ItemUID == "FechaH")) { oEditText = (EditText)(oForm.Items.Item("FechaH").Specific); if ((System.String)(oEditText.Value) == "") { FSBOApp.StatusBar.SetText("Debe ingresar una fecha hasta", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Warning); BubbleEvent = false; } } } catch (Exception e) { if (FCmpny.InTransaction) { FCmpny.EndTransaction(BoWfTransOpt.wf_RollBack); } FSBOApp.StatusBar.SetText(e.Message + " ** Trace: " + e.StackTrace, BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); OutLog("FormEvent: " + e.Message + " ** Trace: " + e.StackTrace); } }//fin FormEvent
}//fin ActualizarRegistros private void ActualizarRegistros() { TFunctions Reg; String sCode = ""; SqlDataAdapter cmd; //SqlDataAdapter cmd2; SqlConnection ConexionADO; System.Data.DataTable resultDataTable; //System.Data.DataTable resultDataTable1; Int32 i; Boolean _return; String sCnn; SAPbouiCOM.GridColumn oColumn; Boolean bExiste; SqlCommand cmd1; Int32 iDif; String User, Pass, sDocEntry; SAPbobsCOM.Recordset orsAux; try { ActualizarGrilla(); orsAux = (SAPbobsCOM.Recordset)(FCmpny.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)); if (bMultiSoc) { if (GlobalSettings.RunningUnderSQLServer) { s = @"select DocEntry, U_Servidor, U_Base, U_Usuario, U_Password from [@VID_FEMULTISOC] where U_Habilitada = 'Y'"; } else { s = @"select TO_VARCHAR(""DocEntry"") ""DocEntry"", ""U_Servidor"", ""U_Base"", ""U_Usuario"", ""U_Password"" from ""@VID_FEMULTISOC"" where ""U_Habilitada"" = 'Y' "; } } else { if (GlobalSettings.RunningUnderSQLServer) { s = @"select TOP 1 * from [@VID_FEPARAM]"; } else { s = @"select TOP 1 * from ""@VID_FEPARAM"" "; } } oRecordSet.DoQuery(s); if (oRecordSet.RecordCount > 0) { Reg = new TFunctions(); Reg.SBO_f = FSBOf; while (!oRecordSet.EoF) { if (bMultiSoc) { User = (System.String)(oRecordSet.Fields.Item("U_Usuario").Value); Pass = (System.String)(oRecordSet.Fields.Item("U_Password").Value); } else { User = Reg.DesEncriptar((System.String)(oRecordSet.Fields.Item("U_Usuario").Value)); Pass = Reg.DesEncriptar((System.String)(oRecordSet.Fields.Item("U_Password").Value)); } sCnn = Reg.sConexion((System.String)(oRecordSet.Fields.Item("U_Servidor").Value), (System.String)(oRecordSet.Fields.Item("U_Base").Value), User, Pass); sDocEntry = Convert.ToString((System.Int32)(oRecordSet.Fields.Item("DocEntry").Value)); if (sCnn.Substring(0, 1) != "E") { ConexionADO = new SqlConnection(sCnn); if (ConexionADO.State == ConnectionState.Closed) { ConexionADO.Open(); } s = @"SELECT CAST(TPDOCUMENTO AS VARCHAR(20)) 'TipoDoc' ,CAST(RANGODESDE AS VARCHAR(20)) 'Desde' ,CAST(RANGOHASTA AS VARCHAR(20)) 'Hasta' ,CONVERT(Char(8),FECHA,112) 'Fecha' ,CAST((RANGOHASTA - (RANGODESDE + UTILIZADOS)) + 1 AS VARCHAR(20)) 'Asig' ,CAST(ID as varchar(20)) 'ID' ,CAST((RANGODESDE + UTILIZADOS) AS VARCHAR(20)) 'FolioDesde' ,CAST(UTILIZADOS AS VARCHAR(20)) 'Utilizados' ,ISNULL(XML_CAF,'') 'XML_CAF' FROM folios WITH(nolock)"; cmd = new SqlDataAdapter(s, ConexionADO); resultDataTable = new System.Data.DataTable(); cmd.Fill(resultDataTable); foreach (System.Data.DataRow oRow in resultDataTable.Rows) { bExiste = false; i = 0; if (!oDataTable.IsEmpty) { while (i < oDataTable.Rows.Count) { s = oDataTable.Rows.Count.ToString(); var dFecha = (System.DateTime)(oDataTable.GetValue("U_Fecha", i)); if (((System.String)(oDataTable.GetValue("U_TipoDoc", i)) == oRow.Field <String>("TipoDoc").ToString()) && (Convert.ToString((System.Int32)(oDataTable.GetValue("U_Desde", i))) == oRow.Field <String>("Desde")) && (Convert.ToString((System.Int32)(oDataTable.GetValue("U_Hasta", i))) == oRow.Field <String>("Hasta")) && (dFecha.ToString("yyyyMMdd") == oRow.Field <String>("Fecha"))) { bExiste = true; i = oDataTable.Rows.Count; } i++; } } if (!bExiste) { sCode = Reg.sNuevoDocEntryLargo("@VID_FECAF", GlobalSettings.RunningUnderSQLServer); oDBDSH.Clear(); oDBDSH.InsertRecord(0); oDBDSH.SetValue("Code", 0, sCode); //OutLog("Code -> " + oDBDSH.GetValue("Code",0)); oDBDSH.SetValue("U_TipoDoc", 0, oRow.Field <String>("TipoDoc")); //OutLog("TipoDoc -> " + oDBDSH.GetValue("U_TipoDoc", 0)); oDBDSH.SetValue("U_Desde", 0, oRow.Field <String>("Desde")); //OutLog("Desde -> " + oDBDSH.GetValue("U_Desde", 0)); oDBDSH.SetValue("U_Hasta", 0, oRow.Field <String>("Hasta")); //OutLog("Hasta -> " + oDBDSH.GetValue("U_Hasta", 0)); oDBDSH.SetValue("U_Fecha", 0, oRow.Field <String>("Fecha")); //OutLog("Fecha -> " + oDBDSH.GetValue("U_Fecha", 0)); oDBDSH.SetValue("U_BaseMul", 0, sDocEntry); //OutLog("BaseMul -> " + oDBDSH.GetValue("U_BaseMul", 0)); s = oRow.Field <String>("XML_CAF"); oDBDSH.SetValue("U_CAF", 0, s); //OutLog("CAF -> " + oDBDSH.GetValue("U_CAF", 0)); iDif = (Int32.Parse(oRow.Field <String>("Hasta")) - Int32.Parse(oRow.Field <String>("Desde"))) + 1; cmd1 = new SqlCommand(); cmd1.CommandTimeout = 0; cmd1.CommandType = CommandType.Text; cmd1.Connection = ConexionADO; s = @"WITH n(n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM n WHERE n < {0} ) SELECT COUNT(*) --n + {1} , T0.CAB_FOL_DOCTO_INT FROM n left outer join Faet_Erp_Encabezado_Doc T0 on n.n + {1} = T0.CAB_FOL_DOCTO_INT and T0.CAB_COD_TP_FACTURA = '{2}' and T0.CAB_FOL_DOCTO_INT between {3} and {4} where t0.CAB_FOL_DOCTO_INT is not null --ORDER BY n OPTION (MAXRECURSION 0)"; // antes OPTION (MAXRECURSION {0})"; s = String.Format(s, iDif.ToString(), Int32.Parse(oRow.Field <String>("Desde")) - 1, oRow.Field <String>("TipoDoc"), oRow.Field <String>("Desde"), oRow.Field <String>("Hasta")); cmd1.CommandText = s; s = cmd1.ExecuteScalar().ToString(); oDBDSH.SetValue("U_Utilizados", 0, s); //OutLog("Utilizados -> " + oDBDSH.GetValue("U_Utilizados", 0)); iDif = iDif - Int32.Parse(s); oDBDSH.SetValue("U_Asignables", 0, iDif.ToString()); //OutLog("Asignables -> " + oDBDSH.GetValue("U_Asignables", 0)); s = @"WITH n(n) AS ( SELECT 1 UNION ALL SELECT n + 1 FROM n WHERE n < {0} ) SELECT TOP 1 n + {1} --, T0.CAB_FOL_DOCTO_INT FROM n left outer join Faet_Erp_Encabezado_Doc T0 on n.n + {1} = T0.CAB_FOL_DOCTO_INT and T0.CAB_COD_TP_FACTURA = '{2}' and T0.CAB_FOL_DOCTO_INT between {3} and {4} where t0.CAB_FOL_DOCTO_INT is null ORDER BY n OPTION (MAXRECURSION 0)"; // antes OPTION (MAXRECURSION {0})"; s = String.Format(s, iDif.ToString(), Int32.Parse(oRow.Field <String>("Desde")) - 1, oRow.Field <String>("TipoDoc"), oRow.Field <String>("Desde"), oRow.Field <String>("Hasta")); cmd1.CommandText = s; if (cmd1.ExecuteScalar() == null) { s = oRow.Field <String>("Desde"); } else { s = cmd1.ExecuteScalar().ToString(); } oDBDSH.SetValue("U_FolioDesde", 0, s); //OutLog("FolioDesde -> " + oDBDSH.GetValue("U_FolioDesde", 0)); _return = Reg.CAFAdd(oDBDSH); if (_return) { FSBOApp.StatusBar.SetText("CAF Registrado, ID " + oRow.Field <String>("ID"), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); } else { FSBOApp.StatusBar.SetText("CAF no se ha registrado, ID " + oRow.Field <String>("ID"), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); } } } if (ConexionADO.State == ConnectionState.Open) { ConexionADO.Close(); } FSBOApp.StatusBar.SetText("CAF actualizados", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Success); } else { FSBOApp.StatusBar.SetText("Faltan datos Conexion. " + sCnn.Substring(1, sCnn.Length - 1), BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); } oRecordSet.MoveNext(); } ActualizarGrilla(); } else { FSBOApp.StatusBar.SetText("Debe ingresar datos de conexion", BoMessageTime.bmt_Short, BoStatusBarMessageType.smt_Error); } } catch (Exception e) { FSBOApp.MessageBox(e.Message + " ** Trace: " + e.StackTrace, 1, "Ok", "", ""); OutLog("ActualizarRegistros: " + e.Message + " ** Trace: " + e.StackTrace); } }//fin ActualizarRegistros
private void ChooseFromListAfterEvent(ItemEvent pObjValEvent) { try { if (pObjValEvent.Action_Success) { SAPbouiCOM.IChooseFromListEvent lObjCFLEvent = (SAPbouiCOM.IChooseFromListEvent)pObjValEvent; if (lObjCFLEvent.SelectedObjects != null) { SAPbouiCOM.DataTable lObjDataTable = lObjCFLEvent.SelectedObjects; if (lObjDataTable != null) { this.UIAPIRawForm.DataSources.UserDataSources.Item(lObjDataTable.UniqueID).ValueEx = System.Convert.ToString(lObjDataTable.GetValue(0, 0)); switch (lObjDataTable.UniqueID) { case "CFL_Area": //txtArea.Value = lObjDataTable.GetValue(0, 0).ToString(); this.UIAPIRawForm.DataSources.UserDataSources.Item("CFL_Area").ValueEx = lObjDataTable.GetValue(0, 0).ToString(); break; } } } } } catch (Exception ex) { LogService.WriteError("(ChooseFromListAfterEvent): " + ex.Message); LogService.WriteError(ex); } }