Beispiel #1
0
        /// <summary>
        /// ɾ��һ������
        /// </summary>
        public bool Delete(int id)
        {
            List<CommandInfo> sqllist = new List<CommandInfo>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from dt_attribute_value ");
            strSql.Append(" where attribute_id=@attribute_id");
            SqlParameter[] parameters = {
                    new SqlParameter("@attribute_id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("delete from dt_attributes ");
            strSql2.Append(" where id=@id");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters2[0].Value = id;

            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #2
0
        /// <summary>
        /// ����һ������,�����ӱ�����
        /// </summary>
        public int Add(Model.sys_model model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_sys_model(");
            strSql.Append("title,sort_id,inherit_index,inherit_list,inherit_detail,is_sys)");
            strSql.Append(" values (");
            strSql.Append("@title,@sort_id,@inherit_index,@inherit_list,@inherit_detail,@is_sys)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@inherit_index", SqlDbType.NVarChar,255),
                    new SqlParameter("@inherit_list", SqlDbType.NVarChar,255),
                    new SqlParameter("@inherit_detail", SqlDbType.NVarChar,255),
                    new SqlParameter("@is_sys", SqlDbType.TinyInt,1),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.title;
            parameters[1].Value = model.sort_id;
            parameters[2].Value = model.inherit_index;
            parameters[3].Value = model.inherit_list;
            parameters[4].Value = model.inherit_detail;
            parameters[5].Value = model.is_sys;
            parameters[6].Direction = ParameterDirection.Output;
            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //ģ�Ͳ˵�
            if (model.sys_model_navs != null)
            {
                StringBuilder strSql2;
                foreach (Model.sys_model_nav models in model.sys_model_navs)
                {
                    strSql2 = new StringBuilder();
                    strSql2.Append("insert into dt_sys_model_nav(");
                    strSql2.Append("model_id,title,nav_url,sort_id)");
                    strSql2.Append(" values (");
                    strSql2.Append("@model_id,@title,@nav_url,@sort_id)");
                    SqlParameter[] parameters2 = {
                        new SqlParameter("@model_id", SqlDbType.Int,4),
                        new SqlParameter("@title", SqlDbType.NVarChar,100),
                        new SqlParameter("@nav_url", SqlDbType.NVarChar,255),
                        new SqlParameter("@sort_id", SqlDbType.Int,4)};
                    parameters2[0].Direction = ParameterDirection.InputOutput;
                    parameters2[1].Value = models.title;
                    parameters2[2].Value = models.nav_url;
                    parameters2[3].Value = models.sort_id;

                    cmd = new CommandInfo(strSql2.ToString(), parameters2);
                    sqllist.Add(cmd);
                }
            }
            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[6].Value;
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.amount_log model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_amount_log(");
            strSql.Append("user_id,user_name,type,order_no,payment_id,value,remark,status,add_time,complete_time)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@type,@order_no,@payment_id,@value,@remark,@status,@add_time,@complete_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@user_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@type", SqlDbType.NVarChar,50),
                    new SqlParameter("@order_no", SqlDbType.NVarChar,100),
                    new SqlParameter("@payment_id", SqlDbType.Int,4),
                    new SqlParameter("@value", SqlDbType.Decimal,5),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    new SqlParameter("@status", SqlDbType.TinyInt,1),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@complete_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.order_no;
            parameters[4].Value = model.payment_id;
            parameters[5].Value = model.value;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.status;
            parameters[8].Value = model.add_time;
            parameters[9].Value = model.complete_time;
            parameters[10].Direction = ParameterDirection.Output;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            if (model.status > 0)
            {
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("update dt_users set amount=amount+" + model.value);
                strSql2.Append(" where id=@id");
                SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = model.user_id;
                cmd = new CommandInfo(strSql2.ToString(), parameters2);
                sqllist.Add(cmd);
            }

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[10].Value;
        }
Beispiel #4
0
        /// <summary>
        /// ����һ������,�����ӱ�����
        /// </summary>
        public int Add(Model.manager_role model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_manager_role(");
            strSql.Append("role_name,role_type)");
            strSql.Append(" values (");
            strSql.Append("@role_name,@role_type)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@role_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@role_type", SqlDbType.TinyInt,1),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.role_name;
            parameters[1].Value = model.role_type;
            parameters[2].Direction = ParameterDirection.Output;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);
            StringBuilder strSql2;
            foreach (Model.manager_role_value models in model.manager_role_values)
            {
                strSql2 = new StringBuilder();
                strSql2.Append("insert into dt_manager_role_value(");
                strSql2.Append("role_id,channel_name,channel_id,action_type)");
                strSql2.Append(" values (");
                strSql2.Append("@role_id,@channel_name,@channel_id,@action_type)");
                SqlParameter[] parameters2 = {
                        new SqlParameter("@role_id", SqlDbType.Int,4),
                        new SqlParameter("@channel_name", SqlDbType.NVarChar,255),
                        new SqlParameter("@channel_id", SqlDbType.Int,4),
                        new SqlParameter("@action_type", SqlDbType.NVarChar,100)};
                parameters2[0].Direction = ParameterDirection.InputOutput;
                parameters2[1].Value = models.channel_name;
                parameters2[2].Value = models.channel_id;
                parameters2[3].Value = models.action_type;

                cmd = new CommandInfo(strSql2.ToString(), parameters2);
                sqllist.Add(cmd);
            }
            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[2].Value;
        }
Beispiel #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.point_log model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_point_log(");
            strSql.Append("user_id,user_name,value,remark,add_time)");
            strSql.Append(" values (");
            strSql.Append("@user_id,@user_name,@value,@remark,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@user_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@value", SqlDbType.Int,4),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.value;
            parameters[3].Value = model.remark;
            parameters[4].Value = model.add_time;
            parameters[5].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("update dt_users set point=point+" + model.value);
            if (model.value > 0)
            {
                strSql2.Append(",exp=exp+" + model.value);
            }
            strSql2.Append(" where id=@id");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters2[0].Value = model.user_id;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[5].Value;
        }
Beispiel #6
0
        /// <summary>
        /// ����һ������,�����ӱ�����
        /// </summary>
        public int Add(Model.orders model)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("insert into dt_orders(");
            strSql.Append("order_no,user_id,user_name,payment_id,distribution_id,status,payment_status,distribution_status,delivery_name,delivery_no,accept_name,post_code,telphone,mobile,address,message,payable_amount,real_amount,payable_freight,real_freight,payment_fee,order_amount,point,add_time,payment_time,confirm_time,distribution_time,complete_time)");
            strSql.Append(" values (");
            strSql.Append("@order_no,@user_id,@user_name,@payment_id,@distribution_id,@status,@payment_status,@distribution_status,@delivery_name,@delivery_no,@accept_name,@post_code,@telphone,@mobile,@address,@message,@payable_amount,@real_amount,@payable_freight,@real_freight,@payment_fee,@order_amount,@point,@add_time,@payment_time,@confirm_time,@distribution_time,@complete_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@order_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("@distribution_id", SqlDbType.Int,4),
                    new SqlParameter("@status", SqlDbType.TinyInt,1),
                    new SqlParameter("@payment_status", SqlDbType.TinyInt,1),
                    new SqlParameter("@distribution_status", SqlDbType.TinyInt,1),
                    new SqlParameter("@delivery_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@delivery_no", SqlDbType.NVarChar,100),
                    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,30),
                    new SqlParameter("@address", SqlDbType.NVarChar,255),
                    new SqlParameter("@message", SqlDbType.NVarChar,500),
                    new SqlParameter("@payable_amount", SqlDbType.Decimal,5),
                    new SqlParameter("@real_amount", SqlDbType.Decimal,5),
                    new SqlParameter("@payable_freight", SqlDbType.Decimal,5),
                    new SqlParameter("@real_freight", SqlDbType.Decimal,5),
                    new SqlParameter("@payment_fee", SqlDbType.Decimal,5),
                    new SqlParameter("@order_amount", SqlDbType.Decimal,5),
                    new SqlParameter("@point", SqlDbType.Int,4),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@payment_time", SqlDbType.DateTime),
                    new SqlParameter("@confirm_time", SqlDbType.DateTime),
                    new SqlParameter("@distribution_time", SqlDbType.DateTime),
                    new SqlParameter("@complete_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.order_no;
            parameters[1].Value = model.user_id;
            parameters[2].Value = model.user_name;
            parameters[3].Value = model.payment_id;
            parameters[4].Value = model.distribution_id;
            parameters[5].Value = model.status;
            parameters[6].Value = model.payment_status;
            parameters[7].Value = model.distribution_status;
            parameters[8].Value = model.delivery_name;
            parameters[9].Value = model.delivery_no;
            parameters[10].Value = model.accept_name;
            parameters[11].Value = model.post_code;
            parameters[12].Value = model.telphone;
            parameters[13].Value = model.mobile;
            parameters[14].Value = model.address;
            parameters[15].Value = model.message;
            parameters[16].Value = model.payable_amount;
            parameters[17].Value = model.real_amount;
            parameters[18].Value = model.payable_freight;
            parameters[19].Value = model.real_freight;
            parameters[20].Value = model.payment_fee;
            parameters[21].Value = model.order_amount;
            parameters[22].Value = model.point;
            parameters[23].Value = model.add_time;
            parameters[24].Value = model.payment_time;
            parameters[25].Value = model.confirm_time;
            parameters[26].Value = model.distribution_time;
            parameters[27].Value = model.complete_time;
            parameters[28].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 dt_order_goods(");
                    strSql2.Append("order_id,goods_id,goods_name,goods_price,real_price,quantity,point)");
                    strSql2.Append(" values (");
                    strSql2.Append("@order_id,@goods_id,@goods_name,@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_name", 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_name;
                    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[28].Value;
        }
Beispiel #7
0
        /// <summary>
        /// ɾ��һ�����ݣ����ӱ������������
        /// </summary>
        public bool Delete(int id)
        {
            //ȡ�����MODEL
            List<Model.article_albums> albumsList = new article_albums().GetList(id);
            //ȡ�ø���MODEL
            List<Model.download_attach> attachList = new download_attach().GetList(id);

            List<CommandInfo> sqllist = new List<CommandInfo>();
            //ɾ������ģ������
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from dt_article_news ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //ɾ������ģ������
            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("delete from dt_article_download ");
            strSql2.Append(" where id=@id ");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters2[0].Value = id;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //ɾ����Ʒģ������
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("delete from dt_article_goods ");
            strSql3.Append(" where id=@id ");
            SqlParameter[] parameters3 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters3[0].Value = id;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //ɾ������ģ������
            StringBuilder strSql4 = new StringBuilder();
            strSql4.Append("delete from dt_article_content ");
            strSql4.Append(" where id=@id ");
            SqlParameter[] parameters4 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters4[0].Value = id;
            cmd = new CommandInfo(strSql4.ToString(), parameters4);
            sqllist.Add(cmd);

            //ɾ�����Ͳ�
            StringBuilder strSql5 = new StringBuilder();
            strSql5.Append("delete from dt_article_diggs ");
            strSql5.Append(" where id=@id ");
            SqlParameter[] parameters5 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters5[0].Value = id;
            cmd = new CommandInfo(strSql5.ToString(), parameters5);
            sqllist.Add(cmd);

            //ɾ����Ʒ�۸�
            StringBuilder strSql6 = new StringBuilder();
            strSql6.Append("delete from dt_goods_group_price ");
            strSql6.Append(" where article_id=@article_id ");
            SqlParameter[] parameters6 = {
                    new SqlParameter("@article_id", SqlDbType.Int,4)};
            parameters6[0].Value = id;
            cmd = new CommandInfo(strSql6.ToString(), parameters6);
            sqllist.Add(cmd);

            //ɾ�����صĸ���
            StringBuilder strSql7 = new StringBuilder();
            strSql7.Append("delete from dt_download_attach ");
            strSql7.Append(" where article_id=@article_id ");
            SqlParameter[] parameters7 = {
                    new SqlParameter("@article_id", SqlDbType.Int,4)};
            parameters7[0].Value = id;
            cmd = new CommandInfo(strSql7.ToString(), parameters7);
            sqllist.Add(cmd);

            //ɾ��ͼƬ���
            StringBuilder strSql8 = new StringBuilder();
            strSql8.Append("delete from dt_article_albums ");
            strSql8.Append(" where article_id=@article_id ");
            SqlParameter[] parameters8 = {
                    new SqlParameter("@article_id", SqlDbType.Int,4)};
            parameters8[0].Value = id;
            cmd = new CommandInfo(strSql8.ToString(), parameters8);
            sqllist.Add(cmd);

            //ɾ����չ����
            StringBuilder strSql9 = new StringBuilder();
            strSql9.Append("delete from dt_attribute_value ");
            strSql9.Append(" where article_id=@article_id ");
            SqlParameter[] parameters9 = {
                    new SqlParameter("@article_id", SqlDbType.Int,4)};
            parameters9[0].Value = id;
            cmd = new CommandInfo(strSql9.ToString(), parameters9);
            sqllist.Add(cmd);

            //ɾ������
            StringBuilder strSql10 = new StringBuilder();
            strSql10.Append("delete from dt_article_comment ");
            strSql10.Append(" where article_id=@article_id ");
            SqlParameter[] parameters10 = {
                    new SqlParameter("@article_id", SqlDbType.Int,4)};
            parameters10[0].Value = id;
            cmd = new CommandInfo(strSql10.ToString(), parameters10);
            sqllist.Add(cmd);

            //ɾ��������Ϣ
            StringBuilder strSql11 = new StringBuilder();
            strSql11.Append("delete from dt_article ");
            strSql11.Append(" where id=@id ");
            SqlParameter[] parameters11 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters11[0].Value = id;
            cmd = new CommandInfo(strSql11.ToString(), parameters11);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                new article_albums().DeleteFile(albumsList); //ɾ��ͼƬ
                new download_attach().DeleteFile(attachList); //ɾ������
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #8
0
        /// <summary>
        /// ����һ������,�����ӱ�����
        /// </summary>
        public int Add(Model.article_goods model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_article(");
            strSql.Append("channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@category_id,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_lock,@user_id,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@channel_id", SqlDbType.Int,4),
                    new SqlParameter("@category_id", SqlDbType.Int,4),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@link_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@img_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@click", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1),
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.channel_id;
            parameters[1].Value = model.category_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.link_url;
            parameters[4].Value = model.img_url;
            parameters[5].Value = model.seo_title;
            parameters[6].Value = model.seo_keywords;
            parameters[7].Value = model.seo_description;
            parameters[8].Value = model.content;
            parameters[9].Value = model.sort_id;
            parameters[10].Value = model.click;
            parameters[11].Value = model.is_lock;
            parameters[12].Value = model.user_id;
            parameters[13].Value = model.add_time;
            parameters[14].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("insert into dt_article_goods(");
            strSql2.Append("id,goods_no,stock_quantity,market_price,sell_price,point,is_msg,is_top,is_red,is_hot,is_slide)");
            strSql2.Append(" values (");
            strSql2.Append("@id,@goods_no,@stock_quantity,@market_price,@sell_price,@point,@is_msg,@is_top,@is_red,@is_hot,@is_slide)");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@goods_no", SqlDbType.NVarChar,100),
                    new SqlParameter("@stock_quantity", SqlDbType.Int,4),
                    new SqlParameter("@market_price", SqlDbType.Decimal,5),
                    new SqlParameter("@sell_price", SqlDbType.Decimal,5),
                    new SqlParameter("@point", SqlDbType.Int,4),
                    new SqlParameter("@is_msg", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_top", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_red", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_hot", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_slide", SqlDbType.TinyInt,1)};
            parameters2[0].Direction = ParameterDirection.InputOutput;
            parameters2[1].Value = model.goods_no;
            parameters2[2].Value = model.stock_quantity;
            parameters2[3].Value = model.market_price;
            parameters2[4].Value = model.sell_price;
            parameters2[5].Value = model.point;
            parameters2[6].Value = model.is_msg;
            parameters2[7].Value = model.is_top;
            parameters2[8].Value = model.is_red;
            parameters2[9].Value = model.is_hot;
            parameters2[10].Value = model.is_slide;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //���Ͳ�
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("insert into dt_article_diggs(");
            strSql3.Append("id,digg_good,digg_bad)");
            strSql3.Append(" values (");
            strSql3.Append("@id,@digg_good,@digg_bad)");
            SqlParameter[] parameters3 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@digg_good", SqlDbType.Int,4),
                    new SqlParameter("@digg_bad", SqlDbType.Int,4)};
            parameters3[0].Direction = ParameterDirection.InputOutput;
            parameters3[1].Value = model.digg_good;
            parameters3[2].Value = model.digg_bad;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //ͼƬ���
            if (model.albums != null)
            {
                StringBuilder strSql4;
                foreach (Model.article_albums models in model.albums)
                {
                    strSql4 = new StringBuilder();
                    strSql4.Append("insert into dt_article_albums(");
                    strSql4.Append("article_id,big_img,small_img,remark)");
                    strSql4.Append(" values (");
                    strSql4.Append("@article_id,@big_img,@small_img,@remark)");
                    SqlParameter[] parameters4 = {
                            new SqlParameter("@article_id", SqlDbType.Int,4),
                            new SqlParameter("@big_img", SqlDbType.NVarChar,255),
                            new SqlParameter("@small_img", SqlDbType.NVarChar,255),
                            new SqlParameter("@remark", SqlDbType.NVarChar,500)};
                    parameters4[0].Direction = ParameterDirection.InputOutput;
                    parameters4[1].Value = models.big_img;
                    parameters4[2].Value = models.small_img;
                    parameters4[3].Value = models.remark;

                    cmd = new CommandInfo(strSql4.ToString(), parameters4);
                    sqllist.Add(cmd);
                }
            }
            //��չ����
            if (model.attribute_values != null)
            {
                StringBuilder strSql5;
                foreach (Model.attribute_value models in model.attribute_values)
                {
                    strSql5 = new StringBuilder();
                    strSql5.Append("insert into dt_attribute_value(");
                    strSql5.Append("article_id,attribute_id,title,content)");
                    strSql5.Append(" values (");
                    strSql5.Append("@article_id,@attribute_id,@title,@content)");
                    SqlParameter[] parameters5 = {
                            new SqlParameter("@article_id", SqlDbType.Int,4),
                            new SqlParameter("@attribute_id", SqlDbType.Int,4),
                            new SqlParameter("@title", SqlDbType.NVarChar,100),
                            new SqlParameter("@content", SqlDbType.NText)};
                    parameters5[0].Direction = ParameterDirection.InputOutput;
                    parameters5[1].Value = models.attribute_id;
                    parameters5[2].Value = models.title;
                    parameters5[3].Value = models.content;
                    cmd = new CommandInfo(strSql5.ToString(), parameters5);
                    sqllist.Add(cmd);
                }
            }

            //�û���۸�
            if (model.goods_group_prices != null)
            {
                StringBuilder strSql6;
                foreach (Model.goods_group_price models in model.goods_group_prices)
                {
                    strSql6 = new StringBuilder();
                    strSql6.Append("insert into dt_goods_group_price(");
                    strSql6.Append("article_id,group_id,price)");
                    strSql6.Append(" values (");
                    strSql6.Append("@article_id,@group_id,@price)");
                    SqlParameter[] parameters6 = {
                            new SqlParameter("@article_id", SqlDbType.Int,4),
                            new SqlParameter("@group_id", SqlDbType.Int,4),
                            new SqlParameter("@price", SqlDbType.Decimal,5)};
                    parameters6[0].Direction = ParameterDirection.InputOutput;
                    parameters6[1].Value = models.group_id;
                    parameters6[2].Value = models.price;
                    cmd = new CommandInfo(strSql6.ToString(), parameters6);
                    sqllist.Add(cmd);
                }
            }

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[14].Value;
        }
        /// <summary>
        /// ����һ������,�����ӱ�����
        /// </summary>
        public int Add(Model.article_download model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_article(");
            strSql.Append("channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@category_id,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_lock,@user_id,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@channel_id", SqlDbType.Int,4),
                    new SqlParameter("@category_id", SqlDbType.Int,4),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@link_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@img_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@click", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1),
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.channel_id;
            parameters[1].Value = model.category_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.link_url;
            parameters[4].Value = model.img_url;
            parameters[5].Value = model.seo_title;
            parameters[6].Value = model.seo_keywords;
            parameters[7].Value = model.seo_description;
            parameters[8].Value = model.content;
            parameters[9].Value = model.sort_id;
            parameters[10].Value = model.click;
            parameters[11].Value = model.is_lock;
            parameters[12].Value = model.user_id;
            parameters[13].Value = model.add_time;
            parameters[14].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("insert into dt_article_download(");
            strSql2.Append("id,is_msg,is_red)");
            strSql2.Append(" values (");
            strSql2.Append("@id,@is_msg,@is_red)");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@is_msg", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_red", SqlDbType.TinyInt,1)};
            parameters2[0].Direction = ParameterDirection.InputOutput;
            parameters2[1].Value = model.is_msg;
            parameters2[2].Value = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //���Ͳ�
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("insert into dt_article_diggs(");
            strSql3.Append("id,digg_good,digg_bad)");
            strSql3.Append(" values (");
            strSql3.Append("@id,@digg_good,@digg_bad)");
            SqlParameter[] parameters3 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@digg_good", SqlDbType.Int,4),
                    new SqlParameter("@digg_bad", SqlDbType.Int,4)};
            parameters3[0].Direction = ParameterDirection.InputOutput;
            parameters3[1].Value = model.digg_good;
            parameters3[2].Value = model.digg_bad;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //���ظ���
            if (model.download_attachs != null)
            {
                StringBuilder strSql4;
                foreach (Model.download_attach models in model.download_attachs)
                {
                    strSql4 = new StringBuilder();
                    strSql4.Append("insert into dt_download_attach(");
                    strSql4.Append("article_id,title,file_path,file_ext,file_size,down_num,point)");
                    strSql4.Append(" values (");
                    strSql4.Append("@article_id,@title,@file_path,@file_ext,@file_size,@down_num,@point)");
                    SqlParameter[] parameters4 = {
                            new SqlParameter("@article_id", SqlDbType.Int,4),
                            new SqlParameter("@title", SqlDbType.NVarChar,255),
                            new SqlParameter("@file_path", SqlDbType.NVarChar,255),
                            new SqlParameter("@file_ext", SqlDbType.NVarChar,100),
                            new SqlParameter("@file_size", SqlDbType.Int,4),
                            new SqlParameter("@down_num", SqlDbType.Int,4),
                            new SqlParameter("@point", SqlDbType.Int,4)};
                    parameters4[0].Direction = ParameterDirection.InputOutput;
                    parameters4[1].Value = models.title;
                    parameters4[2].Value = models.file_path;
                    parameters4[3].Value = models.file_ext;
                    parameters4[4].Value = models.file_size;
                    parameters4[5].Value = models.down_num;
                    parameters4[6].Value = models.point;
                    cmd = new CommandInfo(strSql4.ToString(), parameters4);
                    sqllist.Add(cmd);
                }
            }

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[14].Value;
        }
Beispiel #10
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.article_content model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update dt_article set ");
            strSql.Append("channel_id=@channel_id,");
            strSql.Append("category_id=@category_id,");
            strSql.Append("title=@title,");
            strSql.Append("link_url=@link_url,");
            strSql.Append("img_url=@img_url,");
            strSql.Append("seo_title=@seo_title,");
            strSql.Append("seo_keywords=@seo_keywords,");
            strSql.Append("seo_description=@seo_description,");
            strSql.Append("content=@content,");
            strSql.Append("sort_id=@sort_id,");
            strSql.Append("click=@click,");
            strSql.Append("is_lock=@is_lock,");
            strSql.Append("user_id=@user_id,");
            strSql.Append("add_time=@add_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@channel_id", SqlDbType.Int,4),
                    new SqlParameter("@category_id", SqlDbType.Int,4),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@link_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@img_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@click", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1),
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = model.channel_id;
            parameters[1].Value = model.category_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.link_url;
            parameters[4].Value = model.img_url;
            parameters[5].Value = model.seo_title;
            parameters[6].Value = model.seo_keywords;
            parameters[7].Value = model.seo_description;
            parameters[8].Value = model.content;
            parameters[9].Value = model.sort_id;
            parameters[10].Value = model.click;
            parameters[11].Value = model.is_lock;
            parameters[12].Value = model.user_id;
            parameters[13].Value = model.add_time;
            parameters[14].Value = model.id;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //修改副表
            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("update dt_article_content set ");
            strSql2.Append("id=@id,");
            strSql2.Append("call_index=@call_index,");
            strSql2.Append("is_msg=@is_msg,");
            strSql2.Append("is_red=@is_red");
            strSql2.Append(" where id=@id ");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@call_index", SqlDbType.NVarChar,50),
                    new SqlParameter("@is_msg", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_red", SqlDbType.TinyInt,1)};
            parameters2[0].Value = model.id;
            parameters2[1].Value = model.call_index;
            parameters2[2].Value = model.is_msg;
            parameters2[3].Value = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //修改顶和踩
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("update dt_article_diggs set ");
            strSql3.Append("digg_good=@digg_good,");
            strSql3.Append("digg_bad=@digg_bad");
            strSql3.Append(" where id=@id ");
            SqlParameter[] parameters3 = {
                                new SqlParameter("@digg_good", SqlDbType.Int,4),
                                new SqlParameter("@digg_bad", SqlDbType.Int,4),
                                new SqlParameter("@id", SqlDbType.Int,4)};
            parameters3[0].Value = model.digg_good;
            parameters3[1].Value = model.digg_bad;
            parameters3[2].Value = model.id;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #11
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.article_content model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into dt_article(");
            strSql.Append("channel_id,category_id,title,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_lock,user_id,add_time)");
            strSql.Append(" values (");
            strSql.Append("@channel_id,@category_id,@title,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_lock,@user_id,@add_time)");
            strSql.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] parameters = {
                    new SqlParameter("@channel_id", SqlDbType.Int,4),
                    new SqlParameter("@category_id", SqlDbType.Int,4),
                    new SqlParameter("@title", SqlDbType.NVarChar,100),
                    new SqlParameter("@link_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@img_url", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_title", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_keywords", SqlDbType.NVarChar,255),
                    new SqlParameter("@seo_description", SqlDbType.NVarChar,255),
                    new SqlParameter("@content", SqlDbType.NText),
                    new SqlParameter("@sort_id", SqlDbType.Int,4),
                    new SqlParameter("@click", SqlDbType.Int,4),
                    new SqlParameter("@is_lock", SqlDbType.TinyInt,1),
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@ReturnValue",SqlDbType.Int)};
            parameters[0].Value = model.channel_id;
            parameters[1].Value = model.category_id;
            parameters[2].Value = model.title;
            parameters[3].Value = model.link_url;
            parameters[4].Value = model.img_url;
            parameters[5].Value = model.seo_title;
            parameters[6].Value = model.seo_keywords;
            parameters[7].Value = model.seo_description;
            parameters[8].Value = model.content;
            parameters[9].Value = model.sort_id;
            parameters[10].Value = model.click;
            parameters[11].Value = model.is_lock;
            parameters[12].Value = model.user_id;
            parameters[13].Value = model.add_time;
            parameters[14].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("insert into dt_article_content(");
            strSql2.Append("id,call_index,is_msg,is_red)");
            strSql2.Append(" values (");
            strSql2.Append("@id,@call_index,@is_msg,@is_red)");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@call_index", SqlDbType.NVarChar,50),
                    new SqlParameter("@is_msg", SqlDbType.TinyInt,1),
                    new SqlParameter("@is_red", SqlDbType.TinyInt,1)};
            parameters2[0].Direction = ParameterDirection.InputOutput;
            parameters2[1].Value = model.call_index;
            parameters2[2].Value = model.is_msg;
            parameters2[3].Value = model.is_red;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //顶和踩
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("insert into dt_article_diggs(");
            strSql3.Append("id,digg_good,digg_bad)");
            strSql3.Append(" values (");
            strSql3.Append("@id,@digg_good,@digg_bad)");
            SqlParameter[] parameters3 = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@digg_good", SqlDbType.Int,4),
                    new SqlParameter("@digg_bad", SqlDbType.Int,4)};
            parameters3[0].Direction = ParameterDirection.InputOutput;
            parameters3[1].Value = model.digg_good;
            parameters3[2].Value = model.digg_bad;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            DbHelperSQL.ExecuteSqlTranWithIndentity(sqllist);
            return (int)parameters[14].Value;
        }
Beispiel #12
0
        /// <summary>
        /// ɾ��һ������
        /// </summary>
        public bool Delete(int id)
        {
            //��ȡ���û�Model
            Model.users model = GetModel(id);
            if (model == null)
            {
                return false;
            }
            List<CommandInfo> sqllist = new List<CommandInfo>();
            //ɾ����¼��־
            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from dt_user_login_log ");
            strSql.Append(" where user_id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //ɾ��������
            StringBuilder strSql1 = new StringBuilder();
            strSql1.Append("delete from dt_user_code ");
            strSql1.Append(" where user_id=@id");
            SqlParameter[] parameters1 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters1[0].Value = id;
            cmd = new CommandInfo(strSql1.ToString(), parameters1);
            sqllist.Add(cmd);

            //ɾ�����ּ�¼
            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("delete from dt_point_log ");
            strSql2.Append(" where user_id=@id");
            SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters2[0].Value = id;
            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //ɾ������¼
            StringBuilder strSql3 = new StringBuilder();
            strSql3.Append("delete from dt_amount_log ");
            strSql3.Append(" where user_id=@id");
            SqlParameter[] parameters3 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters3[0].Value = id;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //ɾ������Ϣ
            StringBuilder strSql4 = new StringBuilder();
            strSql4.Append("delete from dt_user_message ");
            strSql4.Append(" where post_user_name=@post_user_name or accept_user_name=@accept_user_name");
            SqlParameter[] parameters4 = {
                    new SqlParameter("@post_user_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@accept_user_name", SqlDbType.NVarChar,100)};
            parameters4[0].Value = model.user_name;
            parameters4[1].Value = model.user_name;
            cmd = new CommandInfo(strSql4.ToString(), parameters4);
            sqllist.Add(cmd);

            //ɾ���û�����
            StringBuilder strSql5 = new StringBuilder();
            strSql5.Append("delete from dt_users ");
            strSql5.Append(" where id=@id");
            SqlParameter[] parameters5 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters5[0].Value = id;
            cmd = new CommandInfo(strSql5.ToString(), parameters5);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #13
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.amount_log model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update dt_amount_log set ");
            strSql.Append("user_id=@user_id,");
            strSql.Append("user_name=@user_name,");
            strSql.Append("type=@type,");
            strSql.Append("order_no=@order_no,");
            strSql.Append("payment_id=@payment_id,");
            strSql.Append("value=@value,");
            strSql.Append("remark=@remark,");
            strSql.Append("status=@status,");
            strSql.Append("add_time=@add_time,");
            strSql.Append("complete_time=@complete_time");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@user_id", SqlDbType.Int,4),
                    new SqlParameter("@user_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@type", SqlDbType.NVarChar,50),
                    new SqlParameter("@order_no", SqlDbType.NVarChar,100),
                    new SqlParameter("@payment_id", SqlDbType.Int,4),
                    new SqlParameter("@value", SqlDbType.Decimal,5),
                    new SqlParameter("@remark", SqlDbType.NVarChar,500),
                    new SqlParameter("@status", SqlDbType.TinyInt,1),
                    new SqlParameter("@add_time", SqlDbType.DateTime),
                    new SqlParameter("@complete_time", SqlDbType.DateTime),
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = model.user_id;
            parameters[1].Value = model.user_name;
            parameters[2].Value = model.type;
            parameters[3].Value = model.order_no;
            parameters[4].Value = model.payment_id;
            parameters[5].Value = model.value;
            parameters[6].Value = model.remark;
            parameters[7].Value = model.status;
            parameters[8].Value = model.add_time;
            parameters[9].Value = model.complete_time;
            parameters[10].Value = model.id;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            if (model.status > 0)
            {
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("update dt_users set amount=amount+" + model.value);
                strSql2.Append(" where id=@id");
                SqlParameter[] parameters2 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = model.user_id;
                cmd = new CommandInfo(strSql2.ToString(), parameters2);
                sqllist.Add(cmd);
            }

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Beispiel #14
0
        /// <summary>
        /// ����һ�����ݼ����ӱ�
        /// </summary>
        public bool Update(Model.manager_role model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update dt_manager_role set ");
            strSql.Append("role_name=@role_name,");
            strSql.Append("role_type=@role_type");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@role_name", SqlDbType.NVarChar,100),
                    new SqlParameter("@role_type", SqlDbType.TinyInt,1)};
            parameters[0].Value = model.id;
            parameters[1].Value = model.role_name;
            parameters[2].Value = model.role_type;

            List<CommandInfo> sqllist = new List<CommandInfo>();
            CommandInfo cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            //ɾ��Ȩ��
            StringBuilder strSql2 = new StringBuilder();
            strSql2.Append("delete from dt_manager_role_value where role_id=@role_id ");
            StringBuilder idList = new StringBuilder();
            if (model.manager_role_values != null)
            {
                foreach (Model.manager_role_value models in model.manager_role_values)
                {
                    if (models.id > 0)
                    {
                        idList.Append(models.id + ",");
                    }
                }
                string id_list = HotoUtils.DelLastChar(idList.ToString(), ",");
                if (!string.IsNullOrEmpty(id_list))
                {
                    strSql2.Append(" and id not in(" + id_list + ")");
                }
            }
            SqlParameter[] parameters2 = {
                    new SqlParameter("@role_id", SqlDbType.Int,4)};
            parameters2[0].Value = model.id;

            cmd = new CommandInfo(strSql2.ToString(), parameters2);
            sqllist.Add(cmd);

            //���Ȩ��
            if (model.manager_role_values != null)
            {
                StringBuilder strSql3;
                foreach (Model.manager_role_value models in model.manager_role_values)
                {
                    strSql3 = new StringBuilder();
                    if (models.id == 0)
                    {
                        strSql3.Append("insert into dt_manager_role_value(");
                        strSql3.Append("role_id,channel_name,channel_id,action_type)");
                        strSql3.Append(" values (");
                        strSql3.Append("@role_id,@channel_name,@channel_id,@action_type)");
                        SqlParameter[] parameters3 = {
                        new SqlParameter("@role_id", SqlDbType.Int,4),
                        new SqlParameter("@channel_name", SqlDbType.NVarChar,255),
                        new SqlParameter("@channel_id", SqlDbType.Int,4),
                        new SqlParameter("@action_type", SqlDbType.NVarChar,100)};
                        parameters3[0].Value = model.id;
                        parameters3[1].Value = models.channel_name;
                        parameters3[2].Value = models.channel_id;
                        parameters3[3].Value = models.action_type;

                        cmd = new CommandInfo(strSql3.ToString(), parameters3);
                        sqllist.Add(cmd);
                    }
                }
            }

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }