Esempio n. 1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(PTeamData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into PTeam(");
            strSql.Append("teamNm,teamLeadEmpId,isrtDt,isrtEmpId)");
            strSql.Append(" values (");
            strSql.Append("@teamNm,@teamLeadEmpId,@isrtDt,@isrtEmpId)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@teamNm", SqlDbType.NVarChar,20),
                    new SqlParameter("@teamLeadEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int)
                };
            parameters[0].Value = model.teamNm;
            parameters[1].Value = model.teamLeadEmpId;
            parameters[2].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[3].Value = model.isrtEmpId;

            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;
        }
Esempio n. 2
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(PTeamData model)
 {
     return this.teamDB.ModifyRecord(model);
 }
Esempio n. 3
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(PTeamData model)
 {
     return this.teamDB.AddRecord(model);
 }
Esempio n. 4
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(PTeamData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update PTeam set ");
            strSql.Append("teamNm=@teamNm,");
            strSql.Append("teamLeadEmpId=@teamLeadEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("isrtEmpId=@isrtEmpId");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@teamNm", SqlDbType.NVarChar,20),
                    new SqlParameter("@teamLeadEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.teamNm;
            parameters[2].Value = model.teamLeadEmpId;
            parameters[3].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[4].Value = model.isrtEmpId;

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

            PTeamData model = new PTeamData();
            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["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["teamNm"] != DBNull.Value)
                {
                    model.teamNm = Convert.ToString(row["teamNm"]);
                }
                if (row["teamLeadEmpId"] != DBNull.Value)
                {
                    model.teamLeadEmpId = Convert.ToInt32(row["teamLeadEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }