Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.PhoneMessage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update PhoneMessage set ");
            strSql.Append("SoftName=@SoftName,");
            strSql.Append("Brands=@Brands,");
            strSql.Append("Model=@Model,");
            strSql.Append("Version=@Version,");
            strSql.Append("BlueToothVer=@BlueToothVer,");
            strSql.Append("SDKVer=@SDKVer,");
            strSql.Append("IMEI=@IMEI,");
            strSql.Append("CPU=@CPU,");
            strSql.Append("Memory=@Memory,");
            strSql.Append("Resolution=@Resolution,");
            strSql.Append("FirstLoginDate=@FirstLoginDate");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SoftName",       SqlDbType.VarChar,   100),
                new SqlParameter("@Brands",         SqlDbType.VarChar,    50),
                new SqlParameter("@Model",          SqlDbType.VarChar,    50),
                new SqlParameter("@Version",        SqlDbType.VarChar,    50),
                new SqlParameter("@BlueToothVer",   SqlDbType.VarChar,    50),
                new SqlParameter("@SDKVer",         SqlDbType.VarChar,    50),
                new SqlParameter("@IMEI",           SqlDbType.VarChar,    50),
                new SqlParameter("@CPU",            SqlDbType.VarChar,    50),
                new SqlParameter("@Memory",         SqlDbType.VarChar,    50),
                new SqlParameter("@Resolution",     SqlDbType.VarChar,    50),
                new SqlParameter("@FirstLoginDate", SqlDbType.DateTime),
                new SqlParameter("@ID",             SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.SoftName;
            parameters[1].Value  = model.Brands;
            parameters[2].Value  = model.Model;
            parameters[3].Value  = model.Version;
            parameters[4].Value  = model.BlueToothVer;
            parameters[5].Value  = model.SDKVer;
            parameters[6].Value  = model.IMEI;
            parameters[7].Value  = model.CPU;
            parameters[8].Value  = model.Memory;
            parameters[9].Value  = model.Resolution;
            parameters[10].Value = model.FirstLoginDate;
            parameters[11].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.PhoneMessage DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.PhoneMessage model = new WebDemo.Model.WebDemo.PhoneMessage();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["SoftName"] != null)
         {
             model.SoftName = row["SoftName"].ToString();
         }
         if (row["Brands"] != null)
         {
             model.Brands = row["Brands"].ToString();
         }
         if (row["Model"] != null)
         {
             model.Model = row["Model"].ToString();
         }
         if (row["Version"] != null)
         {
             model.Version = row["Version"].ToString();
         }
         if (row["BlueToothVer"] != null)
         {
             model.BlueToothVer = row["BlueToothVer"].ToString();
         }
         if (row["SDKVer"] != null)
         {
             model.SDKVer = row["SDKVer"].ToString();
         }
         if (row["IMEI"] != null)
         {
             model.IMEI = row["IMEI"].ToString();
         }
         if (row["CPU"] != null)
         {
             model.CPU = row["CPU"].ToString();
         }
         if (row["Memory"] != null)
         {
             model.Memory = row["Memory"].ToString();
         }
         if (row["Resolution"] != null)
         {
             model.Resolution = row["Resolution"].ToString();
         }
         if (row["FirstLoginDate"] != null && row["FirstLoginDate"].ToString() != "")
         {
             model.FirstLoginDate = DateTime.Parse(row["FirstLoginDate"].ToString());
         }
     }
     return(model);
 }
