Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.test model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into test(");
            strSql.Append("PN,measureb,time,step1,OKorNG,workid)");
            strSql.Append(" values (");
            strSql.Append("@PN,@measureb,@time,@step1,@OKorNG,@workid)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@PN",       MySqlDbType.VarChar,   64),
                new MySqlParameter("@measureb", MySqlDbType.VarChar,   64),
                new MySqlParameter("@time",     MySqlDbType.DateTime),
                new MySqlParameter("@step1",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@OKorNG",   MySqlDbType.VarChar,   64),
                new MySqlParameter("@workid",   MySqlDbType.VarChar, 64)
            };
            parameters[0].Value = model.PN;
            parameters[1].Value = model.measureb;
            parameters[2].Value = model.time;
            parameters[3].Value = model.step1;
            parameters[4].Value = model.OKorNG;
            parameters[5].Value = model.workid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
 private void ShowInfo(int id)
 {
     Maticsoft.BLL.test   bll   = new Maticsoft.BLL.test();
     Maticsoft.Model.test model = bll.GetModel(id);
     this.lblid.Text       = model.id.ToString();
     this.lblmeasureb.Text = model.measureb;
     this.lbltime.Text     = model.time.ToString();
     this.lblstep1.Text    = model.step1;
     this.lblstep2.Text    = model.step2;
     this.lblstep3.Text    = model.step3;
     this.lblstep4.Text    = model.step4;
     this.lblstep5.Text    = model.step5;
     this.lblOKorNG.Text   = model.OKorNG;
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.test model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update test set ");
            strSql.Append("measureb=@measureb,");
            strSql.Append("time=@time,");
            strSql.Append("step1=@step1,");
            strSql.Append("step2=@step2,");
            strSql.Append("step3=@step3,");
            strSql.Append("step4=@step4,");
            strSql.Append("step5=@step5,");
            strSql.Append("OKorNG=@OKorNG");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@measureb", MySqlDbType.VarChar,   64),
                new MySqlParameter("@time",     MySqlDbType.DateTime),
                new MySqlParameter("@step1",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@step2",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@step3",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@step4",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@step5",    MySqlDbType.VarChar,   64),
                new MySqlParameter("@OKorNG",   MySqlDbType.VarChar,   64),
                new MySqlParameter("@id",       MySqlDbType.Int32, 64)
            };
            parameters[0].Value = model.measureb;
            parameters[1].Value = model.time;
            parameters[2].Value = model.step1;
            parameters[3].Value = model.step2;
            parameters[4].Value = model.step3;
            parameters[5].Value = model.step4;
            parameters[6].Value = model.step5;
            parameters[7].Value = model.OKorNG;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.test DataRowToModel(DataRow row)
 {
     Maticsoft.Model.test model = new Maticsoft.Model.test();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["measureb"] != null)
         {
             model.measureb = row["measureb"].ToString();
         }
         if (row["time"] != null && row["time"].ToString() != "")
         {
             model.time = DateTime.Parse(row["time"].ToString());
         }
         if (row["step1"] != null)
         {
             model.step1 = row["step1"].ToString();
         }
         if (row["step2"] != null)
         {
             model.step2 = row["step2"].ToString();
         }
         if (row["step3"] != null)
         {
             model.step3 = row["step3"].ToString();
         }
         if (row["step4"] != null)
         {
             model.step4 = row["step4"].ToString();
         }
         if (row["step5"] != null)
         {
             model.step5 = row["step5"].ToString();
         }
         if (row["OKorNG"] != null)
         {
             model.OKorNG = row["OKorNG"].ToString();
         }
     }
     return(model);
 }
Esempio n. 5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.test GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,measureb,time,step1,step2,step3,step4,step5,OKorNG from test ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Maticsoft.Model.test model = new Maticsoft.Model.test();
            DataSet ds = DbHelperMySQL.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
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtmeasureb.Text.Trim().Length == 0)
            {
                strErr += "measureb不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txttime.Text))
            {
                strErr += "time格式错误!\\n";
            }
            if (this.txtstep1.Text.Trim().Length == 0)
            {
                strErr += "step1不能为空!\\n";
            }
            if (this.txtstep2.Text.Trim().Length == 0)
            {
                strErr += "step2不能为空!\\n";
            }
            if (this.txtstep3.Text.Trim().Length == 0)
            {
                strErr += "step3不能为空!\\n";
            }
            if (this.txtstep4.Text.Trim().Length == 0)
            {
                strErr += "step4不能为空!\\n";
            }
            if (this.txtstep5.Text.Trim().Length == 0)
            {
                strErr += "step5不能为空!\\n";
            }
            if (this.txtOKorNG.Text.Trim().Length == 0)
            {
                strErr += "OKorNG不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string   measureb = this.txtmeasureb.Text;
            DateTime time     = DateTime.Parse(this.txttime.Text);
            string   step1    = this.txtstep1.Text;
            string   step2    = this.txtstep2.Text;
            string   step3    = this.txtstep3.Text;
            string   step4    = this.txtstep4.Text;
            string   step5    = this.txtstep5.Text;
            string   OKorNG   = this.txtOKorNG.Text;

            Maticsoft.Model.test model = new Maticsoft.Model.test();
            model.measureb = measureb;
            model.time     = time;
            model.step1    = step1;
            model.step2    = step2;
            model.step3    = step3;
            model.step4    = step4;
            model.step5    = step5;
            model.OKorNG   = OKorNG;

            Maticsoft.BLL.test bll = new Maticsoft.BLL.test();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }