public override void LoadData() { NavigationHelper.IsBusy = true; BackgroundProcessFactory.RunAsync(null, (o, e) => { e.Result = DBDataSource.GeTestAttempts(); }, (o, e) => { NavigationHelper.IsBusy = false; if (e.Error != null) { return; } else { var attemts = e.Result as List <TestAttempt>; if (attemts != null) { ResultList = new ObservableCollection <TestAttempt>(attemts); _cv = CollectionViewSource.GetDefaultView(ResultList); _cv.Filter = FilterValid; _cv.Refresh(); } } }); }
/// <summary> /// Validate customer code - nomor memo /// </summary> private void Validate_CashDisc_CustCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent) { if (bubbleEvent) { if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true) { Form oForm = oSBOApplication.Forms.Item(formUID); DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_CASHDISC"); Recordset oRec = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); try { oForm.Freeze(true); string noMemo = GenerateNoMemo(oForm.Items.Item("tCusCd").Specific.Value); dtSource.SetValue("Code", 0, noMemo); } catch (Exception ex) { bubbleEvent = false; oSBOApplication.MessageBox(ex.Message); } finally { if (oForm != null) { oForm.Freeze(false); } Utils.releaseObject(oForm); Utils.releaseObject(dtSource); Utils.releaseObject(oRec); } } } }
private void ExecuteEditQuestionCommand(Object parameter) { var view = new TecherFormAddAndEditQuestions(); var vm = new AddEditQuestionViewModel(); vm.Question = new Question() { Answers = new List <Answer>(SelectedQuestion.Answers), Id = SelectedQuestion.Id, Content = SelectedQuestion.Content, Created = SelectedQuestion.Created, Modifiyed = SelectedQuestion.Modifiyed, Image = SelectedQuestion.Image }; vm.AnswerCollection = new ObservableCollection <Answer>(vm.Question.Answers); vm.Window = view; view.DataContext = vm; var result = view.ShowDialog(); if (result.HasValue && result.Value) { vm.Question.Answers = new List <Answer>(vm.AnswerCollection); var editResult = DBDataSource.EditQuestion(vm.Question); if (editResult) { QuestionCollection = new ObservableCollection <Question>(DBDataSource.GetQuestions()); } } }
/// <summary> /// Sets the specified column identifier. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <param name="value">The value.</param> public static void Set(this DBDataSource source, string columnId, int rowIndex, DateTime?value) { if (value != null) { source.SetValue(columnId, rowIndex, ((DateTime)value).ToString("yyyyMMdd")); } }
/// <summary> /// Creates the new item. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="source">The source.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns></returns> private static T CreateNewItem <T>(DBDataSource source, int rowIndex) where T : class, new() { var sourceFields = source.Fields; var columnCount = sourceFields.Count; var item = new T(); var type = typeof(T); for (var column = 0; column < columnCount; column++) { var columnName = sourceFields.Item(column).Name; var property = DetermineProperty(type, columnName); if (property.PropertyType == typeof(string)) { property.SetValue(item, source.GetString(columnName, rowIndex)); } if (property.PropertyType == typeof(int)) { property.SetValue(item, source.GetInt(columnName, rowIndex)); } if (property.PropertyType == typeof(double)) { property.SetValue(item, source.GetDouble(columnName, rowIndex)); } if (property.PropertyType == typeof(DateTime)) { property.SetValue(item, source.GetDateTime(columnName, rowIndex)); } } return(item); }
private void TemplateLoad(ref Form oForm) { try { DBDataSource dtSource = null; dtSource = oForm.DataSources.DBDataSources.Item("@SOL_UPBOMVER_H"); oForm.Freeze(true); DateTime updDate = DateTime.Now.Date; string updTime = DateTime.Now.TimeOfDay.ToString(); GetLastUpdate(out updDate, out updTime); dtSource.SetValue("U_SOL_UPDATE", 0, updDate.ToString("yyyyMMdd", CultureInfo.InvariantCulture)); dtSource.SetValue("U_SOL_UPTIME", 0, updTime); EditText oEdit = oForm.Items.Item("tEdit").Specific; oEdit.Active = true; oForm.Items.Item("tUpDt").Enabled = false; oForm.Items.Item("tUpTm").Enabled = false; Utils.releaseObject(dtSource); } catch (Exception ex) { oSBOApplication.MessageBox(ex.Message); } finally { oForm.Freeze(false); } }
private static void ButtonRefresh(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { bBubbleEvent = true; if (oItemEvent.BeforeAction) { } if (!oItemEvent.BeforeAction) { var oForm = sbo_application.Forms.Item(formUID); if (oItemEvent.EventType == BoEventTypes.et_ITEM_PRESSED) { DBDataSource det = oForm.DataSources.DBDataSources.Item(pluginForm.dbDetalle); for (int i = 0; i < det.Size; i++) { } ((Matrix)oForm.Items.Item(pluginForm.MtxOV.Uid).Specific).LoadFromDataSourceEx(); ((Matrix)oForm.Items.Item(pluginForm.MtxOV.Uid).Specific).AutoResizeColumns(); } //if (oForm.Mode == BoFormMode.fm_OK_MODE) oForm.Mode = BoFormMode.fm_UPDATE_MODE; } }
protected override void OnResume() { // Handle when your app resumes DBDataSource ds = DBDataSource.GetInstance(); ds.StartDataSource(); }
/// <summary> /// Clear Data and Load Data Source /// </summary> private void Template_Clear_FixDisc(ref Form oForm) { DBDataSource fixDisc_H = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_H"); DBDataSource fixDisc_D1 = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_D1"); DBDataSource fixDisc_D2 = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_D2"); fixDisc_H.SetValue("Code", 0, ""); fixDisc_H.SetValue("U_SOL_AREA", 0, ""); fixDisc_H.SetValue("U_SOL_CARDCODE", 0, ""); fixDisc_H.SetValue("U_SOL_CARDNAME", 0, ""); fixDisc_D1.Clear(); fixDisc_D1.Clear(); fixDisc_D1.InsertRecord(fixDisc_D1.Size); fixDisc_D2.InsertRecord(fixDisc_D2.Size); fixDisc_D1.Offset = fixDisc_D1.Size - 1; fixDisc_D1.SetValue("LineId", fixDisc_D1.Size - 1, fixDisc_D1.Size.ToString()); fixDisc_D2.Offset = fixDisc_D2.Size - 1; fixDisc_D2.SetValue("LineId", fixDisc_D2.Size - 1, fixDisc_D2.Size.ToString()); oForm.Items.Item("mt_1").Specific.LoadFromDataSource(); oForm.Items.Item("mt_2").Specific.LoadFromDataSource(); Utils.releaseObject(fixDisc_H); Utils.releaseObject(fixDisc_D1); Utils.releaseObject(fixDisc_D2); }
/// <summary> /// Template Fix Discount When Load /// </summary> public void Template_Add_FixDisc(ref Form oForm) { try { DBDataSource dtSource = null; dtSource = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_H"); oForm.Freeze(true); Template_Clear_FixDisc(ref oForm); oForm.DataBrowser.BrowseBy = "tCode"; oForm.Items.Item("tab2").Click(); oForm.Items.Item("tab1").Click(); oForm.Items.Item("tCustCd").Click(); Utils.releaseObject(dtSource); } catch (Exception ex) { oSBOApplication.MessageBox(ex.Message); } finally { oForm.Freeze(false); } }
/// <summary> /// Sets the specified column identifier. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <param name="value">The value.</param> public static void Set(this DBDataSource source, string columnId, int rowIndex, double?value) { if (value != null) { source.SetValue(columnId, rowIndex, ((double)value).ToString(CultureInfo.InvariantCulture)); } }
/// <summary> /// Sets the specified column identifier. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <param name="value">The value.</param> public static void Set(this DBDataSource source, string columnId, int rowIndex, string value) { if (value != null) { source.SetValue(columnId, rowIndex, value); } }
/// <summary> /// Validate - Brand Code /// Ketika Brand Code Dipilih, Brand Name terisi otomatis /// </summary> private void Validate_FixDisc_BrandCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent) { if (bubbleEvent) { if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true) { Form oForm = oSBOApplication.Forms.Item(formUID); Matrix oMtx = oForm.Items.Item("mt_1").Specific; DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_D1"); Recordset oRec = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); try { oForm.Freeze(true); oMtx.FlushToDataSource(); if (pVal.Row == oMtx.RowCount) { dtSource.InsertRecord(dtSource.Size); dtSource.SetValue("LineId", dtSource.Size - 1, dtSource.Size.ToString()); } string nama = string.Empty; string brandCode = oMtx.Columns.Item("cBrCd").Cells.Item(pVal.Row).Specific.Value; string query = "SELECT T1.\"U_SOL_SUBGRP\" " + "FROM \"@SOL_ITMGRP_MAP_H\" T0 " + "INNER JOIN \"@SOL_ITMGRP_MAP_D\" T1 ON T0.\"Code\" = T1.\"Code\" " + "WHERE T1.\"U_SOL_SUBGRP_CODE\" = '" + brandCode + "'"; oRec.DoQuery(query); if (oRec.RecordCount > 0) { nama = oRec.Fields.Item(0).Value; } dtSource.SetValue("U_SOL_BRANDNAME", pVal.Row - 1, nama); oMtx.LoadFromDataSource(); } catch (Exception ex) { bubbleEvent = false; oSBOApplication.MessageBox(ex.Message); } finally { if (oForm != null) { oForm.Freeze(false); } Utils.releaseObject(oForm); Utils.releaseObject(oMtx); Utils.releaseObject(dtSource); Utils.releaseObject(oRec); } } } }
/// <summary> /// Asigna los data sources al formualario /// </summary> /// <param name="formUID"></param> protected override void AgregarDataSources() { //Asigna la tabla de usuario de CAE's como data source dataSourceMatriz = Formulario.DataSources.DBDataSources.Add("@TFECAE"); //Asigna el user data source Formulario.DataSources.UserDataSources.Add("dsCbAct", BoDataType.dt_SHORT_TEXT, 1); }
public void InsertTest() { DBDataSource ds = new DBDataSource(); Student s = ds.Insert(testStudent); Assert.NotEqual(0, s.Id); Assert.True(Utilities.DelById(s.Id)); }
protected override void OnSleep() { // Handle when your app sleeps DBDataSource ds = DBDataSource.GetInstance(); ds.StopDataSource(); // Handle when your app sleeps }
public override void RegrasDeNegocioAoSalvar(SAPbouiCOM.Form form, DBDataSource dbdts) { var numPreContrato = dbdts.GetValue(_numeroDoPreContrato.Datasource, 0); if (string.IsNullOrEmpty(numPreContrato)) { throw new BusinessRuleException("Não foi possível identificar qual o Pré-Contrato referente a este Contrato Final."); } }
/// <summary> /// Refresh Matrix /// </summary> private void RefreshMatrix(Form oForm, string mtxName, string dataSource) { DBDataSource dtSource = oForm.DataSources.DBDataSources.Item(dataSource); Matrix oMtx = oForm.Items.Item(mtxName).Specific; dtSource.Clear(); oMtx.FlushToDataSource(); Utils.releaseObject(dtSource); Utils.releaseObject(oMtx); }
public static DBAccess GetInstance(DBDataSource dataSource) { switch (dataSource) { case DBDataSource.MYSQL: return new DBMySqlAccess(); case DBDataSource.MSSQL: break; } return null; }
/// <summary> /// Validate - Item Code /// Ketika Item Code Dipilih, Item Name terisi otomatis /// </summary> private void Validate_FixDisc_ItemCode(string formUID, ref ItemEvent pVal, ref bool bubbleEvent) { if (bubbleEvent) { if (pVal.BeforeAction == false && pVal.ActionSuccess == true && pVal.ItemChanged == true) { Form oForm = oSBOApplication.Forms.Item(formUID); Matrix oMtx = oForm.Items.Item("mt_2").Specific; DBDataSource dtSource = oForm.DataSources.DBDataSources.Item("@SOL_FIXDISC_D2"); Recordset oRec = oSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset); try { oForm.Freeze(true); oMtx.FlushToDataSource(); if (pVal.Row == oMtx.RowCount) { dtSource.InsertRecord(dtSource.Size); dtSource.SetValue("LineId", dtSource.Size - 1, dtSource.Size.ToString()); } string nama = string.Empty; oRec.DoQuery("SELECT \"ItemName\" FROM OITM WHERE \"ItemCode\" = '" + oMtx.Columns.Item("cItmCd").Cells.Item(pVal.Row).Specific.Value + "'"); if (oRec.RecordCount > 0) { nama = oRec.Fields.Item(0).Value; } dtSource.SetValue("U_SOL_ITEMNAME", pVal.Row - 1, nama); oMtx.LoadFromDataSource(); } catch (Exception ex) { bubbleEvent = false; oSBOApplication.MessageBox(ex.Message); } finally { if (oForm != null) { oForm.Freeze(false); } Utils.releaseObject(oForm); Utils.releaseObject(oMtx); Utils.releaseObject(dtSource); Utils.releaseObject(oRec); } } } }
protected override void OnStart() { // Handle when your app starts DBDataSource ds = DBDataSource.GetInstance(); if (ds.Running == false) { ds.StartDataSource(); } MainPage = new NavigationPage(new ContactListPage()); }
public override void LoadData() { NavigationHelper.IsBusy = true; BackgroundProcessFactory.RunAsync(null, (o, e) => { e.Result = DBDataSource.GetTestGradeLimit(NavigationHelper.CurrrentTest.Id); }, (o, e) => { NavigationHelper.IsBusy = false; if (e.Error != null) { return; } else { _limits = e.Result as List <TestGradeLimit>; if (_limits != null) { foreach (Grade grade in Enum.GetValues(typeof(Grade))) { var limit = _limits.FirstOrDefault(l => l.Grade == (int)grade); if (limit != null) { switch (grade) { case Grade.Poor: PoorMaxValue = limit.ToPer; break; case Grade.Satisfactory: SatisfyMinValue = limit.FromPer; SatisfyMaxValue = limit.ToPer; break; case Grade.Good: GoodMinValue = limit.FromPer; GoodMaxValue = limit.ToPer; break; case Grade.Excellent: ExcellentMinValue = limit.FromPer; ExcellentMaxValue = limit.ToPer; break; } } } MinuteLimitCount = NavigationHelper.CurrrentTest.MinuteTimeLimit; QuestionCount = NavigationHelper.CurrrentTest.QuestionCount; } } }); }
private static void BindMatrixData(string formUID, ref ItemEvent oItemEvent, SAPbobsCOM.Company sbo_company, ref Application sbo_application, out bool bBubbleEvent, string sessionId) { Form oForm = sbo_application.Forms.Item(formUID); bBubbleEvent = true; DBDataSource dbData = oForm.DataSources.DBDataSources.Add("OBTN"); Matrix oMatrix = (Matrix)oForm.Items.Item(pluginForm.MatrixLote.Uid).Specific; Column oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_ItemCode.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_ItemCode.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_itemName.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_itemName.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_SysNumber.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_SysNumber.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_DistNumber.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_DistNumber.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_MnfSerial.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_MnfSerial.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_InDate.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_InDate.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_Status.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_Status.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_Quantity.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_Quantity.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_Balance.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_Balance.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_U_FRU_Variedad.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_U_FRU_Variedad.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_U_FRU_Tipo.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_U_FRU_Tipo.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_U_FRU_Calibre.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_U_FRU_Calibre.dbField); oCol = oMatrix.Columns.Item(pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.Uid); oCol.DataBind.SetBound(true, "OBTN", pluginForm.MatrixLote.Colums.Col_U_FRU_Destino.dbField); dbData.Query(null); oMatrix.LoadFromDataSourceEx(true); }
public static DateTime GetValueAsDateTime(this DBDataSource dataTable, string field, int rowIndex) { DateTime returnDate = DateTime.MinValue; if (!DateTime.TryParseExact(dataTable.GetValue(field, rowIndex), "yyyyMMdd", CultureInfo.InvariantCulture, DateTimeStyles.None, out returnDate)) { return(DateTime.MinValue); } return(returnDate); }
protected override void OnDisappearing() { DBDataSource ds = DBDataSource.GetInstance(); Contact contact = BindingContext as Contact; if (contact != null) { ds.SaveContact(contact); } }
public ContactListPage() { InitializeComponent(); this.Title = "Contacts"; NavigationPage.SetHasNavigationBar(this, false); DBDataSource ds = DBDataSource.GetInstance(); Items = ds.ActiveContacts; BindingContext = this; }
private void ValidarMatriz(DBDataSource dbdts, Matriz matriz) { for (int i = 0; i < dbdts.Size; i++) { var participante = matriz._participante.GetValorDBDatasource <string>(dbdts, i); var comissao = matriz._comissao.GetValorDBDatasource <double>(dbdts, i); if (!String.IsNullOrEmpty(participante) && comissao == 0) { throw new FormValidationException(matriz._comissao.Mensagem, matriz._comissao.ItemUID, "", i); } } }
/// <summary> /// Gets the date time. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns></returns> public static DateTime?GetDateTime(this DBDataSource source, string columnId, int rowIndex) { var sourceValue = source.GetString(columnId, rowIndex); if (string.IsNullOrEmpty(sourceValue)) { return(null); } var value = DateTime.ParseExact(sourceValue, "yyyyMMdd", CultureInfo.InvariantCulture); return(value); }
public override string ProximaChavePrimaria(DBDataSource dbdts) { var numPreContrato = dbdts.GetValue(_numeroDoPreContrato.Datasource, 0); using (var recordset = new RecordSet()) { var rs = recordset.DoQuery( $@"SELECT CONVERT(NVARCHAR, {numPreContrato}) + '.' + CONVERT(NVARCHAR, COUNT(*) + 1) as codigo FROM [{dbdts.TableName}] WHERE {_numeroDoPreContrato.Datasource} = {numPreContrato}"); return(rs.Fields.Item("codigo").Value); } }
public static DBConnection GetInstance(DBDataSource dataSource) { _connectionString = AppConfig.ConnectionString; switch (dataSource) { case DBDataSource.MYSQL: return new DBMySqlConnection(); case DBDataSource.MSSQL: break; } return null; }
private void ExecuteDeleteQuestionCommand(Object parameter) { var result = MessageBox.Show("Действительно удалить вопрос?", "Удаление вопроса", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { var resultTry = DBDataSource.DeleteQuestion(SelectedQuestion); if (resultTry) { QuestionCollection.Remove(SelectedQuestion); } } }
/// <summary> /// Gets the int. /// </summary> /// <param name="source">The source.</param> /// <param name="columnId">The column identifier.</param> /// <param name="rowIndex">Index of the row.</param> /// <returns></returns> public static int?GetInt(this DBDataSource source, string columnId, int rowIndex) { string sourceValue = source.GetString(columnId, rowIndex); if (string.IsNullOrEmpty(sourceValue)) { return(null); } var value = int.Parse(sourceValue, NumberStyles.AllowLeadingSign | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture); return(value); }