/// <summary> /// 增加一条数据,及其子表数据 /// </summary> public int Add(Model.orders model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "orders("); strSql.Append("order_no,trade_no,user_id,user_name,payment_id,payment_fee,payment_status,payment_time,express_id,express_no,express_fee,express_status,express_time,accept_name,post_code,telphone,mobile,area,address,message,remark,payable_amount,real_amount,order_amount,point,status,add_time,confirm_time,complete_time)"); strSql.Append(" values ("); strSql.Append("@order_no,@trade_no,@user_id,@user_name,@payment_id,@payment_fee,@payment_status,@payment_time,@express_id,@express_no,@express_fee,@express_status,@express_time,@accept_name,@post_code,@telphone,@mobile,@area,@address,@message,@remark,@payable_amount,@real_amount,@order_amount,@point,@status,@add_time,@confirm_time,@complete_time)"); strSql.Append(";set @ReturnValue= @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@order_no", SqlDbType.NVarChar, 100), new SqlParameter("@trade_no", SqlDbType.NVarChar, 100), new SqlParameter("@user_id", SqlDbType.Int, 4), new SqlParameter("@user_name", SqlDbType.NVarChar, 100), new SqlParameter("@payment_id", SqlDbType.Int, 4), new SqlParameter("@payment_fee", SqlDbType.Decimal, 5), new SqlParameter("@payment_status", SqlDbType.TinyInt, 1), new SqlParameter("@payment_time", SqlDbType.DateTime), new SqlParameter("@express_id", SqlDbType.Int, 4), new SqlParameter("@express_no", SqlDbType.NVarChar, 100), new SqlParameter("@express_fee", SqlDbType.Decimal, 5), new SqlParameter("@express_status", SqlDbType.TinyInt, 1), new SqlParameter("@express_time", SqlDbType.DateTime), new SqlParameter("@accept_name", SqlDbType.NVarChar, 50), new SqlParameter("@post_code", SqlDbType.NVarChar, 20), new SqlParameter("@telphone", SqlDbType.NVarChar, 30), new SqlParameter("@mobile", SqlDbType.NVarChar, 20), new SqlParameter("@area", SqlDbType.NVarChar, 100), new SqlParameter("@address", SqlDbType.NVarChar, 500), new SqlParameter("@message", SqlDbType.NVarChar, 500), new SqlParameter("@remark", SqlDbType.NVarChar, 500), new SqlParameter("@payable_amount", SqlDbType.Decimal, 5), new SqlParameter("@real_amount", SqlDbType.Decimal, 5), new SqlParameter("@order_amount", SqlDbType.Decimal, 5), new SqlParameter("@point", SqlDbType.Int, 4), new SqlParameter("@status", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@confirm_time", SqlDbType.DateTime), new SqlParameter("@complete_time", SqlDbType.DateTime), new SqlParameter("@ReturnValue", SqlDbType.Int) }; parameters[0].Value = model.order_no; parameters[1].Value = model.trade_no; parameters[2].Value = model.user_id; parameters[3].Value = model.user_name; parameters[4].Value = model.payment_id; parameters[5].Value = model.payment_fee; parameters[6].Value = model.payment_status; parameters[7].Value = model.payment_time; parameters[8].Value = model.express_id; parameters[9].Value = model.express_no; parameters[10].Value = model.express_fee; parameters[11].Value = model.express_status; parameters[12].Value = model.express_time; parameters[13].Value = model.accept_name; parameters[14].Value = model.post_code; parameters[15].Value = model.telphone; parameters[16].Value = model.mobile; parameters[17].Value = model.area; parameters[18].Value = model.address; parameters[19].Value = model.message; parameters[20].Value = model.remark; parameters[21].Value = model.payable_amount; parameters[22].Value = model.real_amount; parameters[23].Value = model.order_amount; parameters[24].Value = model.point; parameters[25].Value = model.status; parameters[26].Value = model.add_time; parameters[27].Value = model.confirm_time; parameters[28].Value = model.complete_time; parameters[29].Direction = ParameterDirection.Output; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); //订单商品列表 if (model.order_goods != null) { StringBuilder strSql2; foreach (Model.order_goods models in model.order_goods) { strSql2 = new StringBuilder(); strSql2.Append("insert into " + databaseprefix + "order_goods("); strSql2.Append("order_id,goods_id,goods_title,goods_price,real_price,quantity,point)"); strSql2.Append(" values ("); strSql2.Append("@order_id,@goods_id,@goods_title,@goods_price,@real_price,@quantity,@point)"); SqlParameter[] parameters2 = { new SqlParameter("@order_id", SqlDbType.Int, 4), new SqlParameter("@goods_id", SqlDbType.Int, 4), new SqlParameter("@goods_title", SqlDbType.NVarChar, 100), new SqlParameter("@goods_price", SqlDbType.Decimal, 5), new SqlParameter("@real_price", SqlDbType.Decimal, 5), new SqlParameter("@quantity", SqlDbType.Int, 4), new SqlParameter("@point", SqlDbType.Int, 4) }; parameters2[0].Direction = ParameterDirection.InputOutput; parameters2[1].Value = models.goods_id; parameters2[2].Value = models.goods_title; parameters2[3].Value = models.goods_price; parameters2[4].Value = models.real_price; parameters2[5].Value = models.quantity; parameters2[6].Value = models.point; cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(cmd); } } DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist); return((int)parameters[29].Value); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.article_attribute_field model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "article_attribute_field("); strSql.Append("name,title,control_type,data_type,data_length,data_place,item_option,default_value,is_required,is_password,is_html,editor_type,valid_tip_msg,valid_error_msg,valid_pattern,sort_id,is_sys)"); strSql.Append(" values ("); strSql.Append("@name,@title,@control_type,@data_type,@data_length,@data_place,@item_option,@default_value,@is_required,@is_password,@is_html,@editor_type,@valid_tip_msg,@valid_error_msg,@valid_pattern,@sort_id,@is_sys)"); strSql.Append(";set @ReturnValue= @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@name", SqlDbType.NVarChar, 100), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@control_type", SqlDbType.NVarChar, 50), new SqlParameter("@data_type", SqlDbType.NVarChar, 50), new SqlParameter("@data_length", SqlDbType.Int, 4), new SqlParameter("@data_place", SqlDbType.TinyInt, 1), new SqlParameter("@item_option", SqlDbType.NText), new SqlParameter("@default_value", SqlDbType.NText), new SqlParameter("@is_required", SqlDbType.TinyInt, 1), new SqlParameter("@is_password", SqlDbType.TinyInt, 1), new SqlParameter("@is_html", SqlDbType.TinyInt, 1), new SqlParameter("@editor_type", SqlDbType.TinyInt, 1), new SqlParameter("@valid_tip_msg", SqlDbType.NVarChar, 255), new SqlParameter("@valid_error_msg", SqlDbType.NVarChar, 255), new SqlParameter("@valid_pattern", SqlDbType.NVarChar, 500), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@is_sys", SqlDbType.TinyInt, 1), new SqlParameter("@ReturnValue", SqlDbType.Int) }; parameters[0].Value = model.name; parameters[1].Value = model.title; parameters[2].Value = model.control_type; parameters[3].Value = model.data_type; parameters[4].Value = model.data_length; parameters[5].Value = model.data_place; parameters[6].Value = model.item_option; parameters[7].Value = model.default_value; parameters[8].Value = model.is_required; parameters[9].Value = model.is_password; parameters[10].Value = model.is_html; parameters[11].Value = model.editor_type; parameters[12].Value = model.valid_tip_msg; parameters[13].Value = model.valid_error_msg; parameters[14].Value = model.valid_pattern; parameters[15].Value = model.sort_id; parameters[16].Value = model.is_sys; parameters[17].Direction = ParameterDirection.Output; List <CommandInfo> sqllist = new List <CommandInfo>(); CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters); sqllist.Add(cmd); //增加扩展字段表中一列 StringBuilder strSql2 = new StringBuilder(); strSql2.Append("alter table " + databaseprefix + "article_attribute_value add " + model.name + " " + model.data_type); SqlParameter[] parameters2 = { }; cmd = new CommandInfo(strSql2.ToString(), parameters2); sqllist.Add(cmd); DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist); return((int)parameters[17].Value); }