void __app_FormDataEvent(ref SAPbouiCOM.BusinessObjectInfo BusinessObjectInfo, out bool BubbleEvent) { BubbleEvent = true; try { if (BusinessObjectInfo.FormTypeEx == "CTIAMDC" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_LOAD && BusinessObjectInfo.BeforeAction == false) { __Form = __app.Forms.GetForm("CTIAMDC", 0); __Form.EnableMenu("1282", true); //__Form.EnableMenu("1289", true); __Form.Mode = SAPbouiCOM.BoFormMode.fm_VIEW_MODE; } if (BusinessObjectInfo.FormTypeEx == "CTIAMDC" && BusinessObjectInfo.EventType == SAPbouiCOM.BoEventTypes.et_FORM_DATA_ADD && BusinessObjectInfo.ActionSuccess == true && BusinessObjectInfo.BeforeAction == false) { __Form = __app.Forms.GetForm("CTIAMDC", 0); __app.ActivateMenuItem("1289"); } } catch (COMException e1) { __app.MessageBox(e1.Message, 0, "Ok", "", ""); } catch (SqlException e1) { __app.MessageBox(e1.Message, 0, "Ok", "", ""); } catch (Exception e1) { __app.MessageBox(e1.Message, 0, "Ok", "", ""); } }
private void Grid0_DoubleClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { if (Grid0.Rows.SelectedRows.Count > 0) { oApp.ActivateMenuItem("39722"); SAPbouiCOM.Form act_form = oApp.Forms.ActiveForm; //1250000004 ((SAPbouiCOM.EditText)act_form.Items.Item("1250000004").Specific).Value = Grid0.DataTable.GetValue("Agreement No", Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)).ToString(); act_form.Items.Item("1250000001").Click(); } }
private void Grid0_DoubleClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { //throw new System.NotImplementedException(); if (Grid0.Rows.SelectedRows.Count == 1) { string STK = Grid0.DataTable.GetValue(1, Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)).ToString(); DataTable rs_tonghopPS = Is_TonghopsoPS(STK); if (rs_tonghopPS.Rows.Count == 0 || string.IsNullOrEmpty(rs_tonghopPS.Rows[0][0].ToString())) { //Khong co trong bagn @COA DataTable rs = Get_MenuUID(); if (rs.Rows.Count > 0) { oApp.ActivateMenuItem(rs.Rows[0]["MenuUID"].ToString()); SAPbouiCOM.Form act_frm = oApp.Forms.ActiveForm; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000003").Specific).Value = EditText0.Value; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000009").Specific).Value = EditText1.Value; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000027").Specific).Value = STK; act_frm.Items.Item("1").Click(); } } else { //Neu co trong bang @COA DataTable rs = Get_MenuUID_TonghopsoPS(); if (rs.Rows.Count > 0) { oApp.ActivateMenuItem(rs.Rows[0]["MenuUID"].ToString()); SAPbouiCOM.Form act_frm = oApp.Forms.ActiveForm; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000003").Specific).Value = EditText0.Value; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000009").Specific).Value = EditText1.Value; ((SAPbouiCOM.CheckBox)act_frm.Items.Item("1000015").Specific).Checked = true; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000021").Specific).Value = STK; ((SAPbouiCOM.ComboBox)act_frm.Items.Item("1000027").Specific).Select(0, SAPbouiCOM.BoSearchKey.psk_Index); act_frm.Items.Item("1").Click(); } } } }
private void Grid0_DoubleClickAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { //throw new System.NotImplementedException(); if (Grid0.Rows.SelectedRows.Count == 1) { DataTable rs = Get_MenuUID(); if (rs.Rows.Count > 0) { oApp.ActivateMenuItem(rs.Rows[0]["MenuUID"].ToString()); SAPbouiCOM.Form act_frm = oApp.Forms.ActiveForm; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000003").Specific).Value = EditText0.Value; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000009").Specific).Value = EditText1.Value; string STK = Grid0.DataTable.GetValue(1, Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)).ToString(); ((SAPbouiCOM.EditText)act_frm.Items.Item("1000027").Specific).Value = STK; act_frm.Items.Item("1").Click(); } } }
//Print Button private void Button1_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { try { DataTable rs = Get_MenuUID("Ủy nhiệm chi"); if (rs.Rows.Count > 0) { oApp.ActivateMenuItem(rs.Rows[0]["MenuUID"].ToString()); SAPbouiCOM.Form act_frm = oApp.Forms.ActiveForm; ((SAPbouiCOM.EditText)act_frm.Items.Item("1000003").Specific).Value = BatchNum.ToString(); act_frm.Items.Item("1").Click(); } } catch (Exception ex) { oApp.MessageBox("Error! " + ex.Message); } }
private void Button0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { //Thiet bi if (pVal.FormMode == 1) { //Get DATA SUM CCM int DocEntry = int.Parse(((SAPbouiCOM.EditText)(this.GetItem("0_U_E").Specific)).Value); string Project = ((SAPbouiCOM.EditText)(this.GetItem("20_U_E").Specific)).Value; DataTable Sum_DUTRU = Load_Data_DUTRU_TB(Project, DocEntry); oApp.ActivateMenuItem("DUTRU"); SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.ActiveForm; //Get DocNum CTG try { ((SAPbouiCOM.EditText)oForm.Items.Item("20_U_E").Specific).Value = DocEntry.ToString(); try { //Select Type DUTRU ((SAPbouiCOM.ComboBox)oForm.Items.Item("21_U_Cb").Specific).Select("2", SAPbouiCOM.BoSearchKey.psk_ByValue); } catch (Exception ex) { oApp.MessageBox(ex.Message); } oForm.Freeze(true); oForm.PaneLevel = 1; SAPbouiCOM.Matrix oMtx = (SAPbouiCOM.Matrix)oForm.Items.Item("0_U_G").Specific; for (int i = 0; i < Sum_DUTRU.Rows.Count; i++) { oApp.SetStatusBarMessage(string.Format("Creating DUTRU TB: {0}", (i + 1) + "/" + Sum_DUTRU.Rows.Count), SAPbouiCOM.BoMessageTime.bmt_Short, false); DataRow r = Sum_DUTRU.Rows[i]; //Subproject Code ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_2").Cells.Item(i + 1).Specific).Value = r["High_Level_SUM"].ToString(); //Subproject Description ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_3").Cells.Item(i + 1).Specific).Value = r["High_Level_Name"].ToString(); //CP Mua ban ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_8").Cells.Item(i + 1).Specific).Value = r["CP_MB"].ToString(); //CP Thue ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_9").Cells.Item(i + 1).Specific).Value = r["CP_THUE"].ToString(); //CP Van hanh ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_10").Cells.Item(i + 1).Specific).Value = r["CP_VH"].ToString(); //CP VC ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_11").Cells.Item(i + 1).Specific).Value = r["CP_VC"].ToString(); if (i < Sum_DUTRU.Rows.Count - 1) { oMtx.AddRow(); ((SAPbouiCOM.EditText)oMtx.Columns.Item(1).Cells.Item(i + 2).Specific).Value = (i + 2).ToString(); } } oForm.Freeze(false); } catch (Exception ex) { } finally { oForm.Freeze(false); } } else { Application.SBO_Application.MessageBox("Function works only on View Mode"); } }
/// <summary> /// /// </summary> /// <param name="FormUID"></param> /// <param name="pVal"></param> /// <param name="BubbleEvent"></param> /// public void app_ItemEvent(string FormUID, ref SAPbouiCOM.ItemEvent pVal, out bool BubbleEvent) { BubbleEvent = true; // se evalua que el boton presionado es el correspondiente al copy to // y se se asignan los valores a la clase copiadora la cual se encarga del transporte los itenes if (pVal.FormUID == "FSDC" && pVal.FormMode == 1 && pVal.BeforeAction == true && pVal.ItemUID == "btnCpTo" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) { try { if (!copyTo) { docNum = forma.DataSources.DBDataSources.Item("@ZTV").GetValue("DocNum", 0); copiar = true; copyTo = true; app.ActivateMenuItem("2305"); } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_copiar a -> " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se captura el evento que se produce al clickear o presionar el campo // descuento del documento if ((pVal.FormUID == "FSDC" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_KEY_DOWN && pVal.BeforeAction == false && (pVal.ItemUID == "txtDscPrc" || pVal.ItemUID == "txtDsc")) || (pVal.FormUID == "FSDC" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK && pVal.BeforeAction == false && (pVal.ItemUID == "txtDscPrc" || pVal.ItemUID == "txtDsc"))) { double discPcnt, discDoc, total; SAPbouiCOM.EditText oEdit; try { switch (pVal.ItemUID) { case "txtDscPrc": oEdit = (SAPbouiCOM.EditText)forma.Items.Item(pVal.ItemUID).Specific; discDoc = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV").GetValue("U_TlBfDsc", 0)) * (Convert.ToDouble(oEdit.Value) / 100); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_DiscPrc", 0, oEdit.Value); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_Disc", 0, discDoc.ToString()); break; case "txtDsc": oEdit = (SAPbouiCOM.EditText)forma.Items.Item(pVal.ItemUID).Specific; total = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV").GetValue("U_TlBfDsc", 0).ToString()); discPcnt = ((Convert.ToDouble(oEdit.Value) / total) * 100); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_Disc", 0, oEdit.Value); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_DiscPrc", 0, discPcnt.ToString()); break; default: break; } calcTaxDoc(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_descuento -> " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se utiliza esta comprobacion para activar un elemento de la // matrix despues de utilizar el metodo loadfromdatasource() if (smf && pVal.FormUID == "FSDC") { SAPbouiCOM.EditText oEdit; SAPbouiCOM.Matrix oMatrix; try { smf = false; oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item(colUID).Cells.Item(rowNum).Specific; oEdit.Active = true; calcTotalBfDsc(); calcTaxDoc(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_semaforo -> " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se registraran los cambios en los campo de calculo como la cantidad y el descuento entre otros if (((pVal.FormUID == "FSDC" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_KEY_DOWN && pVal.BeforeAction == false && pVal.ItemUID == "matrix1") || (pVal.FormUID == "FSDC" && pVal.EventType == SAPbouiCOM.BoEventTypes.et_CLICK && pVal.BeforeAction == false && pVal.ItemUID == "matrix1"))) { SAPbouiCOM.Matrix oMatrix; SAPbouiCOM.EditText oEdit; double qnty; double price; try { oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("colItemCod").Cells.Item(pVal.Row).Specific; // se verifica que el campo codigo cliente no este vacio para proceder a // realizar los calculos if (oEdit.Value.Trim() != "") { switch (pVal.ColUID) { case "colItemCod": if (pVal.CharPressed == 9) { colUID = "colDscrip"; smf = true; } break; case "colCant": oMatrix.FlushToDataSource(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item(pVal.ColUID).Cells.Item(pVal.Row).Specific; forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Quantity", pVal.Row - 1, oEdit.Value); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_OpenQty", pVal.Row - 1, oEdit.Value); qnty = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_Quantity", pVal.Row - 1)); price = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_PrcBfDi", pVal.Row - 1)); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Total", pVal.Row - 1, (qnty * price).ToString()); if ("0.0" != forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_DiscItem", pVal.Row - 1)) { goto Descuento; } if (pVal.CharPressed == 9) { colUID = "colPrecioU"; smf = true; oMatrix.LoadFromDataSource(); } break; case "colPrecioU": oMatrix.FlushToDataSource(); oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item(pVal.ColUID).Cells.Item(pVal.Row).Specific; forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_PrcBfDi", pVal.Row - 1, oEdit.Value); price = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_PrcBfDi", pVal.Row - 1)); qnty = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_Quantity", pVal.Row - 1)); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Total", pVal.Row - 1, (qnty * price).ToString()); if ("0.0" != forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_DiscItem", pVal.Row - 1)) { goto Descuento; } if (pVal.CharPressed == 9) { colUID = "colDiscPrc"; smf = true; oMatrix.LoadFromDataSource(); } break; case "colDiscPrc": double temp; double discLine; oMatrix.FlushToDataSource(); Descuento: oEdit = (SAPbouiCOM.EditText)oMatrix.Columns.Item("colDiscPrc").Cells.Item(pVal.Row).Specific; discLine = Convert.ToDouble(oEdit.Value); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_DiscItem", pVal.Row - 1, oEdit.Value); price = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_PrcBfDi", pVal.Row - 1)); qnty = Convert.ToDouble(forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_Quantity", pVal.Row - 1)); temp = (price * qnty); discLine = temp * (discLine / 100); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Total", pVal.Row - 1, (temp - discLine).ToString()); if (pVal.CharPressed == 9) { if (colUID == "colCant") { colUID = "colPrecioU"; } else { colUID = "colTaxCod"; } smf = true; oMatrix.LoadFromDataSource(); } break; default: break; } } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_calc_prc_qnt_dsc " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se utiliza para manejar todos los eventos que procuren actualizar la forma if (pVal.FormUID == "FSDC" && pVal.FormMode == 1 && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED) { try { if ((pVal.ItemUID == "txtCodProv" || pVal.ItemUID == "matrix1" || pVal.ItemUID == "txtNmbProv" || pVal.ItemUID == "btnCntPr")) { forma.Mode = SAPbouiCOM.BoFormMode.fm_UPDATE_MODE; } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_mode_edit " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se utiliza esta comprobacion por si dos o mas personas estan utilizando el modulo y deciden procesar una // solicitud con el mismo numero de documento if (pVal.FormUID == "FSDC" && pVal.FormMode == 3 && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "1" && pVal.BeforeAction == true) { SAPbouiCOM.ComboBox oCombo; SAPbouiCOM.Matrix oMatrix; try { oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; if (oMatrix.RowCount <= 1 && (forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_ItemCode", oMatrix.RowCount).ToString().Trim()) == "") { app.StatusBar.SetText("No se puede procesar la orden - Debe tener al menos un articulo", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); BubbleEvent = false; } else { if ("" == forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_ItemCode", oMatrix.RowCount - 1).ToString().Trim()) { oMatrix.FlushToDataSource(); forma.DataSources.DBDataSources.Item("@ZTV_LINES").RemoveRecord(forma.DataSources.DBDataSources.Item("@ZTV_LINES").Size - 1); oMatrix.LoadFromDataSource(); } } oCombo = ((SAPbouiCOM.ComboBox)forma.Items.Item("cmbSeries").Specific); oMatrix.FlushToDataSource(); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("DocNum", 0, forma.BusinessObject.GetNextSerialNumber(oCombo.Selected.Value, "OZTV").ToString()); oMatrix.LoadFromDataSource(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_mode_add " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // luego de que se procesa una orden se agrega una linea nueva en la matrix para se puedan seguir aniadiendo registros if (pVal.FormUID == "FSDC" && pVal.FormMode == 3 && pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "1" && pVal.BeforeAction == false) { SAPbouiCOM.Matrix oMatrix; SAPbouiCOM.Item oButton; try { oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; if (oMatrix.RowCount < 1) { oMatrix.AddRow(1, 0); } oButton = forma.Items.Item("btnCpTo"); llenarComboBox(); setFecha(); setColCount(); forma.ActiveItem = "txtCodProv"; oButton.Enabled = false; } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_post_add " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // si la solicitud esta en modo busqueda entonces se habilita el campo que contiene el DocNum // y el campo series if (pVal.FormUID == "FSDC" && pVal.FormMode == 0) { SAPbouiCOM.Item oButton; try { oButton = forma.Items.Item("btnCpTo"); oButton.Enabled = false; if (!forma.Items.Item("txtSeries").Enabled&& !forma.Items.Item("txtStatus").Enabled) { forma.Items.Item("txtSeries").Enabled = true; forma.Items.Item("txtStatus").Enabled = true; } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_mode_find " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // si la solicitud esta en modo de ok que no puedan alterar el tipo de serie con el // cual se proceso el documento ni tampoco su numeracion if ((pVal.FormUID == "FSDC" && pVal.FormMode == 1) && pVal.BeforeAction == false && pVal.ActionSuccess == true) { SAPbouiCOM.Item oButton; SAPbouiCOM.Matrix oMatrix; try { oButton = forma.Items.Item("btnCpTo"); oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; if (forma.Items.Item("cmbSeries").Enabled || forma.Items.Item("cmbDcType").Enabled) { forma.Items.Item("cmbSeries").Enabled = false; forma.Items.Item("cmbDcType").Enabled = false; } if (pVal.FormMode == 1) { if ("O" == forma.DataSources.DBDataSources.Item("@ZTV").GetValue("Status", 0).ToString()) { oButton.Enabled = true; } else { oButton.Enabled = false; } if ("" != forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_ItemCode", oMatrix.RowCount - 1).ToString().Trim()) { oMatrix.FlushToDataSource(); forma.DataSources.DBDataSources.Item("@ZTV_LINES").InsertRecord(forma.DataSources.DBDataSources.Item("@ZTV_LINES").Size); oMatrix.LoadFromDataSource(); } } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_mode_ok " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // si la solicitud esta en modo de UPDATE que no puedan alterar el tipo de serie con el // cual se proceso el documento ni tampoco su numeracion if ((pVal.FormUID == "FSDC" && pVal.FormMode == 2) && pVal.BeforeAction == true) { SAPbouiCOM.Item oButton; SAPbouiCOM.Matrix oMatrix; try { oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; oButton = forma.Items.Item("btnCpTo"); oButton.Enabled = false; if (pVal.EventType == SAPbouiCOM.BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "1") { if ("" == forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_ItemCode", oMatrix.RowCount - 1).ToString().Trim()) { oMatrix.FlushToDataSource(); forma.DataSources.DBDataSources.Item("@ZTV_LINES").RemoveRecord(forma.DataSources.DBDataSources.Item("@ZTV_LINES").Size - 1); oMatrix.LoadFromDataSource(); } } } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_mode_update " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se utiliza para ajustar el rectangulo cuando la forma cambie de tamanio if (pVal.FormUID == "FSDC" && pVal.BeforeAction == false && pVal.EventType == SAPbouiCOM.BoEventTypes.et_FORM_RESIZE && pVal.ActionSuccess == true) { SAPbouiCOM.Item oItem; SAPbouiCOM.Item rectangle; SAPbouiCOM.Matrix oMatrix; try { oItem = forma.Items.Item("matrix1"); oMatrix = (SAPbouiCOM.Matrix)oItem.Specific; rectangle = forma.Items.Item("rtgl"); rectangle.Width = (oItem.Width + 19); rectangle.Height = (oItem.Height + 52); oMatrix.AutoResizeColumns(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_resize " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } // se utiliza para capturar dos tipos de eventos: // el choose from list y el combo select switch (pVal.EventType) { case SAPbouiCOM.BoEventTypes.et_CHOOSE_FROM_LIST: SAPbouiCOM.IChooseFromListEvent oCflEvento = null; oCflEvento = ((SAPbouiCOM.IChooseFromListEvent)(pVal)); string sCflId = null; sCflId = oCflEvento.ChooseFromListUID; if (oCflEvento.Before_Action == false) { SAPbouiCOM.DataTable oDataTable = null; oDataTable = oCflEvento.SelectedObjects; if (pVal.ItemUID == "txtCodProv" || pVal.ItemUID == "txtNmbProv" && pVal.BeforeAction == false) { try { forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_CardCode", 0, System.Convert.ToString(oDataTable.GetValue("CardCode", 0))); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_CardName", 0, System.Convert.ToString(oDataTable.GetValue("CardName", 0))); forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_CntCod", 0, System.Convert.ToString(oDataTable.GetValue("CntctPrsn", 0))); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_cfl_BPCode " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } if (pVal.ItemUID == "btnCntPr" && pVal.Action_Success) { try { forma.DataSources.DBDataSources.Item("@ZTV").SetValue("U_CntCod", 0, Convert.ToString(oDataTable.GetValue(2, 0))); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_BPCntName " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } if (sCflId == "CFL_7" || sCflId.ToString() == "CFL_5") { SAPbouiCOM.Matrix oMatrix; try { int i = pVal.Row; oMatrix = (SAPbouiCOM.Matrix)forma.Items.Item("matrix1").Specific; // la manera en como se agregara los itenes a la matrix siempre sera // en modo edicion de un registro ya que se clickea una columna existente // en este caso una columna sin ningun valor forma.DataSources.DBDataSources.Item("@ZTV_LINES").Clear(); oMatrix.FlushToDataSource(); if (sCflId == "CFL_5") { forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", (i - 1), oDataTable.GetValue("ItemCode", 0).ToString()); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", (i - 1), oDataTable.GetValue("ItemName", 0).ToString()); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Quantity", (i - 1), "1"); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_OpenQty", (i - 1), forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_Quantity", (i - 1)).ToString()); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_PrcBfDi", (i - 1), oDataTable.GetValue("LastPurPrc", 0).ToString()); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_UnitMsr", (i - 1), oDataTable.GetValue("BuyUnitMsr", 0).ToString()); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Total", (i - 1), oDataTable.GetValue("LastPurPrc", 0).ToString()); if (oDataTable.GetValue("VATLiable", 0).ToString() == "N") { forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_TaxCode", (i - 1), "EX"); } else { forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_TaxCode", (i - 1), "IT"); } } if (sCflId == "CFL_7") { if ((oDataTable.GetValue("Code", 0).ToString() == "IT") || (oDataTable.GetValue("Code", 0).ToString() == "EX")) { forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_TaxCode", (i - 1), oDataTable.GetValue("Code", 0).ToString()); } else { app.StatusBar.SetText("No se puede utilizar este tipo de impuesto.", SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Error); } } if ((i == oMatrix.RowCount) && (sCflId == "CFL_5")) { forma.DataSources.DBDataSources.Item("@ZTV_LINES").InsertRecord(i); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_ItemCode", i, ""); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Dscript", i, ""); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_Quantity", i, "1"); forma.DataSources.DBDataSources.Item("@ZTV_LINES").SetValue("U_OpenQty", i, forma.DataSources.DBDataSources.Item("@ZTV_LINES").GetValue("U_Quantity", i).ToString()); } oMatrix.LoadFromDataSource(); smf = true; rowNum = pVal.Row; colUID = pVal.ColUID; calcTotalBfDsc(); calcTaxDoc(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_matrix1 " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } } break; case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT: SAPbouiCOM.ComboBox oCombo; int lNum = 0; // con este procedimiento se llena el combo de la series if (pVal.ItemUID == "cmbSeries" && pVal.Before_Action == false && pVal.ItemChanged == true) { oCombo = ((SAPbouiCOM.ComboBox)forma.Items.Item("cmbSeries").Specific); try { SAPbouiCOM.EditText oEdit; lNum = forma.BusinessObject.GetNextSerialNumber(oCombo.Selected.Value, "OZTV"); oEdit = (SAPbouiCOM.EditText)forma.Items.Item("txtSeries").Specific; oEdit.String = lNum.ToString(); } catch (Exception e) { app.StatusBar.SetText("solicitud_app_event_comboSeries " + e.Message, SAPbouiCOM.BoMessageTime.bmt_Short, SAPbouiCOM.BoStatusBarMessageType.smt_Warning); } } break; } }
private void Button1_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { //throw new System.NotImplementedException(); if (pVal.FormMode == 1) { //Get DATA SUM CCM int DocEntry = int.Parse(((SAPbouiCOM.EditText)(this.GetItem("0_U_E").Specific)).Value); string Project = ((SAPbouiCOM.EditText)(this.GetItem("20_U_E").Specific)).Value; DataTable Sum_DUTRU = Load_Data_DUTRU(Project, DocEntry); oApp.ActivateMenuItem("DUTRU"); SAPbouiCOM.Form oForm = Application.SBO_Application.Forms.ActiveForm; //Get DocNum CTG try { ((SAPbouiCOM.EditText)oForm.Items.Item("20_U_E").Specific).Value = DocEntry.ToString(); oForm.Freeze(true); oForm.PaneLevel = 1; SAPbouiCOM.Matrix oMtx = (SAPbouiCOM.Matrix)oForm.Items.Item("0_U_G").Specific; for (int i = 0; i < Sum_DUTRU.Rows.Count; i++) { oApp.SetStatusBarMessage(string.Format("Creating DUTRU: {0}", (i + 1) + "/" + Sum_DUTRU.Rows.Count), SAPbouiCOM.BoMessageTime.bmt_Short, false); DataRow r = Sum_DUTRU.Rows[i]; //Subproject Code ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_2").Cells.Item(i + 1).Specific).Value = r["High_Level_SUM"].ToString(); //Subproject Description ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_3").Cells.Item(i + 1).Specific).Value = r["High_Level_Name"].ToString(); //CP NCC ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_4").Cells.Item(i + 1).Specific).Value = r["CP_NCC"].ToString(); //CP NTP ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_5").Cells.Item(i + 1).Specific).Value = r["CP_NTP"].ToString(); //CP DTC ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_6").Cells.Item(i + 1).Specific).Value = r["CP_DTC"].ToString(); //CP VTP ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_7").Cells.Item(i + 1).Specific).Value = r["CP_VTP"].ToString(); //CP VC ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_8").Cells.Item(i + 1).Specific).Value = r["CP_VC"].ToString(); //CP CN ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_9").Cells.Item(i + 1).Specific).Value = r["CP_CN"].ToString(); //CP DP ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_10").Cells.Item(i + 1).Specific).Value = r["CP_DP"].ToString(); //CP DP2 ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_11").Cells.Item(i + 1).Specific).Value = r["CP_DP2"].ToString(); //CP PRELIM ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_12").Cells.Item(i + 1).Specific).Value = r["CP_PRELIM"].ToString(); //CP TB ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_13").Cells.Item(i + 1).Specific).Value = r["CP_TB"].ToString(); //CP Khac ((SAPbouiCOM.EditText)oMtx.Columns.Item("C_0_14").Cells.Item(i + 1).Specific).Value = r["CP_Khac"].ToString(); if (i < Sum_DUTRU.Rows.Count - 1) { oMtx.AddRow(); ((SAPbouiCOM.EditText)oMtx.Columns.Item(1).Cells.Item(i + 2).Specific).Value = (i + 2).ToString(); } } oForm.Freeze(false); } catch (Exception ex) { } finally { oForm.Freeze(false); } } else { Application.SBO_Application.MessageBox("Function works only on View Mode"); } }
//View Button private void Button1_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal) { try { if (Grid0.Rows.SelectedRows.Count == 1) { oApp.ActivateMenuItem(MenuUID); SAPbouiCOM.Form frm = Application.SBO_Application.Forms.ActiveForm; frm.Mode = SAPbouiCOM.BoFormMode.fm_FIND_MODE; frm.Items.Item("1_U_E").Enabled = true; //find Selected Key Matrix string DocNum = Grid0.DataTable.GetValue("Document Number", Grid0.Rows.SelectedRows.Item(0, SAPbouiCOM.BoOrderType.ot_RowOrder)).ToString(); ((SAPbouiCOM.EditText)frm.Items.Item("1_U_E").Specific).Value = DocNum; frm.Items.Item("1").Click(); frm.EnableMenu("1282", false); // Add New Record frm.EnableMenu("1288", false); // Next Record frm.EnableMenu("1289", false); // Pevious Record frm.EnableMenu("1290", false); // First Record frm.EnableMenu("1291", false); // Last record frm.EnableMenu("1283", false); // Remove frm.EnableMenu("1284", false); // Cancel frm.EnableMenu("1286", false); // Close frm.EnableMenu("1304", false); //Refresh frm.EnableMenu("BILLVP_Remove_Line", false); frm.EnableMenu("BILLVP_Add_Line", false); //Disable Header foreach (SAPbouiCOM.Item it in frm.Items) { if (it.Type == SAPbouiCOM.BoFormItemTypes.it_EDIT || it.Type == SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX) { switch (it.Description.Trim()) { case "Financial Project": it.Enabled = false; break; case "Project Name": it.Enabled = false; break; case "BP Code": it.Enabled = false; break; case "BP Name": it.Enabled = false; break; case "Bill Type": it.Enabled = false; break; case "Period": it.Enabled = false; break; case "From Date": it.Enabled = false; break; case "To Date": it.Enabled = false; break; case "Tạm ứng": it.Enabled = false; break; case "Khấu trừ tạm ứng": it.Enabled = false; break; } } } } else { oApp.MessageBox("Please select record !"); } } catch (Exception ex) { oApp.MessageBox(ex.Message); } }