Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [Users] set ");
            strSql.Append("[UserName]=@UserName, [UserPwd]=@UserPwd, [Phone]=@Phone, [Mail]=@Mail, [Permission]=@Permission   ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.ID.ToString() == null)
            {
                h.AddParameter("@ID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ID", model.ID);
            }
            if (model.UserName == null)
            {
                h.AddParameter("@UserName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserName", model.UserName);
            }
            if (model.UserPwd == null)
            {
                h.AddParameter("@UserPwd", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserPwd", model.UserPwd);
            }
            if (model.Phone == null)
            {
                h.AddParameter("@Phone", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Phone", model.Phone);
            }
            if (model.Mail == null)
            {
                h.AddParameter("@Mail", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Mail", model.Mail);
            }
            if (model.Permission == null)
            {
                h.AddParameter("@Permission", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Permission", model.Permission);
            }
            return(h.ExecuteNonQuery());
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Tools_entitys model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [Tools_entitys] set ");
            strSql.Append("[Code]=@Code, [SeqID]=@SeqID, [BillNo]=@BillNo, [RegDate]=@RegDate, [UserCount]=@UserCount, [Location]=@Location   ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Code == null)
            {
                h.AddParameter("@Code", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Code", model.Code);
            }
            if (model.SeqID == null)
            {
                h.AddParameter("@SeqID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SeqID", model.SeqID);
            }
            if (model.BillNo == null)
            {
                h.AddParameter("@BillNo", DBNull.Value);
            }
            else
            {
                h.AddParameter("@BillNo", model.BillNo);
            }
            if (model.RegDate == null)
            {
                h.AddParameter("@RegDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RegDate", model.RegDate);
            }
            if (model.UserCount == null)
            {
                h.AddParameter("@UserCount", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserCount", model.UserCount);
            }
            if (model.Location == null)
            {
                h.AddParameter("@Location", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Location", model.Location);
            }
            return(h.ExecuteNonQuery());
        }
Example #3
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int keyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from [Settings] ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", keyId);
            return(h.ExecuteNonQuery());
        }
Example #4
0
        /// <summary>
        /// 取一个字段的值
        /// </summary>
        /// <param name="filed">字段,如sum(je)</param>
        /// <param name="cond">条件,如userid=2</param>
        /// <returns></returns>
        public string GetOneFiled(string filed, string cond)
        {
            string sql = "select " + filed + " from [Settings]";

            if (!string.IsNullOrEmpty(cond))
            {
                sql += " where " + cond;
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(sql);
            return(h.ExecuteScalar());
        }
Example #5
0
        /// <summary>
        /// 计算记录数
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public int CalcCount(string cond)
        {
            string sql = "select count(1) from [Settings]";

            if (!string.IsNullOrEmpty(cond))
            {
                sql += " where " + cond;
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(sql);
            return(int.Parse(h.ExecuteScalar()));
        }
Example #6
0
        /// <summary>
        /// 根据条件删除数据
        /// </summary>
        public bool DeleteByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from [Settings] ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            return(h.ExecuteNonQuery());
        }
Example #7
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Settings model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [Settings](");
            strSql.Append("[Id], [Name], [Value] )");
            strSql.Append(" values (");
            strSql.Append("@Id, @Name, @Value )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Id == null)
            {
                h.AddParameter("@Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Id", model.Id);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.Value == null)
            {
                h.AddParameter("@Value", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Value", model.Value);
            }
            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }
Example #8
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append(" FROM [Settings] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            DataTable dt = h.ExecuteQuery();
            DataSet   ds = new DataSet();

            ds.Tables.Add(dt);
            return(ds);
        }
Example #9
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Settings GetModel(string name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Settings] ");
            strSql.Append(" where Name=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", name);
            Model.Settings model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Example #10
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Tools_entitys GetModel(int keyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Tools_entitys] ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", keyId);
            Model.Tools_entitys model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Example #11
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Tools_Defination GetModel(string code)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Tools_Defination] ");
            strSql.Append(" where Code=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", code);
            Model.Tools_Defination model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Example #12
0
        /// <summary>
        /// 根据条件得到一个对象实体
        /// </summary>
        public Model.Settings GetModelByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * from [Settings] ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            Model.Settings model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Example #13
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Settings model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [Settings] set ");
            strSql.Append("[Id]=@Id, [Name]=@Name, [Value]=@Value   ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Id == null)
            {
                h.AddParameter("@Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Id", model.Id);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.Value == null)
            {
                h.AddParameter("@Value", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Value", model.Value);
            }
            return(h.ExecuteNonQuery());
        }
Example #14
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <Model.Settings> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append(" FROM [Settings] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List <Model.Settings> list = new List <Model.Settings>();
            MSSQLHelper           h    = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            using (IDataReader dataReader = h.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
                h.CloseConn();
            }
            return(list);
        }
Example #15
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.Tools_Defination model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update [Tools_Defination] set ");
            strSql.Append("[WorkceIIID]=@WorkceIIID, [WorkceII]=@WorkceII, [FamilyID]=@FamilyID, [Family]=@Family, [Code]=@Code, [Name]=@Name, [Model]=@Model, [PartNo]=@PartNo, [UsedFor]=@UsedFor, [UPL]=@UPL, [Owner]=@Owner, [OwnerNamer]=@OwnerNamer, [Remark]=@Remark, [PMperiord]=@PMperiord, [RecOn]=@RecOn, [RecBy]=@RecBy, [RecByName]=@RecByName, [EditOn]=@EditOn, [EditBy]=@EditBy, [EditByName]=@EditByName   ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.ID.ToString() == null)
            {
                h.AddParameter("@ID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ID", model.ID);
            }
            if (model.WorkceIIID == null)
            {
                h.AddParameter("@WorkceIIID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WorkceIIID", model.WorkceIIID);
            }
            if (model.WorkceII == null)
            {
                h.AddParameter("@WorkceII", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WorkceII", model.WorkceII);
            }
            if (model.FamilyID == null)
            {
                h.AddParameter("@FamilyID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@FamilyID", model.FamilyID);
            }
            if (model.Family == null)
            {
                h.AddParameter("@Family", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Family", model.Family);
            }
            if (model.Code == null)
            {
                h.AddParameter("@Code", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Code", model.Code);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.Model == null)
            {
                h.AddParameter("@Model", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Model", model.Model);
            }
            if (model.PartNo == null)
            {
                h.AddParameter("@PartNo", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PartNo", model.PartNo);
            }
            if (model.UsedFor == null)
            {
                h.AddParameter("@UsedFor", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UsedFor", model.UsedFor);
            }
            if (model.UPL == null)
            {
                h.AddParameter("@UPL", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UPL", model.UPL);
            }
            if (model.Owner == null)
            {
                h.AddParameter("@Owner", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Owner", model.Owner);
            }
            if (model.OwnerNamer == null)
            {
                h.AddParameter("@OwnerNamer", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OwnerNamer", model.OwnerNamer);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.PMperiord == null)
            {
                h.AddParameter("@PMperiord", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PMperiord", model.PMperiord);
            }
            if (model.RecOn == null)
            {
                h.AddParameter("@RecOn", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RecOn", model.RecOn);
            }
            if (model.RecBy == null)
            {
                h.AddParameter("@RecBy", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RecBy", model.RecBy);
            }
            if (model.RecByName == null)
            {
                h.AddParameter("@RecByName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RecByName", model.RecByName);
            }
            if (model.EditOn == null)
            {
                h.AddParameter("@EditOn", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditOn", model.EditOn);
            }
            if (model.EditBy == null)
            {
                h.AddParameter("@EditBy", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditBy", model.EditBy);
            }
            if (model.EditByName == null)
            {
                h.AddParameter("@EditByName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditByName", model.EditByName);
            }
            return(h.ExecuteNonQuery());
        }
Example #16
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Tools_entitys model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [Tools_entitys](");
            strSql.Append("[Code], [SeqID], [BillNo], [RegDate], [UserCount], [Location] )");
            strSql.Append(" values (");
            strSql.Append("@Code, @SeqID, @BillNo, @RegDate, @UserCount, @Location )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Code == null)
            {
                h.AddParameter("@Code", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Code", model.Code);
            }
            if (model.SeqID == null)
            {
                h.AddParameter("@SeqID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SeqID", model.SeqID);
            }
            if (model.BillNo == null)
            {
                h.AddParameter("@BillNo", DBNull.Value);
            }
            else
            {
                h.AddParameter("@BillNo", model.BillNo);
            }
            if (model.RegDate == null)
            {
                h.AddParameter("@RegDate", DateTime.Now);
            }
            else
            {
                h.AddParameter("@RegDate", model.RegDate);
            }
            if (model.UserCount == null)
            {
                h.AddParameter("@UserCount", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserCount", model.UserCount);
            }
            if (model.Location == null)
            {
                h.AddParameter("@Location", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Location", model.Location);
            }
            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }
Example #17
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [Users](");
            strSql.Append("[UserName], [UserPwd], [Phone], [Mail], [Permission] )");
            strSql.Append(" values (");
            strSql.Append("@UserName, @UserPwd, @Phone, @Mail, @Permission )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.UserName == null)
            {
                h.AddParameter("@UserName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserName", model.UserName);
            }
            if (model.UserPwd == null)
            {
                h.AddParameter("@UserPwd", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserPwd", model.UserPwd);
            }
            if (model.Phone == null)
            {
                h.AddParameter("@Phone", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Phone", model.Phone);
            }
            if (model.Mail == null)
            {
                h.AddParameter("@Mail", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Mail", model.Mail);
            }
            if (model.Permission == null)
            {
                h.AddParameter("@Permission", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Permission", model.Permission);
            }
            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }
Example #18
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.Tools_Defination model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into [Tools_Defination](");
            strSql.Append("[WorkceIIID], [WorkceII], [FamilyID], [Family], [Code], [Name], [Model], [PartNo], [UsedFor], [UPL], [Owner], [OwnerNamer], [Remark], [PMperiord], [RecOn], [RecBy], [RecByName], [EditOn], [EditBy], [EditByName] )");
            strSql.Append(" values (");
            strSql.Append("@WorkceIIID, @WorkceII, @FamilyID, @Family, @Code, @Name, @Model, @PartNo, @UsedFor, @UPL, @Owner, @OwnerNamer, @Remark, @PMperiord, @RecOn, @RecBy, @RecByName, @EditOn, @EditBy, @EditByName )");
            strSql.Append(";select @@IDENTITY");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            if (model.WorkceIIID == null)
            {
                h.AddParameter("@WorkceIIID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WorkceIIID", model.WorkceIIID);
            }
            if (model.WorkceII == null)
            {
                h.AddParameter("@WorkceII", DBNull.Value);
            }
            else
            {
                h.AddParameter("@WorkceII", model.WorkceII);
            }
            if (model.FamilyID == null)
            {
                h.AddParameter("@FamilyID", DBNull.Value);
            }
            else
            {
                h.AddParameter("@FamilyID", model.FamilyID);
            }
            if (model.Family == null)
            {
                h.AddParameter("@Family", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Family", model.Family);
            }
            if (model.Code == null)
            {
                h.AddParameter("@Code", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Code", model.Code);
            }
            if (model.Name == null)
            {
                h.AddParameter("@Name", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Name", model.Name);
            }
            if (model.Model == null)
            {
                h.AddParameter("@Model", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Model", model.Model);
            }
            if (model.PartNo == null)
            {
                h.AddParameter("@PartNo", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PartNo", model.PartNo);
            }
            if (model.UsedFor == null)
            {
                h.AddParameter("@UsedFor", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UsedFor", model.UsedFor);
            }
            if (model.UPL == null)
            {
                h.AddParameter("@UPL", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UPL", model.UPL);
            }
            if (model.Owner == null)
            {
                h.AddParameter("@Owner", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Owner", model.Owner);
            }
            if (model.OwnerNamer == null)
            {
                h.AddParameter("@OwnerNamer", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OwnerNamer", model.OwnerNamer);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.PMperiord == null)
            {
                h.AddParameter("@PMperiord", DBNull.Value);
            }
            else
            {
                h.AddParameter("@PMperiord", model.PMperiord);
            }
            if (model.RecOn == null)
            {
                h.AddParameter("@RecOn", DateTime.Now);
            }
            else
            {
                h.AddParameter("@RecOn", model.RecOn);
            }
            if (model.RecBy == null)
            {
                h.AddParameter("@RecBy", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RecBy", model.RecBy);
            }
            if (model.RecByName == null)
            {
                h.AddParameter("@RecByName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RecByName", model.RecByName);
            }
            if (model.EditOn == null)
            {
                h.AddParameter("@EditOn", DateTime.Now);
            }
            else
            {
                h.AddParameter("@EditOn", model.EditOn);
            }
            if (model.EditBy == null)
            {
                h.AddParameter("@EditBy", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditBy", model.EditBy);
            }
            if (model.EditByName == null)
            {
                h.AddParameter("@EditByName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditByName", model.EditByName);
            }
            int    result;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out result))
            {
                return(0);
            }
            return(result);
        }