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

            if(strErr!="")
            {
                MessageBox.Show(this,strErr);
                return;
            }
            string Name=this.txtName.Text;
            int CollegeId=int.Parse(this.txtCollegeId.Text);

            Eva.Model.Major model=new Eva.Model.Major();
            model.Name=Name;
            model.CollegeId=CollegeId;

            Eva.BLL.Major bll=new Eva.BLL.Major();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功!","add.aspx");
        }
Ejemplo n.º 2
0
        public Eva.Model.Major GetModelByCollegeId(int Id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 Id,Name,CollegeId from Major ");
            strSql.Append(" where CollegeId=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

            Eva.Model.Major model = new Eva.Model.Major();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["Id"] != null && ds.Tables[0].Rows[0]["Id"].ToString() != "")
                {
                    model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Name"] != null && ds.Tables[0].Rows[0]["Name"].ToString() != "")
                {
                    model.Name = ds.Tables[0].Rows[0]["Name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["CollegeId"] != null && ds.Tables[0].Rows[0]["CollegeId"].ToString() != "")
                {
                    model.CollegeId = int.Parse(ds.Tables[0].Rows[0]["CollegeId"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Ejemplo n.º 3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     string strErr = "";
     if (CollegeList.SelectedValue=="0")
     {
         strErr += "请选择学院!";
     }
     if (txtMajor.Text.Trim().Length==0)
     {
         strErr += "专业不能为空!";
     }
     if (strErr!="")
     {
         Maticsoft.Common.MessageBox.Show(this, strErr);
         return;
     }
     int id = int.Parse(Request["id"]);
     major=bllMajor.GetModel(id);
     major.CollegeId = int.Parse(CollegeList.SelectedValue);
     major.Name = txtMajor.Text;
     if (bllMajor.Update(major))
     {
         Maticsoft.Common.MessageBox.Show(this, "修改成功!");
     }
     else {
         Maticsoft.Common.MessageBox.Show(this, "修改失败!");
     }
 }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = int.Parse(Request["id"]);
                var dsMa = bllMajor.GetAllList();
                var dsCo = bllCollege.GetAllList();

                major = bllMajor.GetModel(id);

                CollegeList.DataSource = dsCo.Tables["ds"].DefaultView;
                CollegeList.DataTextField = "Name";
                CollegeList.DataValueField = "Id";
                CollegeList.DataBind();

                CollegeList.Items.FindByValue(major.CollegeId.ToString()).Selected = true;
                txtMajor.Text = major.Name;

            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Eva.Model.Major DataRowToModel(DataRow row)
 {
     Eva.Model.Major model=new Eva.Model.Major();
     if (row != null)
     {
         if(row["Id"]!=null && row["Id"].ToString()!="")
         {
             model.Id=int.Parse(row["Id"].ToString());
         }
         if(row["Name"]!=null)
         {
             model.Name=row["Name"].ToString();
         }
         if(row["CollegeId"]!=null && row["CollegeId"].ToString()!="")
         {
             model.CollegeId=int.Parse(row["CollegeId"].ToString());
         }
     }
     return model;
 }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var CollegeDS = bllCollege.GetAllList();
                int id = int.Parse(Request["id"]);
                classes = bllClass.GetModel(id);
                major = bllMajor.GetModel(Convert.ToInt16(classes.MajorId));

                CollegeList.DataSource = CollegeDS.Tables["ds"].DefaultView;
                CollegeList.DataTextField = "Name";
                CollegeList.DataValueField = "Id";
                CollegeList.DataBind();

                CollegeList.Items.FindByValue(major.CollegeId.ToString()).Selected = true;
                LoadMajor();

                MajorList.Items.FindByValue(classes.MajorId.ToString()).Selected = true;
                txtClass.Text = classes.Name;

            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Eva.Model.Major GetModel(int Id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 Id,Name,CollegeId from Major ");
            strSql.Append(" where Id=@Id");
            SqlParameter[] parameters = {
                    new SqlParameter("@Id", SqlDbType.Int,4)
            };
            parameters[0].Value = Id;

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