public static int Update(SoftType softType) { using (var connection = new DBConnection()) using (var command = DBConnection.CreateCommand()) { command.CommandText = _updateQuery; if (softType == null) { MessageBox.Show("В метод Update не передана ссылка на объект вида ПО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } command.Parameters.Add(DBConnection.CreateParameter("SoftType", softType.SoftTypeName)); command.Parameters.Add(DBConnection.CreateParameter("IDSoftType", softType.IdSoftType)); try { return(connection.SqlExecuteNonQuery(command)); } catch (SqlException e) { MessageBox.Show(String.Format(CultureInfo.InvariantCulture, "Не удалось изменить данные о виде ПО. Подробная ошибка: {0}", e.Message), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } } }
public static int Insert(SoftType softType) { using (var connection = new DBConnection()) using (var command = DBConnection.CreateCommand()) { command.CommandText = _insertQuery; if (softType == null) { MessageBox.Show("В метод Insert не передана ссылка на объект вида ПО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } command.Parameters.Add(DBConnection.CreateParameter("SoftType", softType.SoftTypeName)); try { return(Convert.ToInt32(connection.SqlExecuteScalar(command), CultureInfo.InvariantCulture)); } catch (SqlException e) { connection.SqlRollbackTransaction(); MessageBox.Show(String.Format(CultureInfo.InvariantCulture, "Не удалось добавить вид ПО в базу данных. Подробная ошибка: {0}", e.Message), "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } } }
/// <summary> /// Generic: Get all items of a given softtype. /// </summary> /// <param name="type">Softtype</param> /// <permission cref="System.Security.PermissionSet">Public Access</permission> public static System.Collections.Generic.List <JObject> SearchAllItemsOfType(SoftType type) { Search softType = new Search(new Uri(type.SearchAllHref)); var results = softType.GetAll(new Uri(type.SearchAllHref)); //Console.WriteLine(results.Count); return(results); }
private static SoftType RowToSoftType(DataRow row) { var softType = new SoftType { IdSoftType = ViewportHelper.ValueOrNull <int>(row, "ID SoftType"), SoftTypeName = ViewportHelper.ValueOrNull(row, "SoftType") }; return(softType); }
public IActionResult EditSoft(int id, int sample, SoftType softType, bool tissue, bool count, bool degree) { var softs = _context.Soft .Include(i => i.Individual) .Where(m => m.IndividualId == id && m.SoftType == softType); var feature = HttpContext.Features.Get <IRequestCultureFeature>(); var lang = feature.RequestCulture.Culture.TwoLetterISOLanguageName.ToUpperInvariant(); ViewData["lang"] = lang; var degrees = from Degree e in Enum.GetValues(typeof(Degree)) select new { Id = e, Name = e.GetDisplayName(lang) }; ViewData["Degree"] = new SelectList(degrees, "Id", "Name"); IndividualSoftTissueViewModel model = new IndividualSoftTissueViewModel() { Id = id, SamplingId = sample, SoftType = softType, Check = softs.Any(), }; model.Configs.AddRangeOverride(new Dictionary <string, bool> { { "tissue", tissue }, { "count", count }, { "degree", degree } }); if (tissue) { model.Tissues.AddRange(Enum.GetValues(typeof(Tissue)) .Cast <Tissue>() .Select(t => new TissueView { Check = softs.Any(s => s.Tissue == t), Count = softs.Any(s => s.Tissue == t) ? softs.FirstOrDefault(s => s.Tissue == t).Count : null, Degree = softs.Any(s => s.Tissue == t) ? softs.FirstOrDefault(s => s.Tissue == t).Degree : null, Text = t.GetDisplayName(lang), Value = ((int)t).ToString(CultureInfo.InvariantCulture), }).ToList()); } if (count && !tissue) { model.Count = softs.Any() ? softs.First().Count : null; } return(PartialView("_EditSoft", model)); }
private List <SoftType> SoftTypesFromView() { var list = new List <SoftType>(); for (var i = 0; i < _vSoftTypes.Count; i++) { var row = (DataRowView)_vSoftTypes[i]; var st = new SoftType { IdSoftType = ViewportHelper.ValueOrNull <int>(row, "ID SoftType"), SoftTypeName = ViewportHelper.ValueOrNull(row, "SoftType") }; list.Add(st); } return(list); }
private List <SoftType> SoftTypesFromViewport() { var list = new List <SoftType>(); for (var i = 0; i < dataGridView.Rows.Count; i++) { if (dataGridView.Rows[i].IsNewRow) { continue; } var row = dataGridView.Rows[i]; var st = new SoftType { IdSoftType = ViewportHelper.ValueOrNull <int>(row, "idSoftType"), SoftTypeName = ViewportHelper.ValueOrNull(row, "softType") }; list.Add(st); } return(list); }
public static JObject SearchSoftTypeItem(SoftType type, string searchTerm, string searchOn, StringComparison caseSensitivity) { Console.WriteLine("Searching for all " + type.Name + " with " + searchOn + ": " + searchTerm + " \nSearch URI:" + type.SearchAllHref); try { Search study = new Search(new Uri(type.SearchAllHref)); JObject match = study.SearchAllPages(searchTerm, searchOn, caseSensitivity); if (match != null) //Found a Match { return(match); } else//Data was not found { Console.WriteLine("No " + type.Name + " found with " + searchOn + ": " + searchTerm); } } // catch (HttpRequestException) { throw new SearchException("Failed to Get item."); } catch (System.Net.WebException) { throw new ConnectionException("Unable to connect to the remote server. A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. Please ensure there is a working internet connection and the host name provided is correct."); } catch (JsonReaderException) { throw new SearchException("The Request response is invalid JSON"); } //The requested space cannot be found catch (UriFormatException) { throw new SearchException("Some invalid URI encountered"); } return(null); }
public bool Equals(SoftType other) { return(Equals((object)other)); }