Esempio n. 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public JiaJiao.Model.RegInfo DataRowToModel(DataRow row)
 {
     JiaJiao.Model.RegInfo model=new JiaJiao.Model.RegInfo();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=int.Parse(row["ID"].ToString());
         }
         if(row["TeacherId"]!=null && row["TeacherId"].ToString()!="")
         {
             model.TeacherId=int.Parse(row["TeacherId"].ToString());
         }
         if(row["DayId"]!=null && row["DayId"].ToString()!="")
         {
             model.DayId=int.Parse(row["DayId"].ToString());
         }
         if(row["StuId"]!=null)
         {
             model.StuId=row["StuId"].ToString();
         }
         if(row["CreateTime"]!=null && row["CreateTime"].ToString()!="")
         {
             model.CreateTime=DateTime.Parse(row["CreateTime"].ToString());
         }
         if(row["UpdateTime"]!=null && row["UpdateTime"].ToString()!="")
         {
             model.UpdateTime=DateTime.Parse(row["UpdateTime"].ToString());
         }
     }
     return model;
 }
Esempio n. 2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(!PageValidate.IsNumber(txtTeacherId.Text))
            {
                strErr+="TeacherId格式错误!\\n";
            }
            if(!PageValidate.IsNumber(txtDayId.Text))
            {
                strErr+="DayId格式错误!\\n";
            }
            if(this.txtStuId.Text.Trim().Length==0)
            {
                strErr+="StuId不能为空!\\n";
            }
            if(!PageValidate.IsDateTime(txtCreateTime.Text))
            {
                strErr+="CreateTime格式错误!\\n";
            }
            if(!PageValidate.IsDateTime(txtUpdateTime.Text))
            {
                strErr+="UpdateTime格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            int ID=int.Parse(this.lblID.Text);
            int TeacherId=int.Parse(this.txtTeacherId.Text);
            int DayId=int.Parse(this.txtDayId.Text);
            string StuId=this.txtStuId.Text;
            DateTime CreateTime=DateTime.Parse(this.txtCreateTime.Text);
            DateTime UpdateTime=DateTime.Parse(this.txtUpdateTime.Text);

            JiaJiao.Model.RegInfo model=new JiaJiao.Model.RegInfo();
            model.ID=ID;
            model.TeacherId=TeacherId;
            model.DayId=DayId;
            model.StuId=StuId;
            model.CreateTime=CreateTime;
            model.UpdateTime=UpdateTime;

            JiaJiao.BLL.RegInfo bll=new JiaJiao.BLL.RegInfo();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","list.aspx");
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public JiaJiao.Model.RegInfo GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 ID,TeacherId,DayId,StuId,CreateTime,UpdateTime from RegInfo ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)
            };
            parameters[0].Value = ID;

            JiaJiao.Model.RegInfo model=new JiaJiao.Model.RegInfo();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                return DataRowToModel(ds.Tables[0].Rows[0]);
            }
            else
            {
                return null;
            }
        }