public System.Data.DataTable GetActiveAuthorPaintingsInDataTable(AuthorPaintings authorpaintings, string MatchWith) { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " Select paintingid,authorid From tblauthorpaintings "; switch (MatchWith.ToLower()) { case "paintingid": query += " where paintingid=" + authorpaintings.PaintingID + " and Is_Active='true' "; break; case "authorid": query += " where authorid=" + authorpaintings.AuthorID + " and Is_Active='true' "; break; } SqlDataAdapter da = new SqlDataAdapter(query, con); System.Data.DataTable tblauthorpaintings = new System.Data.DataTable(); da.Fill(tblauthorpaintings); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } return(tblauthorpaintings); }
public List <AuthorPaintings> GetAuthorPaintingsInList() { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " Select paintingid,authorid From tblauthorpaintings"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader(); List <AuthorPaintings> lstauthorpaintings = new List <AuthorPaintings>(); while (reader.Read()) { AuthorPaintings authorpaintings = new AuthorPaintings(); authorpaintings.PaintingID = Convert.ToInt32(reader["paintingid"]); authorpaintings.AuthorID = Convert.ToInt32(reader["authorid"]); lstauthorpaintings.Add(authorpaintings); } reader.Close(); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(lstauthorpaintings); }
public AuthorPaintings GetAuthorPaintingsInObjectUsingID(AuthorPaintings authorpaintings) { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " Select paintingid,authorid From tblauthorpaintings where paintingid=" + authorpaintings.PaintingID + ""; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { authorpaintings.PaintingID = Convert.ToInt32(reader["paintingid"]); authorpaintings.AuthorID = Convert.ToInt32(reader["authorid"]); } reader.Close(); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(authorpaintings); }
public bool InsertUpdate(AuthorPaintings authorpaintings) { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " select count(*) from tblAuthorPaintings where paintingid=" + authorpaintings.PaintingID + ""; SqlCommand cmd = new SqlCommand(query, con); int c = cmd.ExecuteScalar() == DBNull.Value?0:Convert.ToInt32(cmd.ExecuteScalar()); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(c == 0?this.Insert(authorpaintings):this.Update(authorpaintings)); }
public bool Insert(AuthorPaintings authorpaintings) { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " insert into tblAuthorPaintings(paintingid,authorid)values(" + authorpaintings.PaintingID + "," + authorpaintings.AuthorID + ")"; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(true); }
public bool Update(AuthorPaintings authorpaintings) { SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } string query = " update tblAuthorPaintings set authorid=" + authorpaintings.AuthorID + " where paintingid=" + authorpaintings.PaintingID + ""; SqlCommand cmd = new SqlCommand(query, con); cmd.ExecuteNonQuery(); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(true); }
public List <AuthorPaintings> GetAuthorPaintingsInList(AuthorPaintings authorpaintings, string MatchWith) { string query = " Select paintingid,authorid From tblauthorpaintings "; switch (MatchWith.ToLower()) { case "paintingid": query += " where paintingid=" + authorpaintings.PaintingID + ""; break; case "authorid": query += " where authorid=" + authorpaintings.AuthorID + ""; break; } SqlConnection con = new SqlConnection(DBHelper.GetConnectionString()); if (con.State == System.Data.ConnectionState.Closed) { con.Open(); } SqlCommand cmd = new SqlCommand(query, con); SqlDataReader reader = cmd.ExecuteReader(); List <AuthorPaintings> lstauthorpaintings = new List <AuthorPaintings>(); while (reader.Read()) { authorpaintings = new AuthorPaintings(); authorpaintings.PaintingID = Convert.ToInt32(reader["paintingid"]); authorpaintings.AuthorID = Convert.ToInt32(reader["authorid"]); lstauthorpaintings.Add(authorpaintings); } reader.Close(); if (con.State == System.Data.ConnectionState.Open) { con.Close(); } cmd.Dispose(); return(lstauthorpaintings); }
public System.Data.DataTable GetAuthorPaintingsInDataTable(AuthorPaintings authorpaintings, string MatchWith) { return(new DAL.AuthorPaintingsDAL().GetAuthorPaintingsInDataTable(authorpaintings, MatchWith)); }
///<summary> ///This Method will Get record of AuthorPaintings From your database in a Single Object of Class AuthorPaintings. ///Return Object if record Found other wise will throw an Execption of Type SQLExecption or return false in any other Problem ///Your are using Beta Version of Rapid Development (by Raees Ul Islam 0345-7294449 ///</summary> ///</param name=AuthorPaintings>This is an Object of your Class AuthorPaintings</param> public AuthorPaintings GetAuthorPaintingsInObjectUsingID(AuthorPaintings authorpaintings) { return(new DAL.AuthorPaintingsDAL().GetAuthorPaintingsInObjectUsingID(authorpaintings)); }
///<summary> ///This Method will Delete and record of AuthorPaintings in your database. ///Return true when data will Delete to your Data base other wise will throw an Execption of Type SQLExecption or return false in any other Problem ///Your are using Beta Version of Rapid Development (by Raees Ul Islam 0345-7294449 ///</summary> ///</param name=AuthorPaintings>This is an Object of your Class AuthorPaintings</param> public bool Delete(AuthorPaintings authorpaintings) { return(new DAL.AuthorPaintingsDAL().Delete(authorpaintings)); }
///<summary> ///This Method will Update and record of AuthorPaintings in your database. ///Return true when data will update to your Data base other wise will throw an Execption of Type SQLExecption or return false in any other Problem ///Your are using Beta Version of Rapid Development (by Raees Ul Islam 0345-7294449 ///</summary> ///</param name=AuthorPaintings>This is an Object of your Class AuthorPaintings</param> public bool Update(AuthorPaintings authorpaintings) { return(new DAL.AuthorPaintingsDAL().Update(authorpaintings)); }
///<summary> ///This Method will insert and record of AuthorPaintings in your database. ///Return true when data will insert to your Data base other wise will throw an Execption of Type SQLExecption or return false in any other Problem ///Your are using Beta Version of Rapid Development (by Raees Ul Islam 0345-7294449 ///</summary> ///</param name=AuthorPaintings>This is an Object of your Class AuthorPaintings</param> public bool Insert(AuthorPaintings authorpaintings) { return(new DAL.AuthorPaintingsDAL().Insert(authorpaintings)); }
public List <AuthorPaintings> GetAuthorPaintingsInList(AuthorPaintings authorpaintings, string MatchWith) { return(new DAL.AuthorPaintingsDAL().GetAuthorPaintingsInList(authorpaintings, MatchWith)); }