示例#1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_document model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_document(");
            strSql.Append("doc_Code,doc_Name,doc_Guid,direct_Id,doc_Type,doc_URL,doc_Size,doc_CreateUser,doc_UpdateUser,doc_CreateDate,doc_UpdateDate,isDelete,doc_Revo,doc_Source,doc_Path,temp1,temp2,remark,doc_Status,doc_KeyWord)");
            strSql.Append(" values (");
            strSql.Append("@doc_Code,@doc_Name,@doc_Guid,@direct_Id,@doc_Type,@doc_URL,@doc_Size,@doc_CreateUser,@doc_UpdateUser,@doc_CreateDate,@doc_UpdateDate,@isDelete,@doc_Revo,@doc_Source,@doc_Path,@temp1,@temp2,@remark,@doc_Status,@doc_KeyWord)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@doc_Code",       SqlDbType.NVarChar,  100),
                new SqlParameter("@doc_Name",       SqlDbType.NVarChar,  100),
                new SqlParameter("@doc_Guid",       SqlDbType.VarChar,   100),
                new SqlParameter("@direct_Id",      SqlDbType.Int,         4),
                new SqlParameter("@doc_Type",       SqlDbType.VarChar,    10),
                new SqlParameter("@doc_URL",        SqlDbType.NVarChar,   -1),
                new SqlParameter("@doc_Size",       SqlDbType.VarChar,   100),
                new SqlParameter("@doc_CreateUser", SqlDbType.Int,         4),
                new SqlParameter("@doc_UpdateUser", SqlDbType.Int,         4),
                new SqlParameter("@doc_CreateDate", SqlDbType.DateTime),
                new SqlParameter("@doc_UpdateDate", SqlDbType.DateTime),
                new SqlParameter("@isDelete",       SqlDbType.Bit,         1),
                new SqlParameter("@doc_Revo",       SqlDbType.VarChar,   100),
                new SqlParameter("@doc_Source",     SqlDbType.VarChar,   300),
                new SqlParameter("@doc_Path",       SqlDbType.NVarChar,   -1),
                new SqlParameter("@temp1",          SqlDbType.NVarChar,  300),
                new SqlParameter("@temp2",          SqlDbType.NVarChar,  300),
                new SqlParameter("@remark",         SqlDbType.Text),
                new SqlParameter("@doc_Status",     SqlDbType.Int,         4),
                new SqlParameter("@doc_KeyWord",    SqlDbType.NVarChar, 100)
            };
            parameters[0].Value  = model.doc_Code;
            parameters[1].Value  = model.doc_Name;
            parameters[2].Value  = model.doc_Guid;
            parameters[3].Value  = model.direct_Id;
            parameters[4].Value  = model.doc_Type;
            parameters[5].Value  = model.doc_URL;
            parameters[6].Value  = model.doc_Size;
            parameters[7].Value  = model.doc_CreateUser;
            parameters[8].Value  = model.doc_UpdateUser;
            parameters[9].Value  = model.doc_CreateDate;
            parameters[10].Value = model.doc_UpdateDate;
            parameters[11].Value = model.isDelete;
            parameters[12].Value = model.doc_Revo;
            parameters[13].Value = model.doc_Source;
            parameters[14].Value = model.doc_Path;
            parameters[15].Value = model.temp1;
            parameters[16].Value = model.temp2;
            parameters[17].Value = model.remark;
            parameters[18].Value = model.doc_Status;
            parameters[19].Value = model.doc_KeyWord;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#2
0
 public object ValidLimitTeacher(int classId)
 {
     return(DbHelperSQL.GetSingle("select LimitTeacherIds from ClassPlan where ClassId = @0", classId));
 }
