public static int Insert(SoftLicDocType softLicDocType) { using (var connection = new DBConnection()) using (var command = DBConnection.CreateCommand()) { command.CommandText = _insertQuery; if (softLicDocType == null) { MessageBox.Show("В метод Insert не передана ссылка на объект документа-основания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } command.Parameters.Add(DBConnection.CreateParameter("DocType", softLicDocType.DocType)); 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); } } }
public static int Update(SoftLicDocType softLicDocType) { using (var connection = new DBConnection()) using (var command = DBConnection.CreateCommand()) { command.CommandText = _updateQuery; if (softLicDocType == null) { MessageBox.Show("В метод Update не передана ссылка на объект документа-основания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); return(-1); } command.Parameters.Add(DBConnection.CreateParameter("DocType", softLicDocType.DocType)); command.Parameters.Add(DBConnection.CreateParameter("IDDocType", softLicDocType.IdDocType)); 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); } } }
private static SoftLicDocType RowToSoftLicDocType(DataRow row) { var softLicDocType = new SoftLicDocType { IdDocType = ViewportHelper.ValueOrNull <int>(row, "ID DocType"), DocType = ViewportHelper.ValueOrNull(row, "DocType") }; return(softLicDocType); }
private List <SoftLicDocType> SoftLicTypesFromView() { var list = new List <SoftLicDocType>(); for (var i = 0; i < _vSoftLicDocTypes.Count; i++) { var row = (DataRowView)_vSoftLicDocTypes[i]; var st = new SoftLicDocType { IdDocType = ViewportHelper.ValueOrNull <int>(row, "ID DocType"), DocType = ViewportHelper.ValueOrNull(row, "DocType") }; list.Add(st); } return(list); }
private List <SoftLicDocType> SoftLicTypesFromViewport() { var list = new List <SoftLicDocType>(); for (var i = 0; i < dataGridView.Rows.Count; i++) { if (dataGridView.Rows[i].IsNewRow) { continue; } var row = dataGridView.Rows[i]; var st = new SoftLicDocType { IdDocType = ViewportHelper.ValueOrNull <int>(row, "idSoftLicDocType"), DocType = ViewportHelper.ValueOrNull(row, "softLicDocType") }; list.Add(st); } return(list); }
public bool Equals(SoftLicDocType other) { return(Equals((object)other)); }