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

            strSql.Append("update FailureMessage set ");
            strSql.Append("FailID=@FailID,");
            strSql.Append("Type=@Type,");
            strSql.Append("Flag=@Flag,");
            strSql.Append("Name=@Name,");
            strSql.Append("UpLoadTime=@UpLoadTime,");
            strSql.Append("Size=@Size,");
            strSql.Append("Pattern=@Pattern,");
            strSql.Append("Url=@Url,");
            strSql.Append("LocationX=@LocationX,");
            strSql.Append("LocationY=@LocationY");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FailID",     SqlDbType.Int,         4),
                new SqlParameter("@Type",       SqlDbType.Int,         4),
                new SqlParameter("@Flag",       SqlDbType.Int,         4),
                new SqlParameter("@Name",       SqlDbType.VarChar,   100),
                new SqlParameter("@UpLoadTime", SqlDbType.DateTime),
                new SqlParameter("@Size",       SqlDbType.VarChar,    20),
                new SqlParameter("@Pattern",    SqlDbType.VarChar,    20),
                new SqlParameter("@Url",        SqlDbType.VarChar,   500),
                new SqlParameter("@LocationX",  SqlDbType.Decimal,     9),
                new SqlParameter("@LocationY",  SqlDbType.Decimal,     9),
                new SqlParameter("@ID",         SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.FailID;
            parameters[1].Value  = model.Type;
            parameters[2].Value  = model.Flag;
            parameters[3].Value  = model.Name;
            parameters[4].Value  = model.UpLoadTime;
            parameters[5].Value  = model.Size;
            parameters[6].Value  = model.Pattern;
            parameters[7].Value  = model.Url;
            parameters[8].Value  = model.LocationX;
            parameters[9].Value  = model.LocationY;
            parameters[10].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WebDemo.Model.WebDemo.FailureMessage DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.FailureMessage model = new WebDemo.Model.WebDemo.FailureMessage();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["FailID"] != null && row["FailID"].ToString() != "")
         {
             model.FailID = int.Parse(row["FailID"].ToString());
         }
         if (row["Type"] != null && row["Type"].ToString() != "")
         {
             model.Type = int.Parse(row["Type"].ToString());
         }
         if (row["Flag"] != null && row["Flag"].ToString() != "")
         {
             model.Flag = int.Parse(row["Flag"].ToString());
         }
         if (row["Name"] != null)
         {
             model.Name = row["Name"].ToString();
         }
         if (row["UpLoadTime"] != null && row["UpLoadTime"].ToString() != "")
         {
             model.UpLoadTime = DateTime.Parse(row["UpLoadTime"].ToString());
         }
         if (row["Size"] != null)
         {
             model.Size = row["Size"].ToString();
         }
         if (row["Pattern"] != null)
         {
             model.Pattern = row["Pattern"].ToString();
         }
         if (row["Url"] != null)
         {
             model.Url = row["Url"].ToString();
         }
         if (row["LocationX"] != null && row["LocationX"].ToString() != "")
         {
             model.LocationX = decimal.Parse(row["LocationX"].ToString());
         }
         if (row["LocationY"] != null && row["LocationY"].ToString() != "")
         {
             model.LocationY = decimal.Parse(row["LocationY"].ToString());
         }
     }
     return(model);
 }
Beispiel #3
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.FailureMessage   bll   = new WebDemo.BLL.WebDemo.FailureMessage();
     WebDemo.Model.WebDemo.FailureMessage model = bll.GetModel(ID);
     this.lblID.Text         = model.ID.ToString();
     this.txtFailID.Text     = model.FailID.ToString();
     this.txtType.Text       = model.Type.ToString();
     this.txtFlag.Text       = model.Flag.ToString();
     this.txtName.Text       = model.Name;
     this.txtUpLoadTime.Text = model.UpLoadTime.ToString();
     this.txtSize.Text       = model.Size;
     this.txtPattern.Text    = model.Pattern;
     this.txtUrl.Text        = model.Url;
     this.txtLocationX.Text  = model.LocationX.ToString();
     this.txtLocationY.Text  = model.LocationY.ToString();
 }
