/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row"> /// The input DataRow /// </param> /// <param name="columnName"> /// The input column name specificy which row value to retrieve. /// </param> /// <returns> /// The DataRow value for the column specified. /// </returns> public static T Field <T>(this DataRow row, string columnName) { DataSetUtil.CheckArgumentNull(row, "row"); return(UnboxT <T> .Unbox(row[columnName])); }
/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row"> /// The input DataRow /// </param> /// <param name="column"> /// The input DataColumn specificy which row value to retrieve. /// </param> /// <returns> /// The DataRow value for the column specified. /// </returns> public static T Field <T>(this DataRow row, DataColumn column) { DataSetUtil.CheckArgumentNull(row, "row"); return(UnboxT <T> .Unbox(row[column])); }
/// <summary> /// This method sets a new value for the specified column for the DataRow it’s called on. /// </summary> /// <param name="row"> /// The input DataRow. /// </param> /// <param name="columnIndex"> /// The input ordinal specifying which row value to set. /// </param> /// <param name="value"> /// The new row value for the specified column. /// </param> public static void SetField <T>(this DataRow row, int columnIndex, T value) { DataSetUtil.CheckArgumentNull(row, "row"); row[columnIndex] = (object)value ?? DBNull.Value; }
/// <summary> /// This method sets a new value for the specified column for the DataRow it’s called on. /// </summary> /// <param name="row"> /// The input DataRow. /// </param> /// <param name="columnName"> /// The input column name specificy which row value to retrieve. /// </param> /// <param name="value"> /// The new row value for the specified column. /// </param> public static void SetField <T>(this DataRow row, string columnName, T value) { DataSetUtil.CheckArgumentNull(row, "row"); row[columnName] = (object)value ?? DBNull.Value; }
protected void btnSave_Click(object sender, EventArgs e) { string strId = lblID.Text; string strPassword = tbxPWD.Text.Trim(); string strNickName = tbxNickName.Text.Trim(); string strName = tbxName.Text.Trim(); string strTel = tbxTelNum.Text; string strPartner = tbxPartner.Text.Trim(); string currencyExPasswordText = currencyExPassword.Text.Trim(); string bankNameText = bankName.Text.Trim(); string bankAccountNumberText = bankAccountNumber.Text.Trim(); string depositHolderText = depositHolder.Text.Trim(); int nNoLogin = int.Parse(ddlNologin.SelectedValue); int nStopChat = int.Parse(ddlStopChat.SelectedValue); string strMemo = tbxMemo.Text; float fDealPercent = float.Parse(tbxDealPercent.Text); int isNew = int.Parse(ddlIsNew.Text); if (isNew == 1 && nNoLogin == 0) { isNew = 0; ddlIsNew.Text = isNew.ToString(); } if (CheckExistID(lblLoginID.Text, strId)) { cvResult.ErrorMessage = "이미 등록된 아이디입니다."; cvResult.IsValid = false; return; } if (CheckExistNickName(strNickName, strId)) { cvResult.ErrorMessage = "이미 등록된 닉네임입니다."; cvResult.IsValid = false; return; } DBManager dbManager = new DBManager(); string strQuery = ""; SqlCommand cmd = null; //딜비체크 //유저의 상위업체 딜비 얻기 strQuery = "SELECT TBL_USERLIST.parentid, TBL_Enterprise.class, TBL_Enterprise.classpercent FROM TBL_USERLIST INNER JOIN TBL_Enterprise ON TBL_USERLIST.parentid = TBL_Enterprise.id WHERE TBL_USERLIST.id=@id"; cmd = new SqlCommand(strQuery); cmd.Parameters.Add(new SqlParameter("@id", strId)); DataSet dsUser = dbManager.RunMSelectQuery(cmd); if (DataSetUtil.IsNullOrEmpty(dsUser)) { return; } else { int nClass = DataSetUtil.RowIntValue(dsUser, "class", 0); float fPer = DataSetUtil.RowFloatValue(dsUser, "classpercent", 0); if (fDealPercent > fPer) { cvResult.ErrorMessage = string.Format("딜러비를 0~{0:N1}%사이로 입력하세요.", fPer); cvResult.IsValid = false; return; } } strQuery = "UPDATE TBL_UserList SET "; strQuery += "LoginPWD=@LoginPWD, "; strQuery += "NickName=@NickName, "; strQuery += "Name=@Name, "; strQuery += "TelNum=@TelNum, "; strQuery += "Partner=@Partner, "; strQuery += "status=@NoLogin, "; strQuery += "StopChat=@StopChat, "; strQuery += "ChangeDate=@ChangeDate, "; strQuery += "Memo=@Memo,"; strQuery += "currencyExPassword=@currencyExPassword,"; strQuery += "bankName=@bankName,"; strQuery += "bankAccountNumber=@bankAccountNumber,"; strQuery += "depositHolder=@depositHolder,"; strQuery += "dealpercent=@dealpercent, "; strQuery += "is_new=@is_new "; strQuery += "WHERE ID=" + strId; cmd = new SqlCommand(strQuery); cmd.Parameters.Add(new SqlParameter("@LoginPWD", strPassword)); cmd.Parameters.Add(new SqlParameter("@NickName", strNickName)); cmd.Parameters.Add(new SqlParameter("@Name", strName)); cmd.Parameters.Add(new SqlParameter("@TelNum", strTel)); cmd.Parameters.Add(new SqlParameter("@Partner", strPartner)); cmd.Parameters.Add(new SqlParameter("@NoLogin", nNoLogin)); cmd.Parameters.Add(new SqlParameter("@StopChat", nStopChat)); cmd.Parameters.Add(new SqlParameter("@ChangeDate", DateTime.Now)); cmd.Parameters.Add(new SqlParameter("@Memo", strMemo)); cmd.Parameters.Add(new SqlParameter("@currencyExPassword", currencyExPasswordText)); cmd.Parameters.Add(new SqlParameter("@bankName", bankNameText)); cmd.Parameters.Add(new SqlParameter("@bankAccountNumber", bankAccountNumberText)); cmd.Parameters.Add(new SqlParameter("@depositHolder", depositHolderText)); cmd.Parameters.Add(new SqlParameter("@dealpercent", fDealPercent)); cmd.Parameters.Add(new SqlParameter("@is_new", isNew)); try { dbManager.RunMQuery(cmd); cvResult.ErrorMessage = "회원정보가 수정되였습니다."; } catch (Exception ex) { cvResult.ErrorMessage = "회원정보수정에서 오류가 발생하였습니다. " + ex.ToString(); } cvResult.IsValid = false; }
/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row">The input DataRow</param> /// <param name="column">The input DataColumn specificy which row value to retrieve.</param> /// <param name="version">The DataRow version for which row value to retrieve.</param> /// <returns>The DataRow value for the column specified.</returns> public static T Field <T>(this DataRow row, DataColumn column, DataRowVersion version) { DataSetUtil.CheckArgumentNull(nameof(row), "row"); return(UnboxT <T> .s_unbox(row[column, version])); }
private static DataTable LoadTableFromEnumerable <T>(IEnumerable <T> source, DataTable table, LoadOption?options, FillErrorEventHandler errorHandler) where T : DataRow { if (options.HasValue) { switch (options.Value) { case LoadOption.OverwriteChanges: case LoadOption.PreserveChanges: case LoadOption.Upsert: break; default: throw DataSetUtil.InvalidLoadOption(options.Value); } } using (IEnumerator <T> rows = source.GetEnumerator()) { // need to get first row to create table if (!rows.MoveNext()) { return(table ?? throw DataSetUtil.InvalidOperation(SR.DataSetLinq_EmptyDataRowSource)); } DataRow current; if (table == null) { current = rows.Current; if (current == null) { throw DataSetUtil.InvalidOperation(SR.DataSetLinq_NullDataRow); } table = new DataTable() { Locale = CultureInfo.CurrentCulture }; // We do not copy the same properties that DataView.ToTable does. // If user needs that functionality, use other CopyToDataTable overloads. // The reasoning being, the IEnumerator<DataRow> can be sourced from // different DataTable, so we just use the "Default" instead of resolving the difference. foreach (DataColumn column in current.Table.Columns) { table.Columns.Add(column.ColumnName, column.DataType); } } table.BeginLoadData(); try { do { current = rows.Current; if (current == null) { continue; } object[] values = null; try { // 'recoverable' error block switch (current.RowState) { case DataRowState.Detached: if (!current.HasVersion(DataRowVersion.Proposed)) { throw DataSetUtil.InvalidOperation(SR.DataSetLinq_CannotLoadDetachedRow); } goto case DataRowState.Added; case DataRowState.Unchanged: case DataRowState.Added: case DataRowState.Modified: values = current.ItemArray; if (options.HasValue) { table.LoadDataRow(values, options.Value); } else { table.LoadDataRow(values, fAcceptChanges: true); } break; case DataRowState.Deleted: throw DataSetUtil.InvalidOperation(SR.DataSetLinq_CannotLoadDeletedRow); default: throw DataSetUtil.InvalidDataRowState(current.RowState); } } catch (Exception e) { if (!DataSetUtil.IsCatchableExceptionType(e)) { throw; } FillErrorEventArgs fillError = null; if (null != errorHandler) { fillError = new FillErrorEventArgs(table, values) { Errors = e }; errorHandler.Invoke(rows, fillError); } if (null == fillError) { throw; } else if (!fillError.Continue) { if (ReferenceEquals(fillError.Errors ?? e, e)) { // if user didn't change exception to throw (or set it to null) throw; } else { // user may have changed exception to throw in handler throw fillError.Errors; } } } } while (rows.MoveNext()); } finally { table.EndLoadData(); } } Debug.Assert(null != table, "null DataTable"); return(table); }
/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row">The input DataRow</param> /// <param name="columnIndex">The input ordinal specifying which row value to retrieve.</param> /// <returns>The DataRow value for the column specified.</returns> public static T?Field <T>(this DataRow row, int columnIndex) { DataSetUtil.CheckArgumentNull(row, nameof(row)); return(UnboxT <T> .s_unbox(row[columnIndex])); }
/// <summary> /// Creates a LinqDataView from EnumerableDataTable /// </summary> /// <typeparam name="T">Type of the row in the table. Must inherit from DataRow</typeparam> /// <param name="source">The enumerable-datatable over which view must be created.</param> /// <returns>Generated LinkDataView of type T</returns> public static DataView AsDataView <T>(this EnumerableRowCollection <T> source) where T : DataRow { DataSetUtil.CheckArgumentNull <EnumerableRowCollection <T> >(source, nameof(source)); return(source.GetLinqDataView()); }
/// <summary> /// This method takes an input sequence of DataRows and produces a DataTable object /// with copies of the source rows. /// Also note that this will cause the rest of the query to execute at this point in time /// (e.g. there is no more delayed execution after this sequence operator). /// </summary> /// <param name="source">The input sequence of DataRows</param> /// <returns>DataTable containing copies of the source DataRows. Properties for the DataTable table will be taken from first DataRow in the source.</returns> /// <exception cref="ArgumentNullException">if source is null</exception> /// <exception cref="InvalidOperationException">if source is empty</exception> public static DataTable CopyToDataTable <T>(this IEnumerable <T> source) where T : DataRow { DataSetUtil.CheckArgumentNull(source, nameof(source)); return(LoadTableFromEnumerable(source, table: null, options: null, errorHandler: null)); }
/// <summary> /// Creates a LinkDataView of DataRow over the input table. /// </summary> /// <param name="table">DataTable that the view is over.</param> /// <returns>An instance of LinkDataView.</returns> public static DataView AsDataView(this DataTable table) { DataSetUtil.CheckArgumentNull <DataTable>(table, nameof(table)); return(new LinqDataView(table, null)); }
/// <summary> /// This method returns a IEnumerable of Datarows. /// </summary> /// <param name="source">The source DataTable to make enumerable.</param> /// <returns>IEnumerable of datarows.</returns> public static EnumerableRowCollection <DataRow> AsEnumerable(this DataTable source) { DataSetUtil.CheckArgumentNull(source, nameof(source)); return(new EnumerableRowCollection <DataRow>(source)); }
void BindUserInfo(DataSet dsUSer) { if (dsUSer == null) { return; } if (dsUSer.Tables.Count == 0) { return; } if (dsUSer.Tables[0].Rows.Count == 0) { return; } lnkCharge.NavigateUrl = "javascript:openNewWindow(\"usercharge.aspx\", " + dsUSer.Tables[0].Rows[0]["ID"].ToString() + ")"; lnkWithdraw.NavigateUrl = "javascript:openNewWindow(\"userwithdraw.aspx\", " + dsUSer.Tables[0].Rows[0]["ID"].ToString() + ")"; trPhone.Visible = 인증회원.Tables[0].Rows[0]["CanSeePhone"].ToString() == "1"; lblID.Text = dsUSer.Tables[0].Rows[0]["ID"].ToString(); lblRegDate.Text = ((DateTime)dsUSer.Tables[0].Rows[0]["RegDate"]).ToString("yyyy년 M월 d일 H시 m분"); lblLoginID.Text = dsUSer.Tables[0].Rows[0]["LoginID"].ToString(); tbxPWD.Text = dsUSer.Tables[0].Rows[0]["LoginPWD"].ToString(); lblTitleNickName.Text = tbxNickName.Text = dsUSer.Tables[0].Rows[0]["Nickname"].ToString(); tbxName.Text = dsUSer.Tables[0].Rows[0]["Name"].ToString(); lblGameMoney.Text = ((long)dsUSer.Tables[0].Rows[0]["GameMoney"]).ToString("C0"); lblWalletMoney.Text = ((long)dsUSer.Tables[0].Rows[0]["wallet_money"]).ToString("C0"); tbxTelNum.Text = dsUSer.Tables[0].Rows[0]["TelNum"].ToString(); tbxPartner.Text = dsUSer.Tables[0].Rows[0]["Partner"].ToString(); ddlNologin.SelectedIndex = (byte)dsUSer.Tables[0].Rows[0]["status"]; ddlStopChat.SelectedIndex = (byte)dsUSer.Tables[0].Rows[0]["StopChat"]; tbxMemo.Text = dsUSer.Tables[0].Rows[0]["Memo"].ToString(); lblDealMoney.Text = dsUSer.Tables[0].Rows[0]["dealmoney"].ToString(); tbxDealPercent.Text = dsUSer.Tables[0].Rows[0]["dealpercent"].ToString(); currencyExPassword.Text = dsUSer.Tables[0].Rows[0]["currencyExPassword"].ToString(); bankAccountNumber.Text = dsUSer.Tables[0].Rows[0]["bankAccountNumber"].ToString(); bankName.Text = dsUSer.Tables[0].Rows[0]["bankName"].ToString(); depositHolder.Text = dsUSer.Tables[0].Rows[0]["depositHolder"].ToString(); currencyExPassword.Text = dsUSer.Tables[0].Rows[0]["currencyExPassword"].ToString(); ddlIsNew.Text = dsUSer.Tables[0].Rows[0]["is_new"].ToString(); //딜비체크 //유저의 상위업체 딜비 얻기 DBManager dbManager = new DBManager(); string strQuery = "SELECT TBL_USERLIST.parentid, TBL_Enterprise.class, TBL_Enterprise.classpercent FROM TBL_USERLIST INNER JOIN TBL_Enterprise ON TBL_USERLIST.parentid = TBL_Enterprise.id WHERE TBL_USERLIST.id=@id"; SqlCommand cmd = new SqlCommand(strQuery); cmd.Parameters.Add(new SqlParameter("@id", lblID.Text)); DataSet dsUser = dbManager.RunMSelectQuery(cmd); if (DataSetUtil.IsNullOrEmpty(dsUser)) { return; } else { int nClass = DataSetUtil.RowIntValue(dsUser, "class", 0); float fPer = DataSetUtil.RowFloatValue(dsUser, "classpercent", 0); lblPartnerPer.Text = string.Format("{0:N1}% 이하", fPer); } }
/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row"> /// The input DataRow /// </param> /// <param name="columnIndex"> /// The input ordinal specificy which row value to retrieve. /// </param> /// <param name="version"> /// The DataRow version for which row value to retrieve. /// </param> /// <returns> /// The DataRow value for the column specified. /// </returns> public static T Field <T>(this DataRow row, int columnIndex, DataRowVersion version) { DataSetUtil.CheckArgumentNull(row, "row"); return(UnboxT <T> .Unbox(row[columnIndex, version])); }
private void ReadRowRad1gelementiveza() { this.Gx_mode = Mode.FromRowState(this.rowRAD1GELEMENTIVEZA.RowState); if (this.rowRAD1GELEMENTIVEZA.RowState == DataRowState.Added) { } this._Gxremove = this.rowRAD1GELEMENTIVEZA.RowState == DataRowState.Deleted; if (this._Gxremove) { this.rowRAD1GELEMENTIVEZA = (RAD1GELEMENTIVEZADataSet.RAD1GELEMENTIVEZARow)DataSetUtil.CloneOriginalDataRow(this.rowRAD1GELEMENTIVEZA); } }
/// <summary> /// This method sets a new value for the specified column for the DataRow it's called on. /// </summary> /// <param name="row">The input DataRow.</param> /// <param name="column">The input DataColumn specifying which row value to retrieve.</param> /// <param name="value">The new row value for the specified column.</param> public static void SetField <T>(this DataRow row, DataColumn column, T?value) { DataSetUtil.CheckArgumentNull(row, nameof(row)); row[column] = (object?)value ?? DBNull.Value; }
private void ReadRowPostanskibrojevi() { this.Gx_mode = Mode.FromRowState(this.rowPOSTANSKIBROJEVI.RowState); if (this.rowPOSTANSKIBROJEVI.RowState != DataRowState.Added) { this.m__NAZIVPOSTEOriginal = RuntimeHelpers.GetObjectValue(this.rowPOSTANSKIBROJEVI["NAZIVPOSTE", DataRowVersion.Original]); } else { this.m__NAZIVPOSTEOriginal = RuntimeHelpers.GetObjectValue(this.rowPOSTANSKIBROJEVI["NAZIVPOSTE"]); } this._Gxremove = this.rowPOSTANSKIBROJEVI.RowState == DataRowState.Deleted; if (this._Gxremove) { this.rowPOSTANSKIBROJEVI = (POSTANSKIBROJEVIDataSet.POSTANSKIBROJEVIRow)DataSetUtil.CloneOriginalDataRow(this.rowPOSTANSKIBROJEVI); } }
/// <summary> /// This method provides access to the values in each of the columns in a given row. /// This method makes casts unnecessary when accessing columns. /// Additionally, Field supports nullable types and maps automatically between DBNull and /// Nullable when the generic type is nullable. /// </summary> /// <param name="row">The input DataRow</param> /// <param name="columnName">The input column name specifying which row value to retrieve.</param> /// <param name="version">The DataRow version for which row value to retrieve.</param> /// <returns>The DataRow value for the column specified.</returns> public static T?Field <T>(this DataRow row, string columnName, DataRowVersion version) { DataSetUtil.CheckArgumentNull(row, nameof(row)); return(UnboxT <T> .s_unbox(row[columnName, version])); }
private static T ValueField(object value) => value == DBNull.Value ? throw DataSetUtil.InvalidCast(SR.Format(SR.DataSetLinq_NonNullableCast, typeof(T))) : (T)value;