public int RowCount(PropertyDescriptionCodeDTO propertyDescriptionCodeDTO) { int i = 0; string sql = "Select count(ID) CT from [dbo].[r_Property_Desc_Code] Where 1=1 "; // if property description code is not null then filter with it too. if (!ValidationUtility.IsNull(propertyDescriptionCodeDTO.PropertyDescCodeDescription)) { sql = String.Format(sql + " AND Property_Description_Code_Description = '{0}'", propertyDescriptionCodeDTO.PropertyDescCodeDescription); } if (!ValidationUtility.IsNull(propertyDescriptionCodeDTO.PropertyDescCode)) { sql = String.Format(sql + " AND Property_Description_Code = '{0}'", propertyDescriptionCodeDTO.PropertyDescCode); } if (propertyDescriptionCodeDTO.LoanProgram > 0) { sql = String.Format(sql + " AND Loan_Program = '{0}'", propertyDescriptionCodeDTO.LoanProgram); } using (SqlConnection con = OpenConnection()) { using (SqlDataReader dataReader = ExecuteQuery(sql, con)) { while (dataReader.Read()) { i = ValidationUtility.ToInteger(dataReader["CT"].ToString()); } } } return(i); }
/** * It converts the DataReader object to PropertyDescriptionCodeDTO and returns PropertyDescCode details * @propertyDescCode - DTO of PropertyDescCode * @dataReader - Contains SQL query result * @return PropertyDescriptionCodeDTO - PropertyDescCode details */ private PropertyDescriptionCodeDTO MakeDTO(PropertyDescriptionCodeDTO propertyDescCode, SqlDataReader dataReader) { propertyDescCode = new PropertyDescriptionCodeDTO(); propertyDescCode.ID = ValidationUtility.ToInteger(dataReader["ID"].ToString()); propertyDescCode.PropertyDescCode = ValidationUtility.ToString(dataReader["Property_Description_Code"].ToString()); propertyDescCode.PropertyDescCodeDescription = ValidationUtility.ToString(dataReader["Property_Description_Code_Description"].ToString()); propertyDescCode.CreateDate = ValidationUtility.ToDateTime(dataReader["Create_Date"].ToString()); propertyDescCode.CreateUserID = ValidationUtility.ToString(dataReader["Create_User_ID"].ToString()); propertyDescCode.LastUpdateDate = ValidationUtility.ToDateTime(dataReader["Last_Update_Date"].ToString()); propertyDescCode.LastUpdateUserID = ValidationUtility.ToString(dataReader["Last_Update_User_ID"].ToString()); propertyDescCode.LoanProgram = ValidationUtility.ToInteger(dataReader["Loan_Program"].ToString()); return(propertyDescCode); }
public PropertyDescriptionCodeDTO Add(PropertyDescriptionCodeDTO propertyDescriptionCodeDTO) { PropertyDescriptionCodeDTO propertyDescCode = new PropertyDescriptionCodeDTO(); propertyDescCode.LastUpdateDate = DateTime.Now; propertyDescCode.CreateDate = DateTime.Now; string sql = "INSERT INTO [dbo].[r_Property_Desc_Code] (" + "Property_Description_Code," + "Property_Description_Code_Description," + "Loan_Program," + "Create_Date," + "Create_User_ID," + "Last_Update_Date," + "Last_Update_User_ID" + ") Output Inserted.ID " + "VALUES(" + "{0}," + "{1}," + "{2}," + "{3}," + "{4}," + "{5}," + "{6}" + ")"; sql = String.Format(sql, SQLUtility.getString(propertyDescriptionCodeDTO.PropertyDescCode), SQLUtility.getString(propertyDescriptionCodeDTO.PropertyDescCodeDescription), SQLUtility.getInteger(propertyDescriptionCodeDTO.LoanProgram), SQLUtility.getDateTime(propertyDescriptionCodeDTO.CreateDate), SQLUtility.getString(propertyDescriptionCodeDTO.CreateUserID), SQLUtility.getDateTime(propertyDescriptionCodeDTO.LastUpdateDate), SQLUtility.getString(propertyDescriptionCodeDTO.CreateUserID) ); using (SqlConnection con = OpenConnection()) { using (SqlDataReader dataReader = ExecuteQuery(sql, con)) { while (dataReader.Read()) { propertyDescCode.ID = ValidationUtility.ToInteger(dataReader["ID"].ToString()); } } } return(propertyDescCode); }
public Dictionary <int, string> DropDownList() { Dictionary <int, string> list = new Dictionary <int, string>(); string sql = "Select ID, Property_Description_Code_Description from [dbo].[r_Property_Desc_Code]"; using (SqlConnection con = OpenConnection()) { using (SqlDataReader dataReader = ExecuteQuery(sql, con)) { while (dataReader.Read()) { list.Add(ValidationUtility.ToInteger(dataReader["ID"].ToString()), dataReader["Property_Description_Code_Description"].ToString()); } } } return(list); }