Exemple #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BWJS.Model.MachineSupplier GetModel(int MachineSupplierId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MachineSupplierId, API, QRCode, MainBrand, MainBusiness, Wechat, PublicWechat, Remark, Status, IsDeleted, CreateId, SupplierName, CreateDate, EditId, EditDate, Manager, Phone, Mobile, Address, QQ, SiteUrl, Logo  ");
            strSql.Append("  from dbo.[MachineSupplier] ");
            strSql.Append(" where MachineSupplierId=@MachineSupplierId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MachineSupplierId", SqlDbType.Int, 4)
            };
            parameters[0].Value = MachineSupplierId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
        /// <summary>
        /// datarow转成对象实体
        /// </summary>
        public BWJS.Model.MachineSupplier DataRowToModel(DataRow row)
        {
            BWJS.Model.MachineSupplier model = new BWJS.Model.MachineSupplier();

            if (row != null)
            {
                if (row["MachineSupplierId"].ToString() != "")
                {
                    model.MachineSupplierId = int.Parse(row["MachineSupplierId"].ToString());
                }
                model.API          = row["API"].ToString();
                model.QRCode       = row["QRCode"].ToString();
                model.MainBrand    = row["MainBrand"].ToString();
                model.MainBusiness = row["MainBusiness"].ToString();
                model.Wechat       = row["Wechat"].ToString();
                model.PublicWechat = row["PublicWechat"].ToString();
                model.Remark       = row["Remark"].ToString();
                if (row["Status"].ToString() != "")
                {
                    model.Status = int.Parse(row["Status"].ToString());
                }
                if (row["IsDeleted"].ToString() != "")
                {
                    model.IsDeleted = int.Parse(row["IsDeleted"].ToString());
                }
                if (row["CreateId"].ToString() != "")
                {
                    model.CreateId = int.Parse(row["CreateId"].ToString());
                }
                model.SupplierName = row["SupplierName"].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());
                }
                model.Manager = row["Manager"].ToString();
                model.Phone   = row["Phone"].ToString();
                model.Mobile  = row["Mobile"].ToString();
                model.Address = row["Address"].ToString();
                model.QQ      = row["QQ"].ToString();
                model.SiteUrl = row["SiteUrl"].ToString();
                model.Logo    = row["Logo"].ToString();

                return(model);
            }
            else
            {
                return(null);
            }
        }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BWJS.Model.MachineSupplier model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into dbo.[MachineSupplier](");
            strSql.Append("API,QRCode,MainBrand,MainBusiness,Wechat,PublicWechat,Remark,Status,IsDeleted,CreateId,SupplierName,CreateDate,EditId,EditDate,Manager,Phone,Mobile,Address,QQ,SiteUrl,Logo");
            strSql.Append(") values (");
            strSql.Append("@API,@QRCode,@MainBrand,@MainBusiness,@Wechat,@PublicWechat,@Remark,@Status,@IsDeleted,@CreateId,@SupplierName,@CreateDate,@EditId,@EditDate,@Manager,@Phone,@Mobile,@Address,@QQ,@SiteUrl,@Logo");
            strSql.Append(") ");
            strSql.Append(";select SCOPE_IDENTITY()");
            SqlParameter[] parameters =
            {
                new SqlParameter("@API",          model.API),
                new SqlParameter("@QRCode",       model.QRCode),
                new SqlParameter("@MainBrand",    model.MainBrand),
                new SqlParameter("@MainBusiness", model.MainBusiness),
                new SqlParameter("@Wechat",       model.Wechat),
                new SqlParameter("@PublicWechat", model.PublicWechat),
                new SqlParameter("@Remark",       model.Remark),
                new SqlParameter("@Status",       model.Status),
                new SqlParameter("@IsDeleted",    model.IsDeleted),
                new SqlParameter("@CreateId",     model.CreateId),
                new SqlParameter("@SupplierName", model.SupplierName),
                new SqlParameter("@CreateDate",   model.CreateDate),
                new SqlParameter("@EditId",       model.EditId),
                new SqlParameter("@EditDate",     model.EditDate),
                new SqlParameter("@Manager",      model.Manager),
                new SqlParameter("@Phone",        model.Phone),
                new SqlParameter("@Mobile",       model.Mobile),
                new SqlParameter("@Address",      model.Address),
                new SqlParameter("@QQ",           model.QQ),
                new SqlParameter("@SiteUrl",      model.SiteUrl),
                new SqlParameter("@Logo",         model.Logo)
            };
            object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BWJS.Model.MachineSupplier model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update dbo.[MachineSupplier] set ");
            strSql.Append(" API = @API , ");
            strSql.Append(" QRCode = @QRCode , ");
            strSql.Append(" MainBrand = @MainBrand , ");
            strSql.Append(" MainBusiness = @MainBusiness , ");
            strSql.Append(" Wechat = @Wechat , ");
            strSql.Append(" PublicWechat = @PublicWechat , ");
            strSql.Append(" Remark = @Remark , ");
            strSql.Append(" Status = @Status , ");
            strSql.Append(" IsDeleted = @IsDeleted , ");
            strSql.Append(" CreateId = @CreateId , ");
            strSql.Append(" SupplierName = @SupplierName , ");
            strSql.Append(" CreateDate = @CreateDate , ");
            strSql.Append(" EditId = @EditId , ");
            strSql.Append(" EditDate = @EditDate , ");
            strSql.Append(" Manager = @Manager , ");
            strSql.Append(" Phone = @Phone , ");
            strSql.Append(" Mobile = @Mobile , ");
            strSql.Append(" Address = @Address , ");
            strSql.Append(" QQ = @QQ , ");
            strSql.Append(" SiteUrl = @SiteUrl , ");
            strSql.Append(" Logo = @Logo  ");
            strSql.Append(" where MachineSupplierId=@MachineSupplierId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MachineSupplierId", model.MachineSupplierId),
                new SqlParameter("@API",               model.API),
                new SqlParameter("@QRCode",            model.QRCode),
                new SqlParameter("@MainBrand",         model.MainBrand),
                new SqlParameter("@MainBusiness",      model.MainBusiness),
                new SqlParameter("@Wechat",            model.Wechat),
                new SqlParameter("@PublicWechat",      model.PublicWechat),
                new SqlParameter("@Remark",            model.Remark),
                new SqlParameter("@Status",            model.Status),
                new SqlParameter("@IsDeleted",         model.IsDeleted),
                new SqlParameter("@CreateId",          model.CreateId),
                new SqlParameter("@SupplierName",      model.SupplierName),
                new SqlParameter("@CreateDate",        model.CreateDate),
                new SqlParameter("@EditId",            model.EditId),
                new SqlParameter("@EditDate",          model.EditDate),
                new SqlParameter("@Manager",           model.Manager),
                new SqlParameter("@Phone",             model.Phone),
                new SqlParameter("@Mobile",            model.Mobile),
                new SqlParameter("@Address",           model.Address),
                new SqlParameter("@QQ",                model.QQ),
                new SqlParameter("@SiteUrl",           model.SiteUrl),
                new SqlParameter("@Logo",              model.Logo)
            };

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }