Пример #1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(SFileOriginTypeData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into SFileOriginType(");
            strSql.Append("typeNo,typeNm,itemNo,isSys,mark,isrtEmpId,isrtDt,updtEmpId,updtDt)");
            strSql.Append(" values (");
            strSql.Append("@typeNo,@typeNm,@itemNo,@isSys,@mark,@isrtEmpId,@isrtDt,@updtEmpId,@updtDt)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@typeNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@typeNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@itemNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSys", SqlDbType.Bit),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.typeNo;
            parameters[1].Value = model.typeNm;
            parameters[2].Value = model.itemNo;
            parameters[3].Value = model.isSys;
            parameters[4].Value = model.mark;
            parameters[5].Value = model.isrtEmpId;
            parameters[6].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[7].Value = model.updtEmpId;
            parameters[8].Value = model.updtDt == string.Empty ? null : model.updtDt;

            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(SFileOriginTypeData model)
 {
     return this.fileOriginTypeDB.ModifyRecord(model);
 }
Пример #3
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(SFileOriginTypeData model)
 {
     return this.fileOriginTypeDB.AddRecord(model);
 }
Пример #4
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(SFileOriginTypeData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update SFileOriginType set ");
            strSql.Append("typeNm=@typeNm,");
            strSql.Append("itemNo=@itemNo,");
            strSql.Append("isSys=@isSys,");
            strSql.Append("mark=@mark,");
            strSql.Append("isrtEmpId=@isrtEmpId,");
            strSql.Append("isrtDt=@isrtDt,");
            strSql.Append("updtEmpId=@updtEmpId,");
            strSql.Append("updtDt=@updtDt");
            strSql.Append(" where typeNo = @typeNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@typeNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@typeNm", SqlDbType.NVarChar,50),
                    new SqlParameter("@itemNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@isSys", SqlDbType.Bit),
                    new SqlParameter("@mark", SqlDbType.NVarChar,500),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime)
                };
            parameters[0].Value = model.typeNo;
            parameters[1].Value = model.typeNm;
            parameters[2].Value = model.itemNo;
            parameters[3].Value = model.isSys;
            parameters[4].Value = model.mark;
            parameters[5].Value = model.isrtEmpId;
            parameters[6].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[7].Value = model.updtEmpId;
            parameters[8].Value = model.updtDt == string.Empty ? null : model.updtDt;

            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="typeNo">����ֵ</param>
        /// <returns>model</returns>
        public SFileOriginTypeData GetModel(string typeNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select * from SFileOriginType");
            strSql.Append(" where typeNo = @typeNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@typeNo", SqlDbType.NVarChar,20)
                };
            parameters[0].Value = typeNo;

            SFileOriginTypeData model = new SFileOriginTypeData();
            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["typeNo"] != DBNull.Value)
                {
                    model.typeNo = Convert.ToString(row["typeNo"]);
                }
                if (row["typeNm"] != DBNull.Value)
                {
                    model.typeNm = Convert.ToString(row["typeNm"]);
                }
                if (row["itemNo"] != DBNull.Value)
                {
                    model.itemNo = Convert.ToString(row["itemNo"]);
                }
                if (row["isSys"] != DBNull.Value)
                {
                    model.isSys = Convert.ToBoolean(row["isSys"]);
                }
                if (row["mark"] != DBNull.Value)
                {
                    model.mark = Convert.ToString(row["mark"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }