public DealerCustomerBLL GetDeaCustIFromName(string name) { DealerCustomerBLL dc = new DealerCustomerBLL(); SqlConnection con = new SqlConnection(this.connect.connection); DataTable dt = new DataTable(); try { string sql = "SELECT [id]" + ",[type]" + ",[name]" + ",[email]" + ",[contact]" + ",[address]" + ",[addeddate]" + ",[addedby]" + "FROM[dbo].[tbldeacust]" + "WHERE name " + name; } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(dc); }
public bool Delete(DealerCustomerBLL bd) { SqlConnection con = new SqlConnection(this.connect.connection); bool isSuccess = false; try { string sql = "DELETE FROM tbldeacust WHERE id=@id"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@id", bd.ID); con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(isSuccess); }
public bool Insert(DealerCustomerBLL bi) { bool isSuccess = false; SqlConnection con = new SqlConnection(this.connect.connection); try { string sql = "INSERT INTO [dbo].[tbldeacust]" + "([type]" + ",[name]" + ",[email]" + ",[contact]" + ",[address]" + ",[addeddate]" + ",[addedby])" + "VALUES" + "(@type," + "@name," + "@email," + "@contact," + "@address," + "@addeddate," + "@addedby)"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@type", bi.Type); cmd.Parameters.AddWithValue("@name", bi.Name); cmd.Parameters.AddWithValue("@email", bi.Email); cmd.Parameters.AddWithValue("@contact", bi.Contact); cmd.Parameters.AddWithValue("@address", bi.Address); cmd.Parameters.AddWithValue("@addeddate", bi.AddedDate); cmd.Parameters.AddWithValue("@addedby", bi.AddedBy); con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(isSuccess); }
public bool Update(DealerCustomerBLL bu) { SqlConnection con = new SqlConnection(this.connect.connection); bool isSuccess = false; try { string sql = "UPDATE [dbo].[tbldeacust]" + "SET[type] = @type," + "[name] = @name," + "[email] = @email," + "[contact] = @contact," + "[address] = @address," + "[addeddate] = @addeddate," + "[addedby] = @addedby," + "WHERE id = @id"; SqlCommand cmd = new SqlCommand(sql, con); cmd.Parameters.AddWithValue("@type", bu.Type); cmd.Parameters.AddWithValue("@name", bu.Name); cmd.Parameters.AddWithValue("@email", bu.Email); cmd.Parameters.AddWithValue("@contact", bu.Contact); cmd.Parameters.AddWithValue("@address", bu.Address); cmd.Parameters.AddWithValue("@addeddate", bu.AddedDate); cmd.Parameters.AddWithValue("@addedby", bu.AddedBy); con.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(isSuccess); }
public bool Update(DealerCustomerBLL dc) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { String sql = "UPDATE table_dealer_customer SET type=@type, name=@name, email=@email, contact=@contact, address=@address, added_date=@added_date, added_by=@added_by WHERE id = @id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@type", dc.type); cmd.Parameters.AddWithValue("@name", dc.name); cmd.Parameters.AddWithValue("@email", dc.email); cmd.Parameters.AddWithValue("@contact", dc.contact); cmd.Parameters.AddWithValue("@address", dc.address); cmd.Parameters.AddWithValue("@added_date", dc.added_date); cmd.Parameters.AddWithValue("@added_by", dc.added_by); cmd.Parameters.AddWithValue("@id", dc.id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
public bool Insert(DealerCustomerBLL dc) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { String sql = "INSERT INTO table_dealer_customer (type, name, email, contact, address, added_date, added_by) VALUES (@type, @name, @email, @contact, @address, @added_date, @added_by)"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@type", dc.type); cmd.Parameters.AddWithValue("@name", dc.name); cmd.Parameters.AddWithValue("@email", dc.email); cmd.Parameters.AddWithValue("@contact", dc.contact); cmd.Parameters.AddWithValue("@address", dc.address); cmd.Parameters.AddWithValue("@added_date", dc.added_date); cmd.Parameters.AddWithValue("@added_by", dc.added_by); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }
public DealerCustomerBLL SearchDealerCustomerForTransaction(string keywords) { DealerCustomerBLL dc = new DealerCustomerBLL(); SqlConnection con = new SqlConnection(this.connect.connection); DataTable dt = new DataTable(); try { string sql = "SELECT [id]" + ",[type]" + ",[name]" + ",[email]" + ",[contact]" + ",[address]" + ",[addeddate]" + ",[addedby]" + "FROM[dbo].[tbldeacust]" + "WHERE id LIKE '%" + keywords + "%' OR name LIKE '%" + keywords + "%'"; SqlDataAdapter da = new SqlDataAdapter(sql, con); con.Open(); da.Fill(dt); if (dt.Rows.Count > 0) { dc.Name = dt.Rows[0]["name"].ToString(); dc.Email = dt.Rows[0]["email"].ToString(); dc.Contact = dt.Rows[0]["contact"].ToString(); dc.Address = dt.Rows[0]["address"].ToString(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { con.Close(); } return(dc); }
public bool Delete(DealerCustomerBLL dc) { bool isSuccess = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "DELETE FROM table_dealer_customer WHERE id = @id"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@id", dc.id); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSuccess = true; } else { isSuccess = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSuccess); }