public bool Insert(MySqlConnection conn, MySqlTransaction trans, BlockPricePo obj) { string text = string.Concat(new string[] { "INSERT INTO ", this.TABLE_NAME, " (", this.SQL_INSERT_COLUMNS, ") VALUES (", this.SQL_INSERT_VALUES, ")" }); MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans); this.SetKeyParams(mySqlCommand, obj); this.SetAttParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } return(result); }
public bool Delete(BlockPricePo obj) { string text = " DELETE FROM " + this.TABLE_NAME + this.SQL_WHERE_KEYS; MySqlConnection connection = DBOHelper.GetConnection(); DBOHelper.OpenConnection(connection); MySqlCommand mySqlCommand = new MySqlCommand(text, connection); this.SetKeyParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } finally { DBOHelper.CloseConnection(connection); } return(result); }
public bool Update(MySqlConnection conn, MySqlTransaction trans, BlockPricePo obj) { string text = string.Concat(new string[] { "UPDATE ", this.TABLE_NAME, " SET ", this.SQL_UPDATE_FIELD, this.SQL_WHERE_KEYS }); MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans); this.SetKeyParams(mySqlCommand, obj); this.SetAttParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } return(result); }
private void SetAttParams(MySqlCommand cmd, BlockPricePo obj) { cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.BLOCKID, 253).Value = obj.BLOCKID; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.SHOWPLANID, 253).Value = obj.SHOWPLANID; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.SINGLEPRICE, 4).Value = obj.SINGLEPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.DOUBLEPRICE, 4).Value = obj.DOUBLEPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.BOXPRICE, 4).Value = obj.BOXPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.STUDENTPRICE, 4).Value = obj.STUDENTPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.GROUPPRICE, 4).Value = obj.GROUPPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.MEMBERPRICE, 4).Value = obj.MEMBERPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.DISCOUNTPRICE, 4).Value = obj.DISCOUNTPRICE; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.CREATED, 12).Value = obj.CREATED; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.UPDATED, 12).Value = obj.UPDATED; cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.ACTIVEFLAG, 3).Value = obj.ACTIVEFLAG; }
public bool Insert(BlockPricePo obj) { MySqlConnection connection = DBOHelper.GetConnection(); DBOHelper.OpenConnection(connection); string text = string.Concat(new string[] { "INSERT INTO ", this.TABLE_NAME, " (", this.SQL_INSERT_COLUMNS, ") VALUES (", this.SQL_INSERT_VALUES, ")" }); MySqlCommand mySqlCommand = new MySqlCommand(text, connection); this.SetKeyParams(mySqlCommand, obj); this.SetAttParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } finally { DBOHelper.CloseConnection(connection); } return(result); }
public bool Delete(MySqlConnection conn, MySqlTransaction trans, BlockPricePo obj) { string text = " DELETE FROM " + this.TABLE_NAME + this.SQL_WHERE_KEYS; MySqlCommand mySqlCommand = new MySqlCommand(text, conn, trans); this.SetKeyParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } return(result); }
public static bool DeleteObj(BlockPrice bk) { BlockPriceDbo dbo = new BlockPriceDbo(); BlockPricePo po = new BlockPricePo(); po.BLOCKPRICEID = bk.BlockPriceId; po.BLOCKID = bk.BlockId; po.SHOWPLANID = bk.ShowPlanId; po.SINGLEPRICE = bk.SinglePrice; po.DOUBLEPRICE = bk.DoublePrice; po.BOXPRICE = bk.BoxPrice; po.STUDENTPRICE = bk.StudentPrice; po.GROUPPRICE = bk.GroupPrice; po.MEMBERPRICE = bk.MemberPrice; po.DISCOUNTPRICE = bk.DiscountPrice; po.CREATED = bk.Created; po.UPDATED = DateTime.Now; po.ACTIVEFLAG = bk.ActiveFlag; return(dbo.Delete(po)); }
public bool Update(BlockPricePo obj) { MySqlConnection connection = DBOHelper.GetConnection(); DBOHelper.OpenConnection(connection); string text = string.Concat(new string[] { "UPDATE ", this.TABLE_NAME, " SET ", this.SQL_UPDATE_FIELD, this.SQL_WHERE_KEYS }); MySqlCommand mySqlCommand = new MySqlCommand(text, connection); this.SetKeyParams(mySqlCommand, obj); this.SetAttParams(mySqlCommand, obj); bool result; try { result = (mySqlCommand.ExecuteNonQuery() > 0); } catch (MySqlException ex) { throw new Exception(ex.Message); } catch (Exception ex2) { throw new Exception(ex2.Message); } finally { DBOHelper.CloseConnection(connection); } return(result); }
private void SetKeyParams(MySqlCommand cmd, BlockPricePo obj) { cmd.Parameters.AddWithValue(BlockPriceDbo.CmdParam.BLOCKPRICEID, 253).Value = obj.BLOCKPRICEID; }