Exemplo n.º 1
0
        /// <summary>
        /// ɾ��һ������
        /// </summary>
        public bool Delete(int id)
        {
            List<CommandInfo> sqllist = new List<CommandInfo>();

            StringBuilder strSql = new StringBuilder();
            strSql.Append("delete from dt_manager_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_manager ");
            strSql1.Append(" where id=@id");
            SqlParameter[] parameters1 = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters1[0].Value = id;
            cmd = new CommandInfo(strSql1.ToString(), parameters1);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);
            if (rowsAffected > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
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;
        }
Exemplo n.º 4
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;
        }
Exemplo n.º 5
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;
            }
        }
Exemplo n.º 6
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 = Utils.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;
            }
        }
Exemplo n.º 7
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;
            }
        }