コード例 #1
0
        /// <summary>
        /// 添加一条数据
        /// </summary>
        /// <param name="model">数据实体</param>
        /// <returns></returns>
        public int Add(Models.APP.Personal model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@m_id",         model.m_id),
                    new SqlParameter("@name",         model.name),
                    new SqlParameter("@phon",         model.phon),
                    new SqlParameter("@sex",          model.sex),
                    new SqlParameter("@age",          model.age),
                    new SqlParameter("@company",      model.company),
                    new SqlParameter("@createtime",   model.createtime),
                    new SqlParameter("@modifytime",   model.modifytime),
                    new SqlParameter("@professional", model.professional)
                };
                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"INSERT INTO App_Personal(
			                        m_id
						            ,name
						            ,phon
						            ,sex
						            ,age
						            ,company
						            ,createtime
						            ,modifytime
                                    ,professional
						  ) VALUES(
									@m_id
									,@name
									,@phon
									,@sex
									,@age
									,@company
									,@createtime
									,@modifytime
                                    ,@professional
					)"                    );

                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Add()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Add()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Add()发生Exception", ex);
            }
            return(-1);
        }
コード例 #2
0
        /// <summary>
        /// 修改一个实体
        /// </summary>
        /// <param name="_entity"></param>
        /// <returns></returns>
        public int Update(Models.APP.Personal model)
        {
            try
            {
                SqlParameter[] para =
                {
                    new SqlParameter("@p_id",         model.p_id),
                    new SqlParameter("@m_id",         model.m_id),
                    new SqlParameter("@name",         model.name),
                    new SqlParameter("@phon",         model.phon),
                    new SqlParameter("@sex",          model.sex),
                    new SqlParameter("@age",          model.age),
                    new SqlParameter("@company",      model.company),
                    new SqlParameter("@createtime",   model.createtime),
                    new SqlParameter("@modifytime",   model.modifytime),
                    new SqlParameter("@professional", model.professional)
                };

                StringBuilder cmdText = new StringBuilder();
                cmdText.Append(@"UPDATE [App_Personal]
								SET [m_id]=@m_id
									   ,[name]=@name
							       ,[phon]=@phon
							       ,[sex]=@sex
							       ,[age]=@age
							       ,[company]=@company
							       ,[createtime]=@createtime
							       ,[modifytime]=@modifytime
                                   ,[professional]=@professional
							  WHERE [p_id]=@p_id"                            );
                return(SqlHelper.ExecuteNonQuery(DefaultConnection.ConnectionStringByDefaultDB, CommandType.Text, cmdText.ToString(), para));
            }
            catch (ArgumentNullException ex)
            {
                logger.Error("调用方法Update()发生ArgumentNullException", ex);
            }
            catch (SqlException ex)
            {
                logger.Error("调用方法Update()发生SqlException", ex);
            }
            catch (Exception ex)
            {
                logger.Error("调用方法Update()发生Exception", ex);
            }
            return(-1);
        }
コード例 #3
0
ファイル: Personal.cs プロジェクト: lodiliu/App-Project-ay
 /// <summary>
 /// 修改一个实体
 /// </summary>
 /// <param name="_entity"></param>
 /// <returns></returns>
 public int Update(Models.APP.Personal model)
 {
     return(dal.Update(model));
 }
コード例 #4
0
ファイル: Personal.cs プロジェクト: lodiliu/App-Project-ay
 /// <summary>
 /// 添加一条数据
 /// </summary>
 /// <param name="model">数据实体</param>
 /// <returns></returns>
 public int Add(Models.APP.Personal model)
 {
     return(dal.Add(model));
 }