Esempio n. 1
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            //删除会员组价格
            StringBuilder strSql1 = new StringBuilder();

            strSql1.Append("delete from " + databaseprefix + "user_group_price ");
            strSql1.Append(" where group_id=@group_id ");
            SqlParameter[] parameters1 =
            {
                new SqlParameter("@group_id", SqlDbType.Int, 4)
            };
            parameters1[0].Value = id;
            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql1.ToString(), parameters1);

            sqllist.Add(cmd);

            //删除主表
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from " + databaseprefix + "user_groups ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        ///// <summary>
        ///// 更新一条数据
        ///// </summary>
        //public bool Update(Model.manager_role model)
        //{
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("update " + databaseprefix + "manager_role set ");
        //    strSql.Append("role_name=@role_name,");
        //    strSql.Append("role_type=@role_type,");
        //    strSql.Append("is_sys=@is_sys");
        //    strSql.Append(" where id=@id");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@role_name", SqlDbType.NVarChar,100),
        //            new SqlParameter("@role_type", SqlDbType.TinyInt,1),
        //            new SqlParameter("@is_sys", SqlDbType.TinyInt,1),
        //            new SqlParameter("@id", SqlDbType.Int,4)};
        //    parameters[0].Value = model.role_name;
        //    parameters[1].Value = model.role_type;
        //    parameters[2].Value = model.is_sys;
        //    parameters[3].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("delete from " + databaseprefix + "manager_role_value where role_id=@role_id ");
        //    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 modelt in model.manager_role_values)
        //        {
        //            strSql3 = new StringBuilder();
        //            strSql3.Append("insert into " + databaseprefix + "manager_role_value(");
        //            strSql3.Append("role_id,nav_name,action_type)");
        //            strSql3.Append(" values (");
        //            strSql3.Append("@role_id,@nav_name,@action_type)");
        //            SqlParameter[] parameters3 = {
        //                    new SqlParameter("@role_id", SqlDbType.Int,4),
        //                    new SqlParameter("@nav_name", SqlDbType.NVarChar,100),
        //                    new SqlParameter("@action_type", SqlDbType.NVarChar,50)};
        //            parameters3[0].Value = model.id;
        //            parameters3[1].Value = modelt.nav_name;
        //            parameters3[2].Value = modelt.action_type;
        //            cmd = new CommandInfo(strSql3.ToString(), parameters3);
        //            sqllist.Add(cmd);
        //        }
        //    }

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

        /// <summary>
        /// 删除一条数据,及子表所有相关数据
        /// </summary>
        public bool Delete(int id)
        {
            List <CommandInfo> sqllist = new List <CommandInfo>();
            //删除管理角色权限
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from " + databaseprefix + "manager_role_value ");
            strSql.Append(" where role_id=@role_id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@role_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 " + databaseprefix + "manager_role ");
            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);
            }
        }
        public bool AddClientAndDiscount(Client client, Discount discount)
        {
            Hashtable     sqlhash = new Hashtable();
            StringBuilder strsql  = new StringBuilder();

            strsql.Append("insert into T_Discount(");
            strsql.Append("Dis_Name,Dis_ClientCode,Dis_CreateDate,Dis_ClearDate,Dis_Discount,Dis_Enable,Dis_Clear,Dis_Remark,Dis_Code");
            strsql.Append(") values (");
            strsql.Append("@Dis_Name,@Dis_ClientCode,@Dis_CreateDate,@Dis_ClearDate,@Dis_Discount,@Dis_Enable,@Dis_Clear,@Dis_Remark,@Dis_Code)");
            SqlParameter[] disParameters =
            {
                new SqlParameter("@Dis_Name",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Dis_ClientCode", SqlDbType.NVarChar,   512),
                new SqlParameter("@Dis_CreateDate", SqlDbType.DateTime),
                new SqlParameter("@Dis_ClearDate",  SqlDbType.DateTime),
                new SqlParameter("@Dis_Discount",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Dis_Enable",     SqlDbType.Int,          4),
                new SqlParameter("@Dis_Clear",      SqlDbType.Int,          4),
                new SqlParameter("@Dis_Remark",     SqlDbType.NVarChar,  1024),
                new SqlParameter("@Dis_Code",       SqlDbType.NVarChar,   512),
            };
            disParameters[0].Value = discount.Dis_Name;
            disParameters[1].Value = discount.Dis_ClientCode;
            disParameters[2].Value = discount.Dis_CreateDate;
            disParameters[3].Value = discount.Dis_ClearDate;
            disParameters[4].Value = discount.Dis_Discount;
            disParameters[5].Value = discount.Dis_Enable;
            disParameters[6].Value = discount.Dis_Clear;
            disParameters[7].Value = discount.Dis_Remark;
            disParameters[8].Value = discount.Dis_Code;

            sqlhash.Add(strsql.ToString(), disParameters);

            strsql = new StringBuilder();

            strsql.Append("insert into T_Client(");
            strsql.Append("Cli_Code,Cli_zhiwen,Cli_Name,Cli_PicName,Cli_Phone,Cli_PhoneTwo,Cli_faxes,Cli_CityCode,Cli_area,Cli_Address,Cli_LinkMan,Cli_Company,Cli_TypeCode,Cli_TypeName,Cli_DiscountCode,Cli_Bankaccounts,Cli_OpenBank,Cli_Olddata,Cli_Oldreturn,Cli_Newoutdata,Cli_Newintodata,Cli_Createdata,Cli_Limit,Cli_RemainLimit,Cli_ClearLimitdate,Cli_ShouldMoney,Cli_GetMoney,Cli_PreMoney,Cli_Remark,Cli_safetone,Cli_safettwo,Cli_Enable)");
            strsql.Append(" values (");
            strsql.Append("@Cli_Code,@Cli_zhiwen,@Cli_Name,@Cli_PicName,@Cli_Phone,@Cli_PhoneTwo,@Cli_faxes,@Cli_CityCode,@Cli_area,@Cli_Address,@Cli_LinkMan,@Cli_Company,@Cli_TypeCode,@Cli_TypeName,@Cli_DiscountCode,@Cli_Bankaccounts,@Cli_OpenBank,@Cli_Olddata,@Cli_Oldreturn,@Cli_Newoutdata,@Cli_Newintodata,@Cli_Createdata,@Cli_Limit,@Cli_RemainLimit,@Cli_ClearLimitdate,@Cli_ShouldMoney,@Cli_GetMoney,@Cli_PreMoney,@Cli_Remark,@Cli_safetone,@Cli_safettwo,@Cli_Enable)");
            SqlParameter[] cliParameters =
            {
                new SqlParameter("@Cli_Code",           SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_zhiwen",         SqlDbType.NVarChar,    -1),
                new SqlParameter("@Cli_Name",           SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_PicName",        SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Phone",          SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_PhoneTwo",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_faxes",          SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_CityCode",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_area",           SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Address",        SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_LinkMan",        SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Company",        SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_TypeCode",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_TypeName",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_DiscountCode",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Bankaccounts",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_OpenBank",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Olddata",        SqlDbType.DateTime),
                new SqlParameter("@Cli_Oldreturn",      SqlDbType.DateTime),
                new SqlParameter("@Cli_Newoutdata",     SqlDbType.DateTime),
                new SqlParameter("@Cli_Newintodata",    SqlDbType.DateTime),
                new SqlParameter("@Cli_Createdata",     SqlDbType.DateTime),
                new SqlParameter("@Cli_Limit",          SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_RemainLimit",    SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_ClearLimitdate", SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_ShouldMoney",    SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_GetMoney",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_PreMoney",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Remark",         SqlDbType.NVarChar,  1024),
                new SqlParameter("@Cli_safetone",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_safettwo",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Cli_Enable",         SqlDbType.Int, 4)
            };
            cliParameters[0].Value  = client.Cli_Code;
            cliParameters[1].Value  = client.Cli_zhiwen;
            cliParameters[2].Value  = client.Cli_Name;
            cliParameters[3].Value  = client.Cli_PicName;
            cliParameters[4].Value  = client.Cli_Phone;
            cliParameters[5].Value  = client.Cli_PhoneTwo;
            cliParameters[6].Value  = client.Cli_faxes;
            cliParameters[7].Value  = client.Cli_Citycode;
            cliParameters[8].Value  = client.Cli_area;
            cliParameters[9].Value  = client.Cli_Address;
            cliParameters[10].Value = client.Cli_LinkMan;
            cliParameters[11].Value = client.Cli_Company;
            cliParameters[12].Value = client.Cli_TypeCode;
            cliParameters[13].Value = client.Cli_typename;
            cliParameters[14].Value = client.Cli_DiscountCode;
            cliParameters[15].Value = client.Cli_Bankaccounts;
            cliParameters[16].Value = client.Cli_OpenBank;
            cliParameters[17].Value = client.Cli_Olddata;
            cliParameters[18].Value = client.Cli_Oldreturn;
            cliParameters[19].Value = client.Cli_Newoutdata;
            cliParameters[20].Value = client.Cli_Newintodata;
            cliParameters[21].Value = client.Cli_Createdata;
            cliParameters[22].Value = client.Cli_Limit;
            cliParameters[23].Value = client.Cli_RemainLimit;
            cliParameters[24].Value = client.Cli_ClearLimitdate;
            cliParameters[25].Value = client.Cli_ShouldMoney;
            cliParameters[26].Value = client.Cli_GetMoney;
            cliParameters[27].Value = client.Cli_PreMoney;
            cliParameters[28].Value = client.Cli_Remark;
            cliParameters[29].Value = client.Cli_safetone;
            cliParameters[30].Value = client.Cli_safettwo;
            cliParameters[31].Value = client.Cli_Enable;

            sqlhash.Add(strsql.ToString(), cliParameters);

            try
            {
                DbHelperSQL.ExecuteSqlTran(sqlhash);
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            //获取用户旧数据
            Model.users model = GetModel(id);
            if (model == null)
            {
                return(false);
            }

            List <CommandInfo> sqllist = new List <CommandInfo>();
            //删除积分记录
            StringBuilder strSql1 = new StringBuilder();

            strSql1.Append("delete from " + databaseprefix + "user_point_log ");
            strSql1.Append(" where user_id=@id");
            SqlParameter[] parameters1 =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters1[0].Value = id;
            CommandInfo cmd = new CommandInfo(strSql1.ToString(), parameters1);

            sqllist.Add(cmd);

            //删除金额记录
            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("delete from " + databaseprefix + "user_amount_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 " + databaseprefix + "user_message ");
            strSql3.Append(" where post_user_name=@post_user_name or accept_user_name=@accept_user_name");
            SqlParameter[] parameters3 =
            {
                new SqlParameter("@post_user_name",   SqlDbType.NVarChar, 100),
                new SqlParameter("@accept_user_name", SqlDbType.NVarChar, 100)
            };
            parameters3[0].Value = model.user_name;
            parameters3[1].Value = model.user_name;
            cmd = new CommandInfo(strSql3.ToString(), parameters3);
            sqllist.Add(cmd);

            //删除申请码
            StringBuilder strSql4 = new StringBuilder();

            strSql4.Append("delete from " + databaseprefix + "user_code ");
            strSql4.Append(" where user_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 " + databaseprefix + "user_login_log ");
            strSql5.Append(" where user_id=@id");
            SqlParameter[] parameters5 =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters5[0].Value = id;
            cmd = new CommandInfo(strSql5.ToString(), parameters5);
            sqllist.Add(cmd);

            //删除用户记录
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from " + databaseprefix + "users ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.manager_role model)
        {
            //StringBuilder strSql = new StringBuilder();
            //strSql.Append("update " + databaseprefix + "manager_role set ");
            //strSql.Append("role_name=@role_name,");
            //strSql.Append("role_type=@role_type,");
            //strSql.Append("is_sys=@is_sys");
            //strSql.Append(" where id=@id");
            //SqlParameter[] parameters = {
            //        new SqlParameter("@role_name", SqlDbType.NVarChar,100),
            //        new SqlParameter("@role_type", SqlDbType.TinyInt,1),
            //        new SqlParameter("@is_sys", SqlDbType.TinyInt,1),
            //        new SqlParameter("@id", SqlDbType.Int,4)};
            //parameters[0].Value = model.role_name;
            //parameters[1].Value = model.role_type;
            //parameters[2].Value = model.is_sys;
            //parameters[3].Value = model.id;



            StringBuilder             strSql     = new StringBuilder();
            Collection <SqlParameter> parameters = new Collection <SqlParameter>

                                                       ();
            SqlParameter parameter = null;
            int          count     = 0;

            strSql.Append("update dt_manager_role set ");
            parameter = new SqlParameter("@id",

                                         SqlDbType.Int, 4);
            parameter.Value = model.id;
            parameters.Add(parameter);
            if (model.role_name_IsEdit)
            {
                strSql.Append(" role_name = @role_name,");
                parameter = new SqlParameter("@role_name",

                                             SqlDbType.NVarChar, 100);
                parameter.Value = model.role_name;
                parameters.Add(parameter);
                count++;
            }



            if (model.role_type_IsEdit)
            {
                strSql.Append(" role_type = @role_type,");
                parameter = new SqlParameter("@role_type",

                                             SqlDbType.TinyInt, 1);
                parameter.Value = model.role_type;
                parameters.Add(parameter);
                count++;
            }



            if (model.is_sys_IsEdit)
            {
                strSql.Append(" is_sys = @is_sys,");
                parameter = new SqlParameter("@is_sys",

                                             SqlDbType.TinyInt, 1);
                parameter.Value = model.is_sys;
                parameters.Add(parameter);
                count++;
            }



            if (model.agentId_IsEdit)
            {
                strSql.Append(" agentId = @agentId,");
                parameter = new SqlParameter("@agentId",

                                             SqlDbType.Int, 4);
                parameter.Value = model.agentId;
                parameters.Add(parameter);
                count++;
            }

            if (count > 0)
            {
                strSql.Remove(strSql.Length - 1, 1);
            }
            if (count == 0)
            {
                return(false);
            }
            strSql.Append(" where id=@id ");
            // 将参数泛形集合转传为数组
            SqlParameter[] args = new SqlParameter[parameters.Count];
            parameters.CopyTo(args, 0);
            List <CommandInfo> sqllist = new List <CommandInfo>();
            CommandInfo        cmd     = new CommandInfo(strSql.ToString(), args);

            sqllist.Add(cmd);

            //先删除该角色所有权限
            StringBuilder strSql2 = new StringBuilder();

            strSql2.Append("delete from " + databaseprefix + "manager_role_value where role_id=@role_id ");
            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 modelt in model.manager_role_values)
                {
                    strSql3 = new StringBuilder();
                    strSql3.Append("insert into " + databaseprefix + "manager_role_value(");
                    strSql3.Append("role_id,nav_name,action_type)");
                    strSql3.Append(" values (");
                    strSql3.Append("@role_id,@nav_name,@action_type)");
                    SqlParameter[] parameters3 =
                    {
                        new SqlParameter("@role_id",     SqlDbType.Int,        4),
                        new SqlParameter("@nav_name",    SqlDbType.NVarChar, 100),
                        new SqlParameter("@action_type", SqlDbType.NVarChar, 50)
                    };
                    parameters3[0].Value = model.id;
                    parameters3[1].Value = modelt.nav_name;
                    parameters3[2].Value = modelt.action_type;
                    cmd = new CommandInfo(strSql3.ToString(), parameters3);
                    sqllist.Add(cmd);
                }
            }

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.user_amount_log model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "user_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("trade_no=@trade_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("@trade_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.trade_no;
            parameters[5].Value  = model.payment_id;
            parameters[6].Value  = model.value;
            parameters[7].Value  = model.remark;
            parameters[8].Value  = model.status;
            parameters[9].Value  = model.add_time;
            parameters[10].Value = model.complete_time;
            parameters[11].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 " + databaseprefix + "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);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.manager_role model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "manager_role set ");
            strSql.Append("role_name=@role_name,");
            strSql.Append("role_type=@role_type,");
            strSql.Append("is_sys=@is_sys");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@role_name", SqlDbType.NVarChar, 100),
                new SqlParameter("@role_type", SqlDbType.TinyInt,    1),
                new SqlParameter("@is_sys",    SqlDbType.TinyInt,    1),
                new SqlParameter("@id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.role_name;
            parameters[1].Value = model.role_type;
            parameters[2].Value = model.is_sys;
            parameters[3].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("delete from " + databaseprefix + "manager_role_value where role_id=@role_id ");
            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 modelt in model.manager_role_values)
                {
                    strSql3 = new StringBuilder();
                    strSql3.Append("insert into " + databaseprefix + "manager_role_value(");
                    strSql3.Append("role_id,nav_name,action_type)");
                    strSql3.Append(" values (");
                    strSql3.Append("@role_id,@nav_name,@action_type)");
                    SqlParameter[] parameters3 =
                    {
                        new SqlParameter("@role_id",     SqlDbType.Int,        4),
                        new SqlParameter("@nav_name",    SqlDbType.NVarChar, 100),
                        new SqlParameter("@action_type", SqlDbType.NVarChar, 50)
                    };
                    parameters3[0].Value = model.id;
                    parameters3[1].Value = modelt.nav_name;
                    parameters3[2].Value = modelt.action_type;
                    cmd = new CommandInfo(strSql3.ToString(), parameters3);
                    sqllist.Add(cmd);
                }
            }

            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// р坝珇獺础ら粁,穝畐,穝坝珇计秖
        /// </summary>
        public bool UpdateGoodsNum(string id, int num, int user_id, string user_name)
        {
            //础ら粁
            List <CommandInfo> sqllist = new List <CommandInfo>();
            StringBuilder      strSql2 = new StringBuilder();

            strSql2.Append("insert into " + databaseprefix + "order_log ");
            strSql2.Append("select *,@user_id,@user_name,getdate() from " + databaseprefix + "order_goods ");
            strSql2.Append(" where id=@id ");
            SqlParameter[] parameters2 =
            {
                new SqlParameter("@id",        SqlDbType.Int,       8),
                new SqlParameter("@user_id",   SqlDbType.NVarChar, 50),
                new SqlParameter("@user_name", SqlDbType.NVarChar, 50)
            };
            parameters2[0].Value = id;
            parameters2[1].Value = user_id;
            parameters2[2].Value = user_name;

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

            sqllist.Add(cmd);

            //穝畐
            StringBuilder strSql3 = new StringBuilder();

            strSql3.Append("update " + databaseprefix + "article_attribute_value ");
            strSql3.Append("set stock_quantity=stock_quantity - (@num - ");
            strSql3.Append("(select isnull(quantity,0) from " + databaseprefix + "order_goods where id=@id))");
            strSql3.Append("where article_id=( ");
            strSql3.Append("select goods_id from " + databaseprefix + "order_goods where id=@id)");
            SqlParameter[] parameters3 =
            {
                new SqlParameter("@id",  SqlDbType.Int, 8),
                new SqlParameter("@num", SqlDbType.Int, 8)
            };
            parameters3[0].Value = id;
            parameters3[1].Value = num;

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

            //穝计秖
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + databaseprefix + "order_goods set quantity=@num ");
            strSql.Append("where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",  SqlDbType.Int, 8),
                new SqlParameter("@num", SqlDbType.Int, 8)
            };
            parameters[0].Value = id;
            parameters[1].Value = num;

            cmd = new CommandInfo(strSql.ToString(), parameters);
            sqllist.Add(cmd);
            int rowsAffected = DbHelperSQL.ExecuteSqlTran(sqllist);

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
        //public DataSet GetListSellInDetail()
        //{

        //}

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        //public Sell GetModel(int Sell_ID)
        //{

        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append("select  top 1 Sell_ID,Sell_Code,Sell_Type,Sell_Date,Sell_TransportType,Sell_Review,Sell_ChangeDate,Sell_Operation,Sell_Auditman,Sell_Remark,Sell_Satetyone,Sell_Satetytwo,Sell_Clear from T_Sell ");
        //    strSql.Append(" where Sell_ID=@Sell_ID");
        //    SqlParameter[] parameters = {
        //            new SqlParameter("@Sell_ID", SqlDbType.Int,4)
        //    };
        //    parameters[0].Value = Sell_ID;

        //    Sell model = new Sell();
        //    DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
        //    if (ds.Tables[0].Rows.Count > 0)
        //    {
        //        return DataRowToModel(ds.Tables[0].Rows[0]);
        //    }
        //    else
        //    {
        //        return null;
        //    }
        //}

        public void SaveSellOdd(Sell sell, List <SellDetail> sdl, SellProcess sp, bool inStock)
        {
            StringBuilder strSql    = new StringBuilder();
            Hashtable     hashtable = new Hashtable();

            //销售主表操作
            strSql.Append("insert into T_Sell(");
            strSql.Append("Sell_Code,Sell_Type,Sell_Date,Sell_TransportType,Sell_Review,Sell_ChangeDate,Sell_Operation,Sell_Auditman,Sell_Remark,Sell_Satetyone,Sell_Satetytwo,");
            strSql.Append("Sell_IsPay,Sell_IsPutSto,Sell_PayMathod,Sell_GetDate,Sell_Logistics,Sell_LogCode,Sell_LogPhone,Sell_Clear,Sell_OddMoney,Sell_AccountCode,Sell_InMoney,Sell_LastMoney,Sell_Address,Sell_ClientName,Sell_CliPhone,Sell_Salesman,Sell_LinkMan,Sell_OddStatus,Sell_jiajiState,Sell_zuiwanshijian,Sell_fukuanfangshi)");
            strSql.Append(" values (");
            strSql.Append("@Sell_Code,@Sell_Type,@Sell_Date,@Sell_TransportType,@Sell_Review,@Sell_ChangeDate,@Sell_Operation,@Sell_Auditman,@Sell_Remark,@Sell_Satetyone,@Sell_Satetytwo,");
            strSql.Append("@Sell_IsPay,@Sell_IsPutSto,@Sell_PayMathod,@Sell_GetDate,@Sell_Logistics,@Sell_LogCode,@Sell_LogPhone,@Sell_Clear,@Sell_OddMoney,@Sell_AccountCode,@Sell_InMoney,@Sell_LastMoney,@Sell_Address,@Sell_ClientName,@Sell_CliPhone,@Sell_Salesman,@Sell_LinkMan,@Sell_OddStatus,@Sell_jiajiState,@Sell_zuiwanshijian,@Sell_fukuanfangshi)");

            SqlParameter[] parameters =
            {
                new SqlParameter("@Sell_Code",          SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Type",          SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Date",          SqlDbType.DateTime),
                new SqlParameter("@Sell_TransportType", SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Review",        SqlDbType.Int,         4),
                new SqlParameter("@Sell_ChangeDate",    SqlDbType.DateTime),
                new SqlParameter("@Sell_Operation",     SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Auditman",      SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Remark",        SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Satetyone",     SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Satetytwo",     SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_IsPay",         SqlDbType.Int,         4),
                new SqlParameter("@Sell_IsPutSto",      SqlDbType.Int,         4),
                new SqlParameter("@Sell_PayMathod",     SqlDbType.Int,         4),
                new SqlParameter("@Sell_GetDate",       SqlDbType.DateTime),
                new SqlParameter("@Sell_Logistics",     SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_LogCode",       SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_LogPhone",      SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Clear",         SqlDbType.Int,         4),
                new SqlParameter("@Sell_OddMoney",      SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_AccountCode",   SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_InMoney",       SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_LastMoney",     SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Address",       SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_ClientName",    SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_CliPhone",      SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_Salesman",      SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_LinkMan",       SqlDbType.NVarChar,  512),
                new SqlParameter("@Sell_OddStatus",     SqlDbType.Int,         4),
                new SqlParameter("@Sell_jiajiState",    SqlDbType.Int,         4),
                new SqlParameter("@Sell_zuiwanshijian", SqlDbType.DateTime),
                new SqlParameter("@Sell_fukuanfangshi", SqlDbType.NVarChar, 512)
            };
            parameters[0].Value  = sell.Sell_Code;
            parameters[1].Value  = sell.Sell_Type;
            parameters[2].Value  = sell.Sell_Date;
            parameters[3].Value  = sell.Sell_TransportType;
            parameters[4].Value  = sell.Sell_Review;
            parameters[5].Value  = sell.Sell_ChangeDate;
            parameters[6].Value  = sell.Sell_Operation;
            parameters[7].Value  = sell.Sell_Auditman;
            parameters[8].Value  = sell.Sell_Remark;
            parameters[9].Value  = sell.Sell_Satetyone;
            parameters[10].Value = sell.Sell_Satetytwo;
            parameters[11].Value = sell.Sell_IsPay;
            parameters[12].Value = sell.Sell_IsPutSto;
            parameters[13].Value = sell.Sell_PayMathod;
            parameters[14].Value = sell.Sell_GetDate;
            parameters[15].Value = sell.Sell_Logistics;
            parameters[16].Value = sell.Sell_LogCode;
            parameters[17].Value = sell.Sell_LogPhone;
            parameters[18].Value = sell.Sell_Clear;
            parameters[19].Value = sell.Sell_OddMoney;
            parameters[20].Value = sell.Sell_AccountCode;
            parameters[21].Value = sell.Sell_InMoney;
            parameters[22].Value = sell.Sell_LastMoney;
            parameters[23].Value = sell.Sell_Address;
            parameters[24].Value = sell.Sell_ClientName;
            parameters[25].Value = sell.Sell_CliPhone;
            parameters[26].Value = sell.Sell_Salesman;
            parameters[27].Value = sell.Sell_LinkMan;
            parameters[28].Value = sell.Sell_OddStatus;
            parameters[29].Value = sell.Sell_jiajiState;
            parameters[30].Value = sell.Sell_zuiwanshijian;
            parameters[31].Value = sell.Sell_fukuanfangshi;

            //添加到列表中
            hashtable.Add(strSql.ToString(), parameters);

            //销售明细表操作
            string moresqlstr = "";                                       //该sql将插入多行
            List <SqlParameter[]> paraList = new List <SqlParameter[]>(); //多行的值参数列表

            strSql = new StringBuilder();
            strSql.Append("insert into T_SellDetail(");
            strSql.Append("Sell_Code,Sell_StockCode,Sell_StockName,Sell_LineCode,Sell_MaID,Sell_MaName,Sell_Model,Sell_Unit,Sell_CurNumber,");
            strSql.Append("Sell_ReNumber,Sell_LostNumber,Sell_DiscountAPrice,Sell_Discount,Sell_DiscountBPrice,Sell_Money,Sell_Clear,Sell_Safetyone,Sell_Safetytwo,Sell_Remark)");
            strSql.Append(" values (");
            strSql.Append("@Sell_Code,@Sell_StockCode,@Sell_StockName,@Sell_LineCode,@Sell_MaID,@Sell_MaName,@Sell_Model,@Sell_Unit,@Sell_CurNumber,");
            strSql.Append("@Sell_ReNumber,@Sell_LostNumber,@Sell_DiscountAPrice,@Sell_Discount,@Sell_DiscountBPrice,@Sell_Money,@Sell_Clear,@Sell_Safetyone,@Sell_Safetytwo,@Sell_Remark)");
            moresqlstr = strSql.ToString();

            foreach (var sd in sdl)
            {
                SqlParameter[] parametersDetail =
                {
                    new SqlParameter("@Sell_Code",           SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_StockCode",      SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_StockName",      SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_LineCode",       SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_MaID",           SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_MaName",         SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_Model",          SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_Unit",           SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_CurNumber",      SqlDbType.Decimal),
                    new SqlParameter("@Sell_ReNumber",       SqlDbType.Decimal),
                    new SqlParameter("@Sell_LostNumber",     SqlDbType.Decimal),
                    new SqlParameter("@Sell_DiscountAPrice", SqlDbType.Decimal),
                    new SqlParameter("@Sell_Discount",       SqlDbType.Decimal),
                    new SqlParameter("@Sell_DiscountBPrice", SqlDbType.Decimal),
                    new SqlParameter("@Sell_Money",          SqlDbType.Decimal),
                    new SqlParameter("@Sell_Clear",          SqlDbType.Int,        4),
                    new SqlParameter("@Sell_Safetyone",      SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_Safetytwo",      SqlDbType.NVarChar, 512),
                    new SqlParameter("@Sell_Remark",         SqlDbType.NVarChar, 1024)
                };
                parametersDetail[0].Value  = sd.Sell_Code;
                parametersDetail[1].Value  = sd.Sell_StockCode;
                parametersDetail[2].Value  = sd.Sell_StockName;
                parametersDetail[3].Value  = sd.Sell_LineCode;
                parametersDetail[4].Value  = sd.Sell_MaID;
                parametersDetail[5].Value  = sd.Sell_MaName;
                parametersDetail[6].Value  = sd.Sell_Model;
                parametersDetail[7].Value  = sd.Sell_Unit;
                parametersDetail[8].Value  = sd.Sell_CurNumber;
                parametersDetail[9].Value  = sd.Sell_ReNumber;
                parametersDetail[10].Value = sd.Sell_LostNumber;
                parametersDetail[11].Value = sd.Sell_DiscountAPrice;
                parametersDetail[12].Value = sd.Sell_Discount;
                parametersDetail[13].Value = sd.Sell_DiscountBPrice;
                parametersDetail[14].Value = sd.Sell_Money;
                parametersDetail[15].Value = sd.Sell_Clear;
                parametersDetail[16].Value = sd.Sell_Safetyone;
                parametersDetail[17].Value = sd.Sell_Safetytwo;
                parametersDetail[18].Value = sd.Sell_Remark;
                //添加到列表中
                paraList.Add(parametersDetail);
            }
            //操作过程表操作
            strSql = new StringBuilder();
            strSql.Append("insert into T_SellProcess(");
            strSql.Append("SP_Code,SP_SellLineno,SP_Datetime,SP_Opt,SP_Ope,SP_Remark,SP_Clear )");

            strSql.Append(" values (");
            strSql.Append("@SP_Code,@SP_SellLineno,@SP_Datetime,@SP_Opt,@SP_Ope,@SP_Remark,@SP_Clear)");

            SqlParameter[] parametersProcess =
            {
                new SqlParameter("@SP_Code",       SqlDbType.NVarChar,  512),
                new SqlParameter("@SP_SellLineno", SqlDbType.NVarChar,  512),
                new SqlParameter("@SP_Datetime",   SqlDbType.DateTime),
                new SqlParameter("@SP_Opt",        SqlDbType.NVarChar,  512),
                new SqlParameter("@SP_Ope",        SqlDbType.NVarChar,  512),
                new SqlParameter("@SP_Remark",     SqlDbType.NVarChar,  512),
                new SqlParameter("@SP_Clear",      SqlDbType.NVarChar, 512)
            };
            parametersProcess[0].Value = sp.Sp_Code;
            parametersProcess[1].Value = sp.Sp_SellLineno;
            parametersProcess[2].Value = sp.Sp_Datetime;
            parametersProcess[3].Value = sp.Sp_Opt;
            parametersProcess[4].Value = sp.Sp_Ope;
            parametersProcess[5].Value = sp.Sp_Remark;
            parametersProcess[6].Value = sp.Sp_Clear;
            //添加到列表中
            hashtable.Add(strSql.ToString(), parametersProcess);

            if (inStock)
            {
                //入库单生成
            }

            DbHelperSQL.ExecuteSqlTran(hashtable, moresqlstr, paraList);
        }