Пример #1
0
        /// <summary>计算记录数
        ///
        /// </summary>
        /// <param name="strCond">条件</param>
        /// <returns>总数量</returns>
        public int CalcCount(string strCond)
        {
            string strSql = "select count(1) from Sys_Roles";

            if (!string.IsNullOrEmpty(strCond))
            {
                strSql += " where " + strCond;
            }
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo();
            h.CreateCommand(strSql);
            return(int.Parse(h.ExecuteScalar()));
        }
Пример #2
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回新增实体ID</returns>
        public int Add(Nikita.Assist.CodeMaker.Model.Sys_Roles model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Sys_Roles(");
            strSql.Append("RoleName, Sortnum, Remark, isDefault  )");
            strSql.Append(" values (");
            strSql.Append("@RoleName, @Sortnum, @Remark, @isDefault  )");
            strSql.Append(";select @@IDENTITY");
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo();
            h.CreateCommand(strSql.ToString());
            if (model.RoleName == null)
            {
                h.AddParameter("@RoleName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@RoleName", model.RoleName);
            }
            if (model.Sortnum == null)
            {
                h.AddParameter("@Sortnum", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Sortnum", model.Sortnum);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.isDefault == null)
            {
                h.AddParameter("@isDefault", DBNull.Value);
            }
            else
            {
                h.AddParameter("@isDefault", model.isDefault);
            }

            int    intResult;
            string strObj = h.ExecuteScalar();

            if (!int.TryParse(strObj, out intResult))
            {
                return(0);
            }
            return(intResult);
        }
Пример #3
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.CodeMaker.Model.OrderMaster model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrderMaster(");
            strSql.Append("OrderNumber, Status, CreateDate  )");
            strSql.Append(" values (");
            strSql.Append("@OrderNumber, @Status, @CreateDate  )");
            strSql.Append(";select @@IDENTITY");
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo();
            h.CreateCommand(strSql.ToString());
            if (model.OrderNumber == null)
            {
                h.AddParameter("@OrderNumber", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OrderNumber", model.OrderNumber);
            }
            if (model.Status == null)
            {
                h.AddParameter("@Status", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Status", model.Status);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }

            int    intResult;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out intResult))
            {
                return(0);
            }
            return(intResult);
        }
Пример #4
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.CodeMaker.Model.TreeListDemo model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TreeListDemo(");
            strSql.Append("ParentId, Name, Value, OnLevel, OwerCompanyId, Status, Remark, Dept_Id, Company_Id, CreateUser, CreateDate, EditUser, EditDate  )");
            strSql.Append(" values (");
            strSql.Append("@ParentId, @Name, @Value, @OnLevel, @OwerCompanyId, @Status, @Remark, @Dept_Id, @Company_Id, @CreateUser, @CreateDate, @EditUser, @EditDate  )");
            strSql.Append(";select @@IDENTITY");
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo();
            h.CreateCommand(strSql.ToString());
            if (model.ParentId == null)
            {
                h.AddParameter("@ParentId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ParentId", model.ParentId);
            }
            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);
            }
            if (model.OnLevel == null)
            {
                h.AddParameter("@OnLevel", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OnLevel", model.OnLevel);
            }
            if (model.OwerCompanyId == null)
            {
                h.AddParameter("@OwerCompanyId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OwerCompanyId", model.OwerCompanyId);
            }
            if (model.Status == null)
            {
                h.AddParameter("@Status", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Status", model.Status);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.Dept_Id == null)
            {
                h.AddParameter("@Dept_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Dept_Id", model.Dept_Id);
            }
            if (model.Company_Id == null)
            {
                h.AddParameter("@Company_Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Company_Id", model.Company_Id);
            }
            if (model.CreateUser == null)
            {
                h.AddParameter("@CreateUser", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateUser", model.CreateUser);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }
            if (model.EditUser == null)
            {
                h.AddParameter("@EditUser", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditUser", model.EditUser);
            }
            if (model.EditDate == null)
            {
                h.AddParameter("@EditDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@EditDate", model.EditDate);
            }

            int    intResult;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out intResult))
            {
                return(0);
            }
            return(intResult);
        }
Пример #5
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        /// <param name="model">实体对象</param>
        /// <returns>返回新增实体ID</returns>
        public int Add(Nikita.Assist.CodeMaker.Model.Bse_User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Bse_User(");
            strSql.Append("UserName, Password, TrueName, Company, CreateDate, State  )");
            strSql.Append(" values (");
            strSql.Append("@UserName, @Password, @TrueName, @Company, @CreateDate, @State  )");
            strSql.Append(";select @@IDENTITY");
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelper();
            h.CreateCommand(strSql.ToString());
            if (model.UserName == null)
            {
                h.AddParameter("@UserName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UserName", model.UserName);
            }
            if (model.Password == null)
            {
                h.AddParameter("@Password", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Password", model.Password);
            }
            if (model.TrueName == null)
            {
                h.AddParameter("@TrueName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@TrueName", model.TrueName);
            }
            if (model.Company == null)
            {
                h.AddParameter("@Company", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Company", model.Company);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }
            if (model.State == null)
            {
                h.AddParameter("@State", DBNull.Value);
            }
            else
            {
                h.AddParameter("@State", model.State);
            }

            int    intResult;
            string strObj = h.ExecuteScalar();

            if (!int.TryParse(strObj, out intResult))
            {
                return(0);
            }
            return(intResult);
        }
Пример #6
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.CodeMaker.Model.OrderDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into OrderDetail(");
            strSql.Append("OrderId, Customer, ProductName, Amount, SumMoney, Status  )");
            strSql.Append(" values (");
            strSql.Append("@OrderId, @Customer, @ProductName, @Amount, @SumMoney, @Status  )");
            strSql.Append(";select @@IDENTITY");
            DataAccess4DBHelper.IDbHelper h = GlobalHelpDemoForm.GetDataAccessHelperDemo();
            h.CreateCommand(strSql.ToString());
            if (model.OrderId == null)
            {
                h.AddParameter("@OrderId", DBNull.Value);
            }
            else
            {
                h.AddParameter("@OrderId", model.OrderId);
            }
            if (model.Customer == null)
            {
                h.AddParameter("@Customer", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Customer", model.Customer);
            }
            if (model.ProductName == null)
            {
                h.AddParameter("@ProductName", DBNull.Value);
            }
            else
            {
                h.AddParameter("@ProductName", model.ProductName);
            }
            if (model.Amount == null)
            {
                h.AddParameter("@Amount", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Amount", model.Amount);
            }
            if (model.SumMoney == null)
            {
                h.AddParameter("@SumMoney", DBNull.Value);
            }
            else
            {
                h.AddParameter("@SumMoney", model.SumMoney);
            }
            if (model.Status == null)
            {
                h.AddParameter("@Status", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Status", model.Status);
            }

            int    intResult;
            string obj = h.ExecuteScalar();

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