Beispiel #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.FailureMessage model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into FailureMessage(");
            strSql.Append("FailID,Type,Flag,Name,UpLoadTime,Size,Pattern,Url,LocationX,LocationY)");
            strSql.Append(" values (");
            strSql.Append("@FailID,@Type,@Flag,@Name,@UpLoadTime,@Size,@Pattern,@Url,@LocationX,@LocationY)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@FailID",     SqlDbType.Int,         4),
                new SqlParameter("@Type",       SqlDbType.Int,         4),
                new SqlParameter("@Flag",       SqlDbType.Int,         4),
                new SqlParameter("@Name",       SqlDbType.VarChar,   100),
                new SqlParameter("@UpLoadTime", SqlDbType.DateTime),
                new SqlParameter("@Size",       SqlDbType.VarChar,    20),
                new SqlParameter("@Pattern",    SqlDbType.VarChar,    20),
                new SqlParameter("@Url",        SqlDbType.VarChar,   500),
                new SqlParameter("@LocationX",  SqlDbType.Decimal,     9),
                new SqlParameter("@LocationY",  SqlDbType.Decimal, 9)
            };
            parameters[0].Value = model.FailID;
            parameters[1].Value = model.Type;
            parameters[2].Value = model.Flag;
            parameters[3].Value = model.Name;
            parameters[4].Value = model.UpLoadTime;
            parameters[5].Value = model.Size;
            parameters[6].Value = model.Pattern;
            parameters[7].Value = model.Url;
            parameters[8].Value = model.LocationX;
            parameters[9].Value = model.LocationY;

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

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

            strSql.Append("select  top 1 ID,FailID,Type,Flag,Name,UpLoadTime,Size,Pattern,Url,LocationX,LocationY from FailureMessage ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

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

            if (!PageValidate.IsNumber(txtFailID.Text))
            {
                strErr += "FailID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtType.Text))
            {
                strErr += "Type格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtFlag.Text))
            {
                strErr += "Flag格式错误!\\n";
            }
            if (this.txtName.Text.Trim().Length == 0)
            {
                strErr += "Name不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtUpLoadTime.Text))
            {
                strErr += "UpLoadTime格式错误!\\n";
            }
            if (this.txtSize.Text.Trim().Length == 0)
            {
                strErr += "Size不能为空!\\n";
            }
            if (this.txtPattern.Text.Trim().Length == 0)
            {
                strErr += "Pattern不能为空!\\n";
            }
            if (this.txtUrl.Text.Trim().Length == 0)
            {
                strErr += "Url不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtLocationX.Text))
            {
                strErr += "LocationX格式错误!\\n";
            }
            if (!PageValidate.IsDecimal(txtLocationY.Text))
            {
                strErr += "LocationY格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID         = int.Parse(this.lblID.Text);
            int      FailID     = int.Parse(this.txtFailID.Text);
            int      Type       = int.Parse(this.txtType.Text);
            int      Flag       = int.Parse(this.txtFlag.Text);
            string   Name       = this.txtName.Text;
            DateTime UpLoadTime = DateTime.Parse(this.txtUpLoadTime.Text);
            string   Size       = this.txtSize.Text;
            string   Pattern    = this.txtPattern.Text;
            string   Url        = this.txtUrl.Text;
            decimal  LocationX  = decimal.Parse(this.txtLocationX.Text);
            decimal  LocationY  = decimal.Parse(this.txtLocationY.Text);


            WebDemo.Model.WebDemo.FailureMessage model = new WebDemo.Model.WebDemo.FailureMessage();
            model.ID         = ID;
            model.FailID     = FailID;
            model.Type       = Type;
            model.Flag       = Flag;
            model.Name       = Name;
            model.UpLoadTime = UpLoadTime;
            model.Size       = Size;
            model.Pattern    = Pattern;
            model.Url        = Url;
            model.LocationX  = LocationX;
            model.LocationY  = LocationY;

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