示例#3
0
        /// <summary>
        /// 增加一条数据及其子表
        /// </summary>
        public int Add(Model.channel model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "channel(");
                        strSql.Append("category_id,name,title,is_albums,is_attach,is_group_price,page_size,sort_id)");
                        strSql.Append(" values (");
                        strSql.Append("@category_id,@name,@title,@is_albums,@is_attach,@is_group_price,@page_size,@sort_id)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@category_id",    SqlDbType.Int,       4),
                            new SqlParameter("@name",           SqlDbType.VarChar,  50),
                            new SqlParameter("@title",          SqlDbType.VarChar, 100),
                            new SqlParameter("@is_albums",      SqlDbType.TinyInt,   1),
                            new SqlParameter("@is_attach",      SqlDbType.TinyInt,   1),
                            new SqlParameter("@is_group_price", SqlDbType.TinyInt,   1),
                            new SqlParameter("@page_size",      SqlDbType.Int,       4),
                            new SqlParameter("@sort_id",        SqlDbType.Int,       4),
                            new SqlParameter("@ReturnValue",    SqlDbType.Int)
                        };
                        parameters[0].Value = model.category_id;
                        parameters[1].Value = model.name;
                        parameters[2].Value = model.title;
                        parameters[3].Value = model.is_albums;
                        parameters[4].Value = model.is_attach;
                        parameters[5].Value = model.is_group_price;
                        parameters[6].Value = model.page_size;
                        parameters[7].Value = model.sort_id;
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务
                        model.id = Convert.ToInt32(obj);

                        //扩展字段
                        if (model.channel_fields != null)
                        {
                            StringBuilder strSql2;
                            foreach (Model.channel_field modelt in model.channel_fields)
                            {
                                strSql2 = new StringBuilder();
                                strSql2.Append("insert into " + databaseprefix + "channel_field(");
                                strSql2.Append("channel_id,field_id)");
                                strSql2.Append(" values (");
                                strSql2.Append("@channel_id,@field_id)");
                                SqlParameter[] parameters2 =
                                {
                                    new SqlParameter("@channel_id", SqlDbType.Int, 4),
                                    new SqlParameter("@field_id",   SqlDbType.Int, 4)
                                };
                                parameters2[0].Value = model.id;
                                parameters2[1].Value = modelt.field_id;
                                DbHelperSQL.ExecuteSql(conn, trans, strSql2.ToString(), parameters2);
                            }
                        }

                        //添加视图
                        StringBuilder strSql3 = new StringBuilder();
                        strSql3.Append("CREATE VIEW view_channel_" + model.name + " as");
                        strSql3.Append(" SELECT " + databaseprefix + "article.*");
                        if (model.channel_fields != null)
                        {
                            foreach (Model.channel_field modelt in model.channel_fields)
                            {
                                Model.article_attribute_field fieldModel = new DAL.article_attribute_field(databaseprefix).GetModel(modelt.field_id);
                                if (fieldModel != null)
                                {
                                    strSql3.Append("," + databaseprefix + "article_attribute_value." + fieldModel.name);
                                }
                            }
                        }
                        strSql3.Append(" FROM " + databaseprefix + "article_attribute_value INNER JOIN");
                        strSql3.Append(" " + databaseprefix + "article ON " + databaseprefix + "article_attribute_value.article_id = " + databaseprefix + "article.id");
                        strSql3.Append(" WHERE " + databaseprefix + "article.channel_id=" + model.id);
                        DbHelperSQL.ExecuteSql(conn, trans, strSql3.ToString());

                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
示例#4
0
文件: users.cs 项目: zhanglg40/SANKE
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.users model)
        {
            try
            {
                StringBuilder strSql = new StringBuilder();
                strSql.Append("insert into " + databaseprefix + "users(");
                strSql.Append("group_id,express_id,user_name,password,salt,email,nick_name,avatar,sex,birthday,telphone,mobile,qq,address,safe_question,safe_answer,amount,point,exp,status,reg_time,reg_ip,wechat,companyid,taxid,ref1,ref2,ref3)");
                strSql.Append(" values (");
                strSql.Append("@group_id,@express_id,@user_name,@password,@salt,@email,@nick_name,@avatar,@sex,@birthday,@telphone,@mobile,@qq,@address,@safe_question,@safe_answer,@amount,@point,@exp,@status,@reg_time,@reg_ip,@wechat,@companyid,@taxid,@ref1,@ref2,@ref3)");
                strSql.Append(";select @@IDENTITY");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@group_id",      SqlDbType.Int,         4),
                    new SqlParameter("@express_id",    SqlDbType.Int,         4),
                    new SqlParameter("@user_name",     SqlDbType.NVarChar,  100),
                    new SqlParameter("@password",      SqlDbType.NVarChar,  100),
                    new SqlParameter("@salt",          SqlDbType.NVarChar,   20),
                    new SqlParameter("@email",         SqlDbType.NVarChar,   50),
                    new SqlParameter("@nick_name",     SqlDbType.NVarChar,  100),
                    new SqlParameter("@avatar",        SqlDbType.NVarChar,  255),
                    new SqlParameter("@sex",           SqlDbType.NVarChar,   20),
                    new SqlParameter("@birthday",      SqlDbType.DateTime),
                    new SqlParameter("@telphone",      SqlDbType.NVarChar,   50),
                    new SqlParameter("@mobile",        SqlDbType.NVarChar,   20),
                    new SqlParameter("@qq",            SqlDbType.NVarChar,   30),
                    new SqlParameter("@address",       SqlDbType.NVarChar,  255),
                    new SqlParameter("@safe_question", SqlDbType.NVarChar,  255),
                    new SqlParameter("@safe_answer",   SqlDbType.NVarChar,  255),
                    new SqlParameter("@amount",        SqlDbType.Decimal,     5),
                    new SqlParameter("@point",         SqlDbType.Int,         4),
                    new SqlParameter("@exp",           SqlDbType.Int,         4),
                    new SqlParameter("@status",        SqlDbType.TinyInt,     1),
                    new SqlParameter("@reg_time",      SqlDbType.DateTime),
                    new SqlParameter("@reg_ip",        SqlDbType.NVarChar,   30),
                    new SqlParameter("@wechat",        SqlDbType.VarChar,    50),
                    new SqlParameter("@companyid",     SqlDbType.VarChar,   100),
                    new SqlParameter("@taxid",         SqlDbType.VarChar,   100),
                    new SqlParameter("@ref1",          SqlDbType.VarChar,   100),
                    new SqlParameter("@ref2",          SqlDbType.VarChar,   100),
                    new SqlParameter("@ref3",          SqlDbType.VarChar, 100)
                };
                parameters[0].Value  = model.group_id;
                parameters[1].Value  = model.express_id;
                parameters[2].Value  = model.user_name;
                parameters[3].Value  = model.password;
                parameters[4].Value  = model.salt;
                parameters[5].Value  = model.email;
                parameters[6].Value  = model.nick_name;
                parameters[7].Value  = model.avatar;
                parameters[8].Value  = model.sex;
                parameters[9].Value  = model.birthday;
                parameters[10].Value = model.telphone;
                parameters[11].Value = model.mobile;

                parameters[12].Value = model.qq;
                parameters[13].Value = model.address;
                parameters[14].Value = model.safe_question;
                parameters[15].Value = model.safe_answer;
                parameters[16].Value = model.amount;
                parameters[17].Value = model.point;
                parameters[18].Value = model.exp;
                parameters[19].Value = model.status;
                parameters[20].Value = model.reg_time;
                parameters[21].Value = model.reg_ip;
                parameters[22].Value = model.wechat;
                parameters[23].Value = model.companyid;
                parameters[24].Value = model.taxid;
                parameters[25].Value = model.ref1;
                parameters[26].Value = model.ref2;
                parameters[27].Value = model.ref3;
                object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
                if (obj == null)
                {
                    return(0);
                }
                else
                {
                    return(Convert.ToInt32(obj));
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#5
0
        public int GetRecordCount()
        {
            string sql = "select count(*) from Books";

            return(Convert.ToInt32(DbHelperSQL.GetSingle(sql)));
        }
示例#6
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Client model)
        {
            StringBuilder 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)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                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)
            };
            parameters[0].Value  = model.Cli_Code;
            parameters[1].Value  = model.Cli_zhiwen;
            parameters[2].Value  = model.Cli_Name;
            parameters[3].Value  = model.Cli_PicName;
            parameters[4].Value  = model.Cli_Phone;
            parameters[5].Value  = model.Cli_PhoneTwo;
            parameters[6].Value  = model.Cli_faxes;
            parameters[7].Value  = model.Cli_CityCode;
            parameters[8].Value  = model.Cli_area;
            parameters[9].Value  = model.Cli_Address;
            parameters[10].Value = model.Cli_LinkMan;
            parameters[11].Value = model.Cli_Company;
            parameters[12].Value = model.Cli_TypeCode;
            parameters[13].Value = model.Cli_TypeName;
            parameters[14].Value = model.Cli_DiscountCode;
            parameters[15].Value = model.Cli_Bankaccounts;
            parameters[16].Value = model.Cli_OpenBank;
            parameters[17].Value = model.Cli_Olddata;
            parameters[18].Value = model.Cli_Oldreturn;
            parameters[19].Value = model.Cli_Newoutdata;
            parameters[20].Value = model.Cli_Newintodata;
            parameters[21].Value = model.Cli_Createdata;
            parameters[22].Value = model.Cli_Limit;
            parameters[23].Value = model.Cli_RemainLimit;
            parameters[24].Value = model.Cli_ClearLimitdate;
            parameters[25].Value = model.Cli_ShouldMoney;
            parameters[26].Value = model.Cli_GetMoney;
            parameters[27].Value = model.Cli_PreMoney;
            parameters[28].Value = model.Cli_Remark;
            parameters[29].Value = model.Cli_safetone;
            parameters[30].Value = model.Cli_safettwo;
            parameters[31].Value = model.Cli_Enable;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Material model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into T_Material(");
            strSql.Append("Ma_PicName,Ma_Name,Ma_Model,Ma_RFID,Ma_Barcode,Ma_Code,Ma_TypeID,Ma_TypeName,Ma_Price,Ma_PriceA,Ma_PriceB,Ma_PriceC,Ma_PriceD,Ma_PriceE,Ma_CreateDate,Ma_Supplier,Ma_SupID,Ma_zhujima,Ma_Unit,Ma_InPrice,Ma_OutPrice,Ma_InDate,Ma_Remark,Ma_Enable,Ma_Clear,Ma_Safeyone,Ma_Safetytwo)");
            strSql.Append(" values (");
            strSql.Append("@Ma_PicName,@Ma_Name,@Ma_Model,@Ma_RFID,@Ma_Barcode,@Ma_Code,@Ma_TypeID,@Ma_TypeName,@Ma_Price,@Ma_PriceA,@Ma_PriceB,@Ma_PriceC,@Ma_PriceD,@Ma_PriceE,@Ma_CreateDate,@Ma_Supplier,@Ma_SupID,@Ma_zhujima,@Ma_Unit,@Ma_InPrice,@Ma_OutPrice,@Ma_InDate,@Ma_Remark,@Ma_Enable,@Ma_Clear,@Ma_Safeyone,@Ma_Safetytwo)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Ma_PicName",    SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Name",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Model",      SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_RFID",       SqlDbType.NVarChar,  1024),
                new SqlParameter("@Ma_Barcode",    SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Code",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_TypeID",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_TypeName",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Price",      SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_PriceA",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_PriceB",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_PriceC",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_PriceD",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_PriceE",     SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_CreateDate", SqlDbType.DateTime),
                new SqlParameter("@Ma_Supplier",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_SupID",      SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_zhujima",    SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Unit",       SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_InPrice",    SqlDbType.Decimal),
                new SqlParameter("@Ma_OutPrice",   SqlDbType.Decimal),
                new SqlParameter("@Ma_InDate",     SqlDbType.DateTime),
                new SqlParameter("@Ma_Remark",     SqlDbType.NVarChar,  1024),
                new SqlParameter("@Ma_Enable",     SqlDbType.Int,          4),
                new SqlParameter("@Ma_Clear",      SqlDbType.Int,          4),
                new SqlParameter("@Ma_Safeyone",   SqlDbType.NVarChar,   512),
                new SqlParameter("@Ma_Safetytwo",  SqlDbType.NVarChar, 512)
            };
            parameters[0].Value  = model.Ma_PicName;
            parameters[1].Value  = model.Ma_Name;
            parameters[2].Value  = model.Ma_Model;
            parameters[3].Value  = model.Ma_RFID;
            parameters[4].Value  = model.Ma_Barcode;
            parameters[5].Value  = model.Ma_Code;
            parameters[6].Value  = model.Ma_TypeID;
            parameters[7].Value  = model.Ma_TypeName;
            parameters[8].Value  = model.Ma_Price;
            parameters[9].Value  = model.Ma_PriceA;
            parameters[10].Value = model.Ma_PriceB;
            parameters[11].Value = model.Ma_PriceC;
            parameters[12].Value = model.Ma_PriceD;
            parameters[13].Value = model.Ma_PriceE;
            parameters[14].Value = model.Ma_CreateDate;
            parameters[15].Value = model.Ma_Supplier;
            parameters[16].Value = model.Ma_SupID;
            parameters[17].Value = model.Ma_zhujima;
            parameters[18].Value = model.Ma_Unit;
            parameters[19].Value = model.Ma_InPrice;
            parameters[20].Value = model.Ma_OutPrice;
            parameters[21].Value = model.Ma_InDate;
            parameters[22].Value = model.Ma_Remark;
            parameters[23].Value = model.Ma_Enable;
            parameters[24].Value = model.Ma_Clear;
            parameters[25].Value = model.Ma_Safeyone;
            parameters[26].Value = model.Ma_Safetytwo;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_Drug model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_Drug(");
            strSql.Append("drugName,drugCode,drugType,unit,productDate,validDate,amount,manufacturers,cabinet,registrant,riskLevel,isMSDS,remark,createUser,createDate,updateUser,updateDate,temp1,temp2,un,dsm,purity)");
            strSql.Append(" values (");
            strSql.Append("@drugName,@drugCode,@drugType,@unit,@productDate,@validDate,@amount,@manufacturers,@cabinet,@registrant,@riskLevel,@isMSDS,@remark,@createUser,@createDate,@updateUser,@updateDate,@temp1,@temp2,@un,@dsm,@purity)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@drugName",      SqlDbType.NVarChar,  200),
                new SqlParameter("@drugCode",      SqlDbType.VarChar,   300),
                new SqlParameter("@drugType",      SqlDbType.Int,         4),
                new SqlParameter("@unit",          SqlDbType.Int,         4),
                new SqlParameter("@productDate",   SqlDbType.DateTime),
                new SqlParameter("@validDate",     SqlDbType.DateTime),
                new SqlParameter("@amount",        SqlDbType.Decimal,     9),
                new SqlParameter("@manufacturers", SqlDbType.NVarChar,  500),
                new SqlParameter("@cabinet",       SqlDbType.Int,         4),
                new SqlParameter("@registrant",    SqlDbType.Int,         4),
                new SqlParameter("@riskLevel",     SqlDbType.NVarChar,   50),
                new SqlParameter("@isMSDS",        SqlDbType.Bit,         1),
                new SqlParameter("@remark",        SqlDbType.NVarChar,   -1),
                new SqlParameter("@createUser",    SqlDbType.Int,         4),
                new SqlParameter("@createDate",    SqlDbType.DateTime),
                new SqlParameter("@updateUser",    SqlDbType.Int,         4),
                new SqlParameter("@updateDate",    SqlDbType.DateTime),
                new SqlParameter("@temp1",         SqlDbType.Text),
                new SqlParameter("@temp2",         SqlDbType.Text),
                new SqlParameter("@un",            SqlDbType.NVarChar,   50),
                new SqlParameter("@dsm",           SqlDbType.NVarChar,   50),
                new SqlParameter("@purity",        SqlDbType.Int,         4),
            };
            parameters[0].Value  = model.drugName;
            parameters[1].Value  = model.drugCode;
            parameters[2].Value  = model.drugType;
            parameters[3].Value  = model.unit;
            parameters[4].Value  = model.productDate;
            parameters[5].Value  = model.validDate;
            parameters[6].Value  = model.amount;
            parameters[7].Value  = model.manufacturers;
            parameters[8].Value  = model.cabinet;
            parameters[9].Value  = model.registrant;
            parameters[10].Value = model.riskLevel;
            parameters[11].Value = model.isMSDS;
            parameters[12].Value = model.remark;
            parameters[13].Value = model.createUser;
            parameters[14].Value = model.createDate;
            parameters[15].Value = model.updateUser;
            parameters[16].Value = model.updateDate;
            parameters[17].Value = model.temp1;
            parameters[18].Value = model.temp2;
            parameters[19].Value = model.un;
            parameters[20].Value = model.dsm;
            parameters[21].Value = model.purity;
            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
示例#9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.navigation model)
        {
            using (SqlConnection conn = new SqlConnection(DbHelperSQL.connectionString))
            {
                conn.Open();
                using (SqlTransaction trans = conn.BeginTransaction())
                {
                    try
                    {
                        StringBuilder strSql = new StringBuilder();
                        strSql.Append("insert into " + databaseprefix + "navigation(");
                        strSql.Append("nav_type,name,title,sub_title,link_url,sort_id,is_lock,remark,parent_id,class_list,class_layer,channel_id,action_type,is_sys)");
                        strSql.Append(" values (");
                        strSql.Append("@nav_type,@name,@title,@sub_title,@link_url,@sort_id,@is_lock,@remark,@parent_id,@class_list,@class_layer,@channel_id,@action_type,@is_sys)");
                        strSql.Append(";select @@IDENTITY");
                        SqlParameter[] parameters =
                        {
                            new SqlParameter("@nav_type",    SqlDbType.NVarChar,  50),
                            new SqlParameter("@name",        SqlDbType.NVarChar,  50),
                            new SqlParameter("@title",       SqlDbType.NVarChar, 100),
                            new SqlParameter("@sub_title",   SqlDbType.NVarChar, 100),
                            new SqlParameter("@link_url",    SqlDbType.NVarChar, 255),
                            new SqlParameter("@sort_id",     SqlDbType.Int,        4),
                            new SqlParameter("@is_lock",     SqlDbType.TinyInt,    1),
                            new SqlParameter("@remark",      SqlDbType.NVarChar, 500),
                            new SqlParameter("@parent_id",   SqlDbType.Int,        4),
                            new SqlParameter("@class_list",  SqlDbType.NVarChar, 500),
                            new SqlParameter("@class_layer", SqlDbType.Int,        4),
                            new SqlParameter("@channel_id",  SqlDbType.Int,        4),
                            new SqlParameter("@action_type", SqlDbType.NVarChar, 500),
                            new SqlParameter("@is_sys",      SqlDbType.TinyInt, 1)
                        };
                        parameters[0].Value  = model.nav_type;
                        parameters[1].Value  = model.name;
                        parameters[2].Value  = model.title;
                        parameters[3].Value  = model.sub_title;
                        parameters[4].Value  = model.link_url;
                        parameters[5].Value  = model.sort_id;
                        parameters[6].Value  = model.is_lock;
                        parameters[7].Value  = model.remark;
                        parameters[8].Value  = model.parent_id;
                        parameters[9].Value  = model.class_list;
                        parameters[10].Value = model.class_layer;
                        parameters[11].Value = model.channel_id;
                        parameters[12].Value = model.action_type;
                        parameters[13].Value = model.is_sys;
                        object obj = DbHelperSQL.GetSingle(conn, trans, strSql.ToString(), parameters); //带事务

                        model.id = Convert.ToInt32(obj);                                                //得到刚插入的新ID
                        if (model.parent_id > 0)
                        {
                            Model.navigation model2 = GetModel(conn, trans, model.parent_id); //带事务
                            model.class_list  = model2.class_list + model.id + ",";
                            model.class_layer = model2.class_layer + 1;
                        }
                        else
                        {
                            model.class_list  = "," + model.id + ",";
                            model.class_layer = 1;
                        }
                        //修改节点列表和深度
                        DbHelperSQL.ExecuteSql(conn, trans, "update " + databaseprefix + "navigation set class_list='" + model.class_list + "', class_layer=" + model.class_layer + " where id=" + model.id); //带事务
                        //如无异常则提交事务
                        trans.Commit();
                    }
                    catch
                    {
                        trans.Rollback();
                        return(0);
                    }
                }
            }
            return(model.id);
        }
示例#10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(tb_DrugCheck model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_DrugCheck(");
            strSql.Append("drugCode,drugName,drugId,drugInId,drugOutId,outDate,unit,amountIN,amountOUT,amount,riskLevel,checkDate,checkUser,checkUserId,auditstatus,auditUser,auditUserId,remark,isDelete,createUser,createDate,updateUser,updateDate)");
            strSql.Append(" values (");
            strSql.Append("@drugCode,@drugName,@drugId,@drugInId,@drugOutId,@outDate,@unit,@amountIN,@amountOUT,@amount,@riskLevel,@checkDate,@checkUser,@checkUserId,@auditstatus,@auditUser,@auditUserId,@remark,@isDelete,@createUser,@createDate,@updateUser,@updateDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@drugCode",    SqlDbType.NVarChar,  -1),
                new SqlParameter("@drugName",    SqlDbType.NVarChar,  -1),
                new SqlParameter("@drugId",      SqlDbType.Int,        4),
                new SqlParameter("@drugInId",    SqlDbType.Int,        4),
                new SqlParameter("@drugOutId",   SqlDbType.Int,        4),
                new SqlParameter("@outDate",     SqlDbType.DateTime),
                new SqlParameter("@unit",        SqlDbType.NVarChar,  -1),
                new SqlParameter("@amountIN",    SqlDbType.Int,        4),
                new SqlParameter("@amountOUT",   SqlDbType.Int,        4),
                new SqlParameter("@amount",      SqlDbType.Int,        4),
                new SqlParameter("@riskLevel",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@checkDate",   SqlDbType.DateTime),
                new SqlParameter("@checkUser",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@checkUserId", SqlDbType.Int,        4),
                new SqlParameter("@auditstatus", SqlDbType.NVarChar,  -1),
                new SqlParameter("@auditUser",   SqlDbType.NVarChar,  -1),
                new SqlParameter("@auditUserId", SqlDbType.NVarChar,  -1),
                new SqlParameter("@remark",      SqlDbType.NVarChar,  -1),
                new SqlParameter("@isDelete",    SqlDbType.Bit,        1),
                new SqlParameter("@createUser",  SqlDbType.Int,        4),
                new SqlParameter("@createDate",  SqlDbType.DateTime),
                new SqlParameter("@updateUser",  SqlDbType.Int,        4),
                new SqlParameter("@updateDate",  SqlDbType.DateTime)
            };
            parameters[0].Value  = model.drugCode;
            parameters[1].Value  = model.drugName;
            parameters[2].Value  = model.drugId;
            parameters[3].Value  = model.drugInId;
            parameters[4].Value  = model.drugOutId;
            parameters[5].Value  = model.outDate;
            parameters[6].Value  = model.unit;
            parameters[7].Value  = model.amountIN;
            parameters[8].Value  = model.amountOUT;
            parameters[9].Value  = model.amount;
            parameters[10].Value = model.riskLevel;
            parameters[11].Value = model.checkDate;
            parameters[12].Value = model.checkUser;
            parameters[13].Value = model.checkUserId;
            parameters[14].Value = model.auditstatus;
            parameters[15].Value = model.auditUser;
            parameters[16].Value = model.auditUserId;
            parameters[17].Value = model.remark;
            parameters[18].Value = model.isDelete;
            parameters[19].Value = model.createUser;
            parameters[20].Value = model.createDate;
            parameters[21].Value = model.updateUser;
            parameters[22].Value = model.updateDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }