Ejemplo n.º 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr="";
            if(this.txtEmployeeName.Text.Trim().Length==0)
            {
                strErr+="EmployeeName不能为空!\\n";
            }
            if(this.txtEmployeeNo.Text.Trim().Length==0)
            {
                strErr+="EmployeeNo不能为空!\\n";
            }
            if(!PageValidate.IsNumber(txtEmployeeID.Text))
            {
                strErr+="EmployeeID格式错误!\\n";
            }

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            string EmployeeName=this.txtEmployeeName.Text;
            string EmployeeNo=this.txtEmployeeNo.Text;
            int EmployeeID=int.Parse(this.txtEmployeeID.Text);

            RuRo.Model.EmployeeInfo model=new RuRo.Model.EmployeeInfo();
            model.EmployeeName=EmployeeName;
            model.EmployeeNo=EmployeeNo;
            model.EmployeeID=EmployeeID;

            RuRo.BLL.EmployeeInfo bll=new RuRo.BLL.EmployeeInfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public RuRo.Model.EmployeeInfo DataRowToModel(DataRow row)
 {
     RuRo.Model.EmployeeInfo model=new RuRo.Model.EmployeeInfo();
     if (row != null)
     {
         if(row["id"]!=null && row["id"].ToString()!="")
         {
             model.id=int.Parse(row["id"].ToString());
         }
         if(row["EmployeeName"]!=null)
         {
             model.EmployeeName=row["EmployeeName"].ToString();
         }
         if(row["EmployeeNo"]!=null)
         {
             model.EmployeeNo=row["EmployeeNo"].ToString();
         }
         if(row["EmployeeID"]!=null && row["EmployeeID"].ToString()!="")
         {
             model.EmployeeID=int.Parse(row["EmployeeID"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public RuRo.Model.EmployeeInfo GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,EmployeeName,EmployeeNo,EmployeeID from EmployeeInfo ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)
            };
            parameters[0].Value = id;

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