Esempio n. 3
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.PhoneMessage   bll   = new WebDemo.BLL.WebDemo.PhoneMessage();
     WebDemo.Model.WebDemo.PhoneMessage model = bll.GetModel(ID);
     this.lblID.Text             = model.ID.ToString();
     this.lblSoftName.Text       = model.SoftName;
     this.lblBrands.Text         = model.Brands;
     this.lblModel.Text          = model.Model;
     this.lblVersion.Text        = model.Version;
     this.lblBlueToothVer.Text   = model.BlueToothVer;
     this.lblSDKVer.Text         = model.SDKVer;
     this.lblIMEI.Text           = model.IMEI;
     this.lblCPU.Text            = model.CPU;
     this.lblMemory.Text         = model.Memory;
     this.lblResolution.Text     = model.Resolution;
     this.lblFirstLoginDate.Text = model.FirstLoginDate.ToString();
 }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.PhoneMessage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into PhoneMessage(");
            strSql.Append("SoftName,Brands,Model,Version,BlueToothVer,SDKVer,IMEI,CPU,Memory,Resolution,FirstLoginDate)");
            strSql.Append(" values (");
            strSql.Append("@SoftName,@Brands,@Model,@Version,@BlueToothVer,@SDKVer,@IMEI,@CPU,@Memory,@Resolution,@FirstLoginDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SoftName",       SqlDbType.VarChar, 100),
                new SqlParameter("@Brands",         SqlDbType.VarChar,  50),
                new SqlParameter("@Model",          SqlDbType.VarChar,  50),
                new SqlParameter("@Version",        SqlDbType.VarChar,  50),
                new SqlParameter("@BlueToothVer",   SqlDbType.VarChar,  50),
                new SqlParameter("@SDKVer",         SqlDbType.VarChar,  50),
                new SqlParameter("@IMEI",           SqlDbType.VarChar,  50),
                new SqlParameter("@CPU",            SqlDbType.VarChar,  50),
                new SqlParameter("@Memory",         SqlDbType.VarChar,  50),
                new SqlParameter("@Resolution",     SqlDbType.VarChar,  50),
                new SqlParameter("@FirstLoginDate", SqlDbType.DateTime)
            };
            parameters[0].Value  = model.SoftName;
            parameters[1].Value  = model.Brands;
            parameters[2].Value  = model.Model;
            parameters[3].Value  = model.Version;
            parameters[4].Value  = model.BlueToothVer;
            parameters[5].Value  = model.SDKVer;
            parameters[6].Value  = model.IMEI;
            parameters[7].Value  = model.CPU;
            parameters[8].Value  = model.Memory;
            parameters[9].Value  = model.Resolution;
            parameters[10].Value = model.FirstLoginDate;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.PhoneMessage GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,SoftName,Brands,Model,Version,BlueToothVer,SDKVer,IMEI,CPU,Memory,Resolution,FirstLoginDate from PhoneMessage ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

            WebDemo.Model.WebDemo.PhoneMessage model = new WebDemo.Model.WebDemo.PhoneMessage();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Esempio n. 6
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtSoftName.Text.Trim().Length == 0)
            {
                strErr += "SoftName不能为空!\\n";
            }
            if (this.txtBrands.Text.Trim().Length == 0)
            {
                strErr += "Brands不能为空!\\n";
            }
            if (this.txtModel.Text.Trim().Length == 0)
            {
                strErr += "Model不能为空!\\n";
            }
            if (this.txtVersion.Text.Trim().Length == 0)
            {
                strErr += "Version不能为空!\\n";
            }
            if (this.txtBlueToothVer.Text.Trim().Length == 0)
            {
                strErr += "BlueToothVer不能为空!\\n";
            }
            if (this.txtSDKVer.Text.Trim().Length == 0)
            {
                strErr += "SDKVer不能为空!\\n";
            }
            if (this.txtIMEI.Text.Trim().Length == 0)
            {
                strErr += "IMEI不能为空!\\n";
            }
            if (this.txtCPU.Text.Trim().Length == 0)
            {
                strErr += "CPU不能为空!\\n";
            }
            if (this.txtMemory.Text.Trim().Length == 0)
            {
                strErr += "Memory不能为空!\\n";
            }
            if (this.txtResolution.Text.Trim().Length == 0)
            {
                strErr += "Resolution不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtFirstLoginDate.Text))
            {
                strErr += "FirstLoginDate格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID             = int.Parse(this.lblID.Text);
            string   SoftName       = this.txtSoftName.Text;
            string   Brands         = this.txtBrands.Text;
            string   Model          = this.txtModel.Text;
            string   Version        = this.txtVersion.Text;
            string   BlueToothVer   = this.txtBlueToothVer.Text;
            string   SDKVer         = this.txtSDKVer.Text;
            string   IMEI           = this.txtIMEI.Text;
            string   CPU            = this.txtCPU.Text;
            string   Memory         = this.txtMemory.Text;
            string   Resolution     = this.txtResolution.Text;
            DateTime FirstLoginDate = DateTime.Parse(this.txtFirstLoginDate.Text);


            WebDemo.Model.WebDemo.PhoneMessage model = new WebDemo.Model.WebDemo.PhoneMessage();
            model.ID             = ID;
            model.SoftName       = SoftName;
            model.Brands         = Brands;
            model.Model          = Model;
            model.Version        = Version;
            model.BlueToothVer   = BlueToothVer;
            model.SDKVer         = SDKVer;
            model.IMEI           = IMEI;
            model.CPU            = CPU;
            model.Memory         = Memory;
            model.Resolution     = Resolution;
            model.FirstLoginDate = FirstLoginDate;

            WebDemo.BLL.WebDemo.PhoneMessage bll = new WebDemo.BLL.WebDemo.PhoneMessage();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }