public static ApiResultEnum Update(Account model) { string sql = "SELECT * FROM `account` WHERE id <> @id AND (`code` = @code OR server_ip = @server_ip)"; DataTable dt = MySQLHelper.GetDataTable(sql, DAHelper.CreateParams(sql, model)); if (dt == null) { return(ApiResultEnum.Failed); } else if (dt.Rows.Count > 0) { Account account = DAHelper.GetModelByDataRow <Account>(dt.Rows[0]); if (account.code == model.code) { return(ApiResultEnum.Code_Exist); } else if (account.server_ip == model.server_ip) { return(ApiResultEnum.Account_IP_Exist); } } sql = "UPDATE account SET server_ip=@server_ip, server_port=@server_port, `code`=@code, `name`=@name, full_name=@full_name, remarks=@remarks, limit_no_buying=@limit_no_buying, ratio_commission=@ratio_commission, limit_ratio_single=@limit_ratio_single, limit_ratio_gem_single=@limit_ratio_gem_single, limit_ratio_gem_total=@limit_ratio_gem_total, ratio_capital_warning=@ratio_capital_warning, capital_initial=@capital_initial, capital_inferior=@capital_inferior, capital_priority=@capital_priority, capital_raobiao=@capital_raobiao, capital_raobiao_rate=@capital_raobiao_rate WHERE id =@id"; if (MySQLHelper.ExecuteNonQuery(sql, DAHelper.CreateParams(sql, model)) > 0) { LogActionDA.Add(model.created_by, string.Format("修改主账户{0}({1})", model.id, model.code)); return(ApiResultEnum.Success); } return(ApiResultEnum.Failed); }
public static ApiResultEnum Delete(Unit model, int _operator) { string sql = "DELETE FROM unit WHERE id=@id"; if (MySQLHelper.ExecuteNonQuery(sql, DAHelper.CreateParams(sql, model)) > 0) { LogActionDA.Add(_operator, string.Format("删除单元{0}({1})", model.id, model.code)); return(ApiResultEnum.Success); } return(ApiResultEnum.Failed); }
public static ApiResultEnum Delete(AccountGroup model) { string sql = "DELETE FROM account_group WHERE id=@id; DELETE FROM account_group_item WHERE account_group_id=@id"; if (MySQLHelper.ExecuteNonQuery(sql, DAHelper.CreateParams(sql, model)) > 0) { LogActionDA.Add(model.created_by, string.Format("删除主账户池{0}({1})", model.id, model.code)); return(ApiResultEnum.Success); } return(ApiResultEnum.Failed); }
public static ApiResultEnum Delete(User model) { string sql = "DELETE FROM `user` WHERE id=@id"; if (MySQLHelper.ExecuteNonQuery(sql, DAHelper.CreateParams(sql, model)) > 0) { LogActionDA.Add(model.created_by, string.Format("删除用户{0}({1})", model.id, model.code)); return(ApiResultEnum.Success); } return(ApiResultEnum.Failed); }
public static ApiResultEnum Add(Unit model, ref int id) { string sql = "SELECT `code` FROM unit WHERE `code` = @code"; object obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { return(ApiResultEnum.Code_Exist); } sql = "INSERT INTO unit(code,name,area,broker,risk_controller,account_group_id,lever,ratio_management_fee,ratio_commission,ratio_software_fee,limit_stock_count,limit_ratio_mbm_single,limit_ratio_gem_single,limit_ratio_gem_total,limit_ratio_sme_single,limit_ratio_sme_total,limit_ratio_smg_total,limit_ratio_star_single,limit_ratio_star_total,ratio_warning,ratio_close_position,limit_no_buying,limit_order_price,created_by) VALUES(@code,@name,@area,@broker,@risk_controller,@account_group_id,@lever,@ratio_management_fee,@ratio_commission,@ratio_software_fee,@limit_stock_count,@limit_ratio_mbm_single,@limit_ratio_gem_single,@limit_ratio_gem_total,@limit_ratio_sme_single,@limit_ratio_sme_total,@limit_ratio_smg_total,@limit_ratio_star_single,@limit_ratio_star_total,@ratio_warning,@ratio_close_position,@limit_no_buying,@limit_order_price,@created_by); SELECT LAST_INSERT_ID()"; obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { id = int.Parse(obj.ToString()); LogActionDA.Add(model.created_by, string.Format("创建单元{0}({1})", id, model.code)); return(ApiResultEnum.Success); } else { return(ApiResultEnum.Failed); } }
public static ApiResultEnum Add(AccountGroup model, ref int id) { string sql = "SELECT `code` FROM account_group WHERE `code` = @code"; object obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { return(ApiResultEnum.Code_Exist); } sql = "INSERT INTO account_group(`code`, `name`, created_by) VALUES(@code, @name, @created_by); SELECT LAST_INSERT_ID()"; obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { id = int.Parse(obj.ToString()); LogActionDA.Add(model.created_by, string.Format("创建主账户池{0}({1})", id, model.code)); return(ApiResultEnum.Success); } else { return(ApiResultEnum.Failed); } }
public static ApiResultEnum Add(User model, ref int id) { string sql = "SELECT * FROM `user` WHERE `code` = @code OR mobile = @mobile"; DataTable dt = MySQLHelper.GetDataTable(sql, DAHelper.CreateParams(sql, model)); if (dt == null) { return(ApiResultEnum.Failed); } else if (dt.Rows.Count > 0) { User user = DAHelper.GetModelByDataRow <User>(dt.Rows[0]); if (user.code == model.code) { return(ApiResultEnum.Code_Exist); } else if (user.mobile == model.mobile) { return(ApiResultEnum.User_Mobile_Exist); } } sql = "INSERT INTO `user`(`code`,`name`,mobile,`password`,created_by) VALUES(@code,@name,@mobile,@password,@created_by); SELECT LAST_INSERT_ID()"; object obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { id = int.Parse(obj.ToString()); LogActionDA.Add(model.created_by, string.Format("创建用户{0}({1})", id, model.code)); return(ApiResultEnum.Success); } else { return(ApiResultEnum.Failed); } }
public static ApiResultEnum Add(Account model, ref int id) { string sql = "SELECT * FROM `account` WHERE `code` = @code OR `server_ip` = @server_ip"; DataTable dt = MySQLHelper.GetDataTable(sql, DAHelper.CreateParams(sql, model)); if (dt == null) { return(ApiResultEnum.Failed); } else if (dt.Rows.Count > 0) { Account account = DAHelper.GetModelByDataRow <Account>(dt.Rows[0]); if (account.code == model.code) { return(ApiResultEnum.Code_Exist); } else if (account.server_ip == model.server_ip) { return(ApiResultEnum.Account_IP_Exist); } } sql = "INSERT INTO account(server_ip, server_port, `code`, `name`, full_name, remarks, limit_no_buying, ratio_commission, limit_ratio_single, limit_ratio_gem_single, limit_ratio_gem_total, ratio_capital_warning, capital_initial, capital_inferior, capital_priority, capital_raobiao, capital_raobiao_rate, created_by) VALUES(@server_ip, @server_port, @code, @name, @full_name, @remarks, @limit_no_buying, @ratio_commission, @limit_ratio_single, @limit_ratio_gem_single, @limit_ratio_gem_total, @ratio_capital_warning, @capital_initial, @capital_inferior, @capital_priority, @capital_raobiao, @capital_raobiao_rate, @created_by); SELECT LAST_INSERT_ID()"; object obj = MySQLHelper.ExecuteScalar(sql, DAHelper.CreateParams(sql, model)); if (obj != null) { id = int.Parse(obj.ToString()); LogActionDA.Add(model.created_by, string.Format("创建主账户{0}({1})", id, model.code)); return(ApiResultEnum.Success); } else { return(ApiResultEnum.Failed); } }