예제 #1
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.UserBank DataRowToModel(DataRow row)
        {
            BWJS.Model.UserBank model = new BWJS.Model.UserBank();

            if (row != null)
            {
                if (row["UserBankId"].ToString() != "")
                {
                    model.UserBankId = int.Parse(row["UserBankId"].ToString());
                }
                model.Remark = row["Remark"].ToString();
                if (row["CreateId"].ToString() != "")
                {
                    model.CreateId = int.Parse(row["CreateId"].ToString());
                }
                if (row["CreateDate"].ToString() != "")
                {
                    model.CreateDate = DateTime.Parse(row["CreateDate"].ToString());
                }
                if (row["EditId"].ToString() != "")
                {
                    model.EditId = int.Parse(row["EditId"].ToString());
                }
                if (row["EditDate"].ToString() != "")
                {
                    model.EditDate = DateTime.Parse(row["EditDate"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                if (row["UserId"].ToString() != "")
                {
                    model.UserId = int.Parse(row["UserId"].ToString());
                }
                model.BankCode      = row["BankCode"].ToString();
                model.OpeningBank   = row["OpeningBank"].ToString();
                model.CardHolder    = row["CardHolder"].ToString();
                model.CardNumber    = row["CardNumber"].ToString();
                model.BankAddress   = row["BankAddress"].ToString();
                model.AlipayAccount = row["AlipayAccount"].ToString();
                if (row["IsDefault"].ToString() != "")
                {
                    if ((row["IsDefault"].ToString() == "1") || (row["IsDefault"].ToString().ToLower() == "true"))
                    {
                        model.IsDefault = true;
                    }
                    else
                    {
                        model.IsDefault = false;
                    }
                }

                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.UserBank GetModel(int UserBankId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from dbo.[UserBank] ");
            strSql.Append(" where UserBankId=@UserBankId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UserBankId", SqlDbType.Int, 4)
            };
            parameters[0].Value = UserBankId;


            BWJS.Model.UserBank model = new BWJS.Model.UserBank();
            DataSet             ds    = BWJSHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.UserBank model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[UserBank] set ");

            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" CreateId = @CreateId , ");
            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" UserId = @UserId , ");
            strSql.Append(" BankCode = @BankCode , ");
            strSql.Append(" OpeningBank = @OpeningBank , ");
            strSql.Append(" CardHolder = @CardHolder , ");
            strSql.Append(" CardNumber = @CardNumber , ");
            strSql.Append(" BankAddress = @BankAddress , ");
            strSql.Append(" AlipayAccount = @AlipayAccount , ");
            strSql.Append(" IsDefault = @IsDefault  ");
            strSql.Append(" where UserBankId=@UserBankId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@UserBankId",    model.UserBankId),
                new SqlParameter("@Remark",        model.Remark),
                new SqlParameter("@CreateId",      model.CreateId),
                new SqlParameter("@CreateDate",    model.CreateDate),
                new SqlParameter("@EditId",        model.EditId),
                new SqlParameter("@EditDate",      model.EditDate),
                new SqlParameter("@IsDeleted",     model.IsDeleted),
                new SqlParameter("@UserId",        model.UserId),
                new SqlParameter("@BankCode",      model.BankCode),
                new SqlParameter("@OpeningBank",   model.OpeningBank),
                new SqlParameter("@CardHolder",    model.CardHolder),
                new SqlParameter("@CardNumber",    model.CardNumber),
                new SqlParameter("@BankAddress",   model.BankAddress),
                new SqlParameter("@AlipayAccount", model.AlipayAccount),
                new SqlParameter("@IsDefault",     model.IsDefault)
            };

            int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.UserBank model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[UserBank](");
            strSql.Append("Remark,CreateId,CreateDate,EditId,EditDate,IsDeleted,UserId,BankCode,OpeningBank,CardHolder,CardNumber,BankAddress,AlipayAccount,IsDefault");
            strSql.Append(") values (");
            strSql.Append("@Remark,@CreateId,@CreateDate,@EditId,@EditDate,@IsDeleted,@UserId,@BankCode,@OpeningBank,@CardHolder,@CardNumber,@BankAddress,@AlipayAccount,@IsDefault");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Remark",        model.Remark),
                new SqlParameter("@CreateId",      model.CreateId),
                new SqlParameter("@CreateDate",    model.CreateDate),
                new SqlParameter("@EditId",        model.EditId),
                new SqlParameter("@EditDate",      model.EditDate),
                new SqlParameter("@IsDeleted",     model.IsDeleted),
                new SqlParameter("@UserId",        model.UserId),
                new SqlParameter("@BankCode",      model.BankCode),
                new SqlParameter("@OpeningBank",   model.OpeningBank),
                new SqlParameter("@CardHolder",    model.CardHolder),
                new SqlParameter("@CardNumber",    model.CardNumber),
                new SqlParameter("@BankAddress",   model.BankAddress),
                new SqlParameter("@AlipayAccount", model.AlipayAccount),
                new SqlParameter("@IsDefault",     model.IsDefault)
            };


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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BWJS.Model.UserBank model)
 {
     return(dal.Update(model));
 }
예제 #6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Add(BWJS.Model.UserBank model)
 {
     return(dal.Add(model));
 }