Esempio n. 1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtMeterID.Text))
            {
                strErr += "MeterID格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtBookIDBefore.Text))
            {
                strErr += "BookIDBefore格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtBookNumBefore.Text))
            {
                strErr += "BookNumBefore格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtBookIDAfter.Text))
            {
                strErr += "BookIDAfter格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtBookNumAfter.Text))
            {
                strErr += "BookNumAfter格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtOperTime.Text))
            {
                strErr += "OperTime格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      ID            = int.Parse(this.lblID.Text);
            int      MeterID       = int.Parse(this.txtMeterID.Text);
            int      BookIDBefore  = int.Parse(this.txtBookIDBefore.Text);
            int      BookNumBefore = int.Parse(this.txtBookNumBefore.Text);
            int      BookIDAfter   = int.Parse(this.txtBookIDAfter.Text);
            int      BookNumAfter  = int.Parse(this.txtBookNumAfter.Text);
            DateTime OperTime      = DateTime.Parse(this.txtOperTime.Text);


            WebDemo.Model.WebDemo.SwitchBookLog model = new WebDemo.Model.WebDemo.SwitchBookLog();
            model.ID            = ID;
            model.MeterID       = MeterID;
            model.BookIDBefore  = BookIDBefore;
            model.BookNumBefore = BookNumBefore;
            model.BookIDAfter   = BookIDAfter;
            model.BookNumAfter  = BookNumAfter;
            model.OperTime      = OperTime;

            WebDemo.BLL.WebDemo.SwitchBookLog bll = new WebDemo.BLL.WebDemo.SwitchBookLog();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Esempio n. 2
0
 private void ShowInfo(int ID)
 {
     WebDemo.BLL.WebDemo.SwitchBookLog   bll   = new WebDemo.BLL.WebDemo.SwitchBookLog();
     WebDemo.Model.WebDemo.SwitchBookLog model = bll.GetModel(ID);
     this.lblID.Text            = model.ID.ToString();
     this.lblMeterID.Text       = model.MeterID.ToString();
     this.lblBookIDBefore.Text  = model.BookIDBefore.ToString();
     this.lblBookNumBefore.Text = model.BookNumBefore.ToString();
     this.lblBookIDAfter.Text   = model.BookIDAfter.ToString();
     this.lblBookNumAfter.Text  = model.BookNumAfter.ToString();
     this.lblOperTime.Text      = model.OperTime.ToString();
 }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WebDemo.Model.WebDemo.SwitchBookLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update SwitchBookLog set ");
            strSql.Append("MeterID=@MeterID,");
            strSql.Append("BookIDBefore=@BookIDBefore,");
            strSql.Append("BookNumBefore=@BookNumBefore,");
            strSql.Append("BookIDAfter=@BookIDAfter,");
            strSql.Append("BookNumAfter=@BookNumAfter,");
            strSql.Append("OperTime=@OperTime");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MeterID",       SqlDbType.Int,       4),
                new SqlParameter("@BookIDBefore",  SqlDbType.Int,       4),
                new SqlParameter("@BookNumBefore", SqlDbType.Int,       4),
                new SqlParameter("@BookIDAfter",   SqlDbType.Int,       4),
                new SqlParameter("@BookNumAfter",  SqlDbType.Int,       4),
                new SqlParameter("@OperTime",      SqlDbType.DateTime),
                new SqlParameter("@ID",            SqlDbType.Int, 4)
            };
            parameters[0].Value = model.MeterID;
            parameters[1].Value = model.BookIDBefore;
            parameters[2].Value = model.BookNumBefore;
            parameters[3].Value = model.BookIDAfter;
            parameters[4].Value = model.BookNumAfter;
            parameters[5].Value = model.OperTime;
            parameters[6].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(WebDemo.Model.WebDemo.SwitchBookLog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into SwitchBookLog(");
            strSql.Append("MeterID,BookIDBefore,BookNumBefore,BookIDAfter,BookNumAfter,OperTime)");
            strSql.Append(" values (");
            strSql.Append("@MeterID,@BookIDBefore,@BookNumBefore,@BookIDAfter,@BookNumAfter,@OperTime)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MeterID",       SqlDbType.Int, 4),
                new SqlParameter("@BookIDBefore",  SqlDbType.Int, 4),
                new SqlParameter("@BookNumBefore", SqlDbType.Int, 4),
                new SqlParameter("@BookIDAfter",   SqlDbType.Int, 4),
                new SqlParameter("@BookNumAfter",  SqlDbType.Int, 4),
                new SqlParameter("@OperTime",      SqlDbType.DateTime)
            };
            parameters[0].Value = model.MeterID;
            parameters[1].Value = model.BookIDBefore;
            parameters[2].Value = model.BookNumBefore;
            parameters[3].Value = model.BookIDAfter;
            parameters[4].Value = model.BookNumAfter;
            parameters[5].Value = model.OperTime;

            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.SwitchBookLog DataRowToModel(DataRow row)
 {
     WebDemo.Model.WebDemo.SwitchBookLog model = new WebDemo.Model.WebDemo.SwitchBookLog();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["MeterID"] != null && row["MeterID"].ToString() != "")
         {
             model.MeterID = int.Parse(row["MeterID"].ToString());
         }
         if (row["BookIDBefore"] != null && row["BookIDBefore"].ToString() != "")
         {
             model.BookIDBefore = int.Parse(row["BookIDBefore"].ToString());
         }
         if (row["BookNumBefore"] != null && row["BookNumBefore"].ToString() != "")
         {
             model.BookNumBefore = int.Parse(row["BookNumBefore"].ToString());
         }
         if (row["BookIDAfter"] != null && row["BookIDAfter"].ToString() != "")
         {
             model.BookIDAfter = int.Parse(row["BookIDAfter"].ToString());
         }
         if (row["BookNumAfter"] != null && row["BookNumAfter"].ToString() != "")
         {
             model.BookNumAfter = int.Parse(row["BookNumAfter"].ToString());
         }
         if (row["OperTime"] != null && row["OperTime"].ToString() != "")
         {
             model.OperTime = DateTime.Parse(row["OperTime"].ToString());
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WebDemo.Model.WebDemo.SwitchBookLog GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,MeterID,BookIDBefore,BookNumBefore,BookIDAfter,BookNumAfter,OperTime from SwitchBookLog ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.Int, 4)
            };
            parameters[0].Value = ID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }