/// <summary> /// Adds a new record into the <c>tblUsers</c> table. /// </summary> /// <param name="value">The <see cref="tblUsersRow"/> object to be inserted.</param> public virtual void Insert(tblUsersRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblUsers_Insert", true); AddParameter(cmd, "UserName", value.UserName); AddParameter(cmd, "FullName", value.FullName); AddParameter(cmd, "Password", value.Password); AddParameter(cmd, "Email", value.Email); AddParameter(cmd, "Role_Id", value.Role_Id); AddParameter(cmd, "IsDeleted", value.IsDeleted); AddParameter(cmd, "Created_By", value.Created_By); AddParameter(cmd, "Created_Time", value.Created_Time); AddParameter(cmd, "Updated_By", value.Updated_By); AddParameter(cmd, "Updated_Time", value.Updated_Time); value.User_Id = Convert.ToInt32(cmd.ExecuteScalar()); }
/// <summary> /// Updates a record in the <c>tblUsers</c> table. /// </summary> /// <param name="value">The <see cref="tblUsersRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(tblUsersRow value) { IDbCommand cmd = _db.CreateCommand("dbo._tblUsers_Update", true); AddParameter(cmd, "UserName", value.UserName); AddParameter(cmd, "FullName", value.FullName); AddParameter(cmd, "Password", value.Password); AddParameter(cmd, "Email", value.Email); AddParameter(cmd, "Role_Id", value.Role_Id); AddParameter(cmd, "IsDeleted", value.IsDeleted); AddParameter(cmd, "Created_By", value.Created_By); AddParameter(cmd, "Created_Time", value.Created_Time); AddParameter(cmd, "Updated_By", value.Updated_By); AddParameter(cmd, "Updated_Time", value.Updated_Time); AddParameter(cmd, "User_Id", value.User_Id); return(0 != cmd.ExecuteNonQuery()); }
// SqlConnectionStringBuilder csb; //string stDatabaseUser, stDatabasePass; //public string DatabasePassword //{ // get { return stDatabasePass; } // //set { stDatabasePass = value; } //} //public string DatabaseUserName //{ // get { return stDatabaseUser; } // //set { stDatabaseUser = value; } //} #endregion #region "User Details" public static tblUsersRow GetUserDetails(int UserID) { FMSDB db = new FMSDB(); try { tblUsersRow objUserRow = new tblUsersRow(); string strCondition; strCondition = ""; strCondition = "tblUsers.User_Id =" + UserID; DataTable dtUsers = db.tblUsersCollection.GetAsDataTable(strCondition, "User_Id"); //System.Data.DataTable dt1 = db.tblUserCollection.GetAsDataTable(strCondition, "User_ID"); if (dtUsers.Rows.Count > 0) { //System.Data.DataRow dr = dt1.Rows[0]; objUserRow.User_Id = Convert.ToInt16(dtUsers.Rows[0]["User_Id"]); objUserRow.UserName = Convert.ToString(dtUsers.Rows[0]["UserName"]); objUserRow.FullName = Convert.ToString(dtUsers.Rows[0]["FullName"]); objUserRow.Password = Convert.ToString(dtUsers.Rows[0]["Password"]); objUserRow.Email = Convert.ToString(dtUsers.Rows[0]["Email"]); objUserRow.Role_Id = Convert.ToInt32(dtUsers.Rows[0]["Role_Id"]); objUserRow.IsDeleted = Convert.ToBoolean(dtUsers.Rows[0]["IsDeleted"]); //objUserRow.CreationDt = Convert.ToDateTime(dt1.Rows[0]["CreationDt"]); //objUserRow.LastModifiedDt = Convert.ToDateTime(dt1.Rows[0]["LastModifiedDt"]); return(objUserRow); } else { return(null); } } finally { db.Dispose(); } }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="tblUsersRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="tblUsersRow"/> object.</returns> protected virtual tblUsersRow MapRow(DataRow row) { tblUsersRow mappedObject = new tblUsersRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "User_Id" dataColumn = dataTable.Columns["User_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.User_Id = (int)row[dataColumn]; } // Column "UserName" dataColumn = dataTable.Columns["UserName"]; if (!row.IsNull(dataColumn)) { mappedObject.UserName = (string)row[dataColumn]; } // Column "FullName" dataColumn = dataTable.Columns["FullName"]; if (!row.IsNull(dataColumn)) { mappedObject.FullName = (string)row[dataColumn]; } // Column "Password" dataColumn = dataTable.Columns["Password"]; if (!row.IsNull(dataColumn)) { mappedObject.Password = (string)row[dataColumn]; } // Column "Email" dataColumn = dataTable.Columns["Email"]; if (!row.IsNull(dataColumn)) { mappedObject.Email = (string)row[dataColumn]; } // Column "Role_Id" dataColumn = dataTable.Columns["Role_Id"]; if (!row.IsNull(dataColumn)) { mappedObject.Role_Id = (int)row[dataColumn]; } // Column "IsDeleted" dataColumn = dataTable.Columns["IsDeleted"]; if (!row.IsNull(dataColumn)) { mappedObject.IsDeleted = (bool)row[dataColumn]; } // Column "Created_By" dataColumn = dataTable.Columns["Created_By"]; if (!row.IsNull(dataColumn)) { mappedObject.Created_By = (int)row[dataColumn]; } // Column "Created_Time" dataColumn = dataTable.Columns["Created_Time"]; if (!row.IsNull(dataColumn)) { mappedObject.Created_Time = (System.DateTime)row[dataColumn]; } // Column "Updated_By" dataColumn = dataTable.Columns["Updated_By"]; if (!row.IsNull(dataColumn)) { mappedObject.Updated_By = (int)row[dataColumn]; } // Column "Updated_Time" dataColumn = dataTable.Columns["Updated_Time"]; if (!row.IsNull(dataColumn)) { mappedObject.Updated_Time = (System.DateTime)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="tblUsersRow"/> objects.</returns> protected virtual tblUsersRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int user_IdColumnIndex = reader.GetOrdinal("User_Id"); int userNameColumnIndex = reader.GetOrdinal("UserName"); int fullNameColumnIndex = reader.GetOrdinal("FullName"); int passwordColumnIndex = reader.GetOrdinal("Password"); int emailColumnIndex = reader.GetOrdinal("Email"); int role_IdColumnIndex = reader.GetOrdinal("Role_Id"); int isDeletedColumnIndex = reader.GetOrdinal("IsDeleted"); int created_ByColumnIndex = reader.GetOrdinal("Created_By"); int created_TimeColumnIndex = reader.GetOrdinal("Created_Time"); int updated_ByColumnIndex = reader.GetOrdinal("Updated_By"); int updated_TimeColumnIndex = reader.GetOrdinal("Updated_Time"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { tblUsersRow record = new tblUsersRow(); recordList.Add(record); record.User_Id = Convert.ToInt32(reader.GetValue(user_IdColumnIndex)); record.UserName = Convert.ToString(reader.GetValue(userNameColumnIndex)); if (!reader.IsDBNull(fullNameColumnIndex)) { record.FullName = Convert.ToString(reader.GetValue(fullNameColumnIndex)); } record.Password = Convert.ToString(reader.GetValue(passwordColumnIndex)); if (!reader.IsDBNull(emailColumnIndex)) { record.Email = Convert.ToString(reader.GetValue(emailColumnIndex)); } record.Role_Id = Convert.ToInt32(reader.GetValue(role_IdColumnIndex)); record.IsDeleted = Convert.ToBoolean(reader.GetValue(isDeletedColumnIndex)); record.Created_By = Convert.ToInt32(reader.GetValue(created_ByColumnIndex)); record.Created_Time = Convert.ToDateTime(reader.GetValue(created_TimeColumnIndex)); record.Updated_By = Convert.ToInt32(reader.GetValue(updated_ByColumnIndex)); record.Updated_Time = Convert.ToDateTime(reader.GetValue(updated_TimeColumnIndex)); if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((tblUsersRow[])(recordList.ToArray(typeof(tblUsersRow)))); }
/// <summary> /// Deletes the specified object from the <c>tblUsers</c> table. /// </summary> /// <param name="value">The <see cref="tblUsersRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(tblUsersRow value) { return(DeleteByPrimaryKey(value.User_Id)); }