コード例 #1
0
ファイル: TC.cs プロジェクト: YLD10/VisualStudio_Projects
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.TC model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TC set ");
            strSql.Append("teaID=@teaID,");
            strSql.Append("couID=@couID");
            strSql.Append(" where couID=@couID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@teaID", SqlDbType.VarChar, 15),
                new SqlParameter("@couID", SqlDbType.VarChar, 15)
            };
            parameters[0].Value = model.teaID;
            parameters[1].Value = model.couID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
ファイル: TC.cs プロジェクト: YLD10/VisualStudio_Projects
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.TC model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TC(");
            strSql.Append("teaID,couID)");
            strSql.Append(" values (");
            strSql.Append("@teaID,@couID)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@teaID", SqlDbType.VarChar, 15),
                new SqlParameter("@couID", SqlDbType.VarChar, 15)
            };
            parameters[0].Value = model.teaID;
            parameters[1].Value = model.couID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
ファイル: TC.cs プロジェクト: YLD10/VisualStudio_Projects
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.TC GetModel(string teaID, string couID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 teaID,couID from TC ");
            strSql.Append(" where teaID=@teaID and couID=@couID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@teaID", SqlDbType.VarChar, 15),
                new SqlParameter("@couID", SqlDbType.VarChar, 15)
            };
            parameters[0].Value = teaID;
            parameters[1].Value = couID;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #4
0
ファイル: TC.cs プロジェクト: YLD10/VisualStudio_Projects
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.TC DataRowToModel(DataRow row)
 {
     Maticsoft.Model.TC model = new Maticsoft.Model.TC();
     if (row != null)
     {
         if (row["teaID"] != null)
         {
             model.teaID = row["teaID"].ToString();
         }
         if (row["couID"] != null)
         {
             model.couID = row["couID"].ToString();
         }
     }
     return(model);
 }
コード例 #5
0
        private void btConfirm_Click(object sender, EventArgs e)
        {
            Maticsoft.Model.TC model = new Maticsoft.Model.TC();
            model.couID = Maticsoft.Common.StaticDataClass.course.ID;
            model.teaID = (string)combID.SelectedValue;

            if (new Maticsoft.BLL.TC().Exists(model.teaID, model.couID))
            {
                MessageBox.Show("此教师不能重复教授同一门课!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                if (new Maticsoft.BLL.TC().Add(model))
                {
                    MessageBox.Show("添加成功!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ((CouTea)this.Owner).LoadData_TC();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("添加失败!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }