Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public zs.Model.Tbl_Chaxun GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,stuno,ksno,cardid,score,luquxueyuan,luquzhuanye,kstype from Tbl_Chaxun ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            zs.Model.Tbl_Chaxun model = new zs.Model.Tbl_Chaxun();
            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]["stuno"] != null && ds.Tables[0].Rows[0]["stuno"].ToString() != "")
                {
                    model.stuno = ds.Tables[0].Rows[0]["stuno"].ToString();
                }
                if (ds.Tables[0].Rows[0]["ksno"] != null && ds.Tables[0].Rows[0]["ksno"].ToString() != "")
                {
                    model.ksno = ds.Tables[0].Rows[0]["ksno"].ToString();
                }
                if (ds.Tables[0].Rows[0]["cardid"] != null && ds.Tables[0].Rows[0]["cardid"].ToString() != "")
                {
                    model.cardid = ds.Tables[0].Rows[0]["cardid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["score"] != null && ds.Tables[0].Rows[0]["score"].ToString() != "")
                {
                    model.score = ds.Tables[0].Rows[0]["score"].ToString();
                }
                if (ds.Tables[0].Rows[0]["luquxueyuan"] != null && ds.Tables[0].Rows[0]["luquxueyuan"].ToString() != "")
                {
                    model.luquxueyuan = ds.Tables[0].Rows[0]["luquxueyuan"].ToString();
                }
                if (ds.Tables[0].Rows[0]["luquzhuanye"] != null && ds.Tables[0].Rows[0]["luquzhuanye"].ToString() != "")
                {
                    model.luquzhuanye = ds.Tables[0].Rows[0]["luquzhuanye"].ToString();
                }
                if (ds.Tables[0].Rows[0]["kstype"] != null && ds.Tables[0].Rows[0]["kstype"].ToString() != "")
                {
                    model.kstype = ds.Tables[0].Rows[0]["kstype"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
 private void ShowInfo(int id)
 {
     zs.BLL.Tbl_Chaxun   bll   = new zs.BLL.Tbl_Chaxun();
     zs.Model.Tbl_Chaxun model = bll.GetModel(id);
     this.lblid.Text          = model.id.ToString();
     this.txtname.Text        = model.name;
     this.txtstuno.Text       = model.stuno;
     this.txtksno.Text        = model.ksno;
     this.txtcardid.Text      = model.cardid;
     this.txtscore.Text       = model.score;
     this.txtluquxueyuan.Text = model.luquxueyuan;
     this.txtluquzhuanye.Text = model.luquzhuanye;
     this.txtkstype.Text      = model.kstype;
 }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(zs.Model.Tbl_Chaxun model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Tbl_Chaxun set ");
            strSql.Append("name=@name,");
            strSql.Append("stuno=@stuno,");
            strSql.Append("ksno=@ksno,");
            strSql.Append("cardid=@cardid,");
            strSql.Append("score=@score,");
            strSql.Append("luquxueyuan=@luquxueyuan,");
            strSql.Append("luquzhuanye=@luquzhuanye,");
            strSql.Append("kstype=@kstype");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",        SqlDbType.VarChar, 10),
                new SqlParameter("@stuno",       SqlDbType.VarChar, 20),
                new SqlParameter("@ksno",        SqlDbType.VarChar, 50),
                new SqlParameter("@cardid",      SqlDbType.VarChar, 20),
                new SqlParameter("@score",       SqlDbType.VarChar, 10),
                new SqlParameter("@luquxueyuan", SqlDbType.VarChar, 50),
                new SqlParameter("@luquzhuanye", SqlDbType.VarChar, 50),
                new SqlParameter("@kstype",      SqlDbType.VarChar, 10),
                new SqlParameter("@id",          SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.stuno;
            parameters[2].Value = model.ksno;
            parameters[3].Value = model.cardid;
            parameters[4].Value = model.score;
            parameters[5].Value = model.luquxueyuan;
            parameters[6].Value = model.luquzhuanye;
            parameters[7].Value = model.kstype;
            parameters[8].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(zs.Model.Tbl_Chaxun model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Tbl_Chaxun(");
            strSql.Append("name,stuno,ksno,cardid,score,luquxueyuan,luquzhuanye,kstype)");
            strSql.Append(" values (");
            strSql.Append("@name,@stuno,@ksno,@cardid,@score,@luquxueyuan,@luquzhuanye,@kstype)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",        SqlDbType.VarChar, 10),
                new SqlParameter("@stuno",       SqlDbType.VarChar, 20),
                new SqlParameter("@ksno",        SqlDbType.VarChar, 50),
                new SqlParameter("@cardid",      SqlDbType.VarChar, 20),
                new SqlParameter("@score",       SqlDbType.VarChar, 10),
                new SqlParameter("@luquxueyuan", SqlDbType.VarChar, 50),
                new SqlParameter("@luquzhuanye", SqlDbType.VarChar, 50),
                new SqlParameter("@kstype",      SqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.stuno;
            parameters[2].Value = model.ksno;
            parameters[3].Value = model.cardid;
            parameters[4].Value = model.score;
            parameters[5].Value = model.luquxueyuan;
            parameters[6].Value = model.luquzhuanye;
            parameters[7].Value = model.kstype;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtname.Text.Trim().Length == 0)
            {
                strErr += "姓名不能为空!\\n";
            }
            if (this.txtstuno.Text.Trim().Length == 0)
            {
                strErr += "学号不能为空!\\n";
            }
            if (this.txtksno.Text.Trim().Length == 0)
            {
                strErr += "考试号不能为空!\\n";
            }
            if (this.txtcardid.Text.Trim().Length == 0)
            {
                strErr += "身份证号码不能为空!\\n";
            }
            if (this.txtscore.Text.Trim().Length == 0)
            {
                strErr += "分数(总分)不能为空!\\n";
            }
            if (this.txtluquxueyuan.Text.Trim().Length == 0)
            {
                strErr += "录取学院不能为空!\\n";
            }
            if (this.txtluquzhuanye.Text.Trim().Length == 0)
            {
                strErr += "录取专业不能为空!\\n";
            }
            if (this.txtkstype.Text.Trim().Length == 0)
            {
                strErr += "考试类别不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string name        = this.txtname.Text;
            string stuno       = this.txtstuno.Text;
            string ksno        = this.txtksno.Text;
            string cardid      = this.txtcardid.Text;
            string score       = this.txtscore.Text;
            string luquxueyuan = this.txtluquxueyuan.Text;
            string luquzhuanye = this.txtluquzhuanye.Text;
            string kstype      = this.txtkstype.Text;

            zs.Model.Tbl_Chaxun model = new zs.Model.Tbl_Chaxun();
            model.name        = name;
            model.stuno       = stuno;
            model.ksno        = ksno;
            model.cardid      = cardid;
            model.score       = score;
            model.luquxueyuan = luquxueyuan;
            model.luquzhuanye = luquzhuanye;
            model.kstype      = kstype;

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