示例#1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(ToolYesOrNoData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into ToolYesOrNo(");
            strSql.Append("yesOrNo,yesOrNoDesc)");
            strSql.Append(" values (");
            strSql.Append("@yesOrNo,@yesOrNoDesc)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@yesOrNo", SqlDbType.Int),
                    new SqlParameter("@yesOrNoDesc", SqlDbType.NVarChar,20)
                };
            parameters[0].Value = model.yesOrNo;
            parameters[1].Value = model.yesOrNoDesc;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
示例#2
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(ToolYesOrNoData model)
 {
     return this.oolYesOrNoDB.ModifyRecord(model);
 }
示例#3
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(ToolYesOrNoData model)
 {
     return this.oolYesOrNoDB.AddRecord(model);
 }
示例#4
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(ToolYesOrNoData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update ToolYesOrNo set ");
            strSql.Append("yesOrNoDesc=@yesOrNoDesc");
            strSql.Append(" where yesOrNo = @yesOrNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@yesOrNo", SqlDbType.Int),
                    new SqlParameter("@yesOrNoDesc", SqlDbType.NVarChar,20)
                };
            parameters[0].Value = model.yesOrNo;
            parameters[1].Value = model.yesOrNoDesc;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
示例#5
0
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="yesOrNo">����ֵ</param>
        /// <returns>model</returns>
        public ToolYesOrNoData GetModel(int yesOrNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from ToolYesOrNo");
            strSql.Append(" where yesOrNo = @yesOrNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@yesOrNo", SqlDbType.Int)
                };
            parameters[0].Value = yesOrNo;

            ToolYesOrNoData model = new ToolYesOrNoData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["yesOrNo"] != DBNull.Value)
                {
                    model.yesOrNo = Convert.ToInt32(row["yesOrNo"]);
                }
                if (row["yesOrNoDesc"] != DBNull.Value)
                {
                    model.yesOrNoDesc = Convert.ToString(row["yesOrNoDesc"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }