Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CZZD.ERP.Model.BaseCompanyTable model)
        {
            StringBuilder strSql = null;
            int           rows   = 0;

            if (Exists(model.CODE))
            {
                #region 更新
                strSql = new StringBuilder();
                strSql.Append("update BASE_COMPANY set ");
                strSql.Append("NAME=@NAME,");
                strSql.Append("NAME_SHORT=@NAME_SHORT,");
                strSql.Append("NAME_ENGLISH=@NAME_ENGLISH,");
                strSql.Append("ZIP_CODE=@ZIP_CODE,");
                strSql.Append("ADDRESS_FIRST=@ADDRESS_FIRST,");
                strSql.Append("ADDRESS_MIDDLE=@ADDRESS_MIDDLE,");
                strSql.Append("ADDRESS_LAST=@ADDRESS_LAST,");
                strSql.Append("PHONE_NUMBER=@PHONE_NUMBER,");
                strSql.Append("FAX_NUMBER=@FAX_NUMBER,");
                strSql.Append("EMAIL=@EMAIL,");
                strSql.Append("URL=@URL,");
                strSql.Append("MEMO=@MEMO,");
                strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
                strSql.Append("CREATE_USER=@CREATE_USER,");
                strSql.Append("CREATE_DATE_TIME=GETDATE(),");
                strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
                strSql.Append("LAST_UPDATE_TIME=GETDATE()");
                strSql.Append(" where CODE=@CODE ");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                    new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                    new SqlParameter("@NAME_SHORT",       SqlDbType.NVarChar,  50),
                    new SqlParameter("@NAME_ENGLISH",     SqlDbType.VarChar,   50),
                    new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                    new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                    new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                    new SqlParameter("@EMAIL",            SqlDbType.VarChar,   50),
                    new SqlParameter("@URL",              SqlDbType.VarChar,   50),
                    new SqlParameter("@MEMO",             SqlDbType.NVarChar, 255),
                    new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                    new SqlParameter("@CREATE_USER",      SqlDbType.VarChar,   20),
                    new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
                };
                parameters[0].Value  = model.CODE;
                parameters[1].Value  = model.NAME;
                parameters[2].Value  = model.NAME_SHORT;
                parameters[3].Value  = model.NAME_ENGLISH;
                parameters[4].Value  = model.ZIP_CODE;
                parameters[5].Value  = model.ADDRESS_FIRST;
                parameters[6].Value  = model.ADDRESS_MIDDLE;
                parameters[7].Value  = model.ADDRESS_LAST;
                parameters[8].Value  = model.PHONE_NUMBER;
                parameters[9].Value  = model.FAX_NUMBER;
                parameters[10].Value = model.EMAIL;
                parameters[11].Value = model.URL;
                parameters[12].Value = model.MEMO;
                parameters[13].Value = CConstant.NORMAL_STATUS;
                parameters[14].Value = model.CREATE_USER;
                parameters[15].Value = model.LAST_UPDATE_USER;
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            else
            {
                #region 增加
                strSql = new StringBuilder();
                strSql.Append("insert into BASE_COMPANY(");
                strSql.Append("CODE,NAME,NAME_SHORT,NAME_ENGLISH,ZIP_CODE,ADDRESS_FIRST,ADDRESS_MIDDLE,ADDRESS_LAST,PHONE_NUMBER,FAX_NUMBER,EMAIL,URL,MEMO,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME)");
                strSql.Append(" values (");
                strSql.Append("@CODE,@NAME,@NAME_SHORT,@NAME_ENGLISH,@ZIP_CODE,@ADDRESS_FIRST,@ADDRESS_MIDDLE,@ADDRESS_LAST,@PHONE_NUMBER,@FAX_NUMBER,@EMAIL,@URL,@MEMO,@STATUS_FLAG,@CREATE_USER,GETDATE(),@LAST_UPDATE_USER,GETDATE())");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                    new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                    new SqlParameter("@NAME_SHORT",       SqlDbType.NVarChar,  50),
                    new SqlParameter("@NAME_ENGLISH",     SqlDbType.VarChar,   50),
                    new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                    new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                    new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                    new SqlParameter("@EMAIL",            SqlDbType.VarChar,   50),
                    new SqlParameter("@URL",              SqlDbType.VarChar,   50),
                    new SqlParameter("@MEMO",             SqlDbType.NVarChar, 255),
                    new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                    new SqlParameter("@CREATE_USER",      SqlDbType.VarChar,   20),
                    new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
                };
                parameters[0].Value  = model.CODE;
                parameters[1].Value  = model.NAME;
                parameters[2].Value  = model.NAME_SHORT;
                parameters[3].Value  = model.NAME_ENGLISH;
                parameters[4].Value  = model.ZIP_CODE;
                parameters[5].Value  = model.ADDRESS_FIRST;
                parameters[6].Value  = model.ADDRESS_MIDDLE;
                parameters[7].Value  = model.ADDRESS_LAST;
                parameters[8].Value  = model.PHONE_NUMBER;
                parameters[9].Value  = model.FAX_NUMBER;
                parameters[10].Value = model.EMAIL;
                parameters[11].Value = model.URL;
                parameters[12].Value = model.MEMO;
                parameters[13].Value = CConstant.INIT_STATUS;
                parameters[14].Value = model.CREATE_USER;
                parameters[15].Value = model.LAST_UPDATE_USER;
                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            if (rows > 0)
            {
                CCacheData.Company = null;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CZZD.ERP.Model.BaseCompanyTable model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_COMPANY set ");
            strSql.Append("NAME=@NAME,");
            strSql.Append("NAME_SHORT=@NAME_SHORT,");
            strSql.Append("NAME_ENGLISH=@NAME_ENGLISH,");
            strSql.Append("ZIP_CODE=@ZIP_CODE,");
            strSql.Append("ADDRESS_FIRST=@ADDRESS_FIRST,");
            strSql.Append("ADDRESS_MIDDLE=@ADDRESS_MIDDLE,");
            strSql.Append("ADDRESS_LAST=@ADDRESS_LAST,");
            strSql.Append("PHONE_NUMBER=@PHONE_NUMBER,");
            strSql.Append("FAX_NUMBER=@FAX_NUMBER,");
            strSql.Append("EMAIL=@EMAIL,");
            strSql.Append("URL=@URL,");
            strSql.Append("MEMO=@MEMO,");
            strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
            strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
            strSql.Append("LAST_UPDATE_TIME=GETDATE()");
            strSql.Append(" where CODE=@CODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CODE",             SqlDbType.VarChar,   20),
                new SqlParameter("@NAME",             SqlDbType.NVarChar, 100),
                new SqlParameter("@NAME_SHORT",       SqlDbType.NVarChar,  50),
                new SqlParameter("@NAME_ENGLISH",     SqlDbType.VarChar,   50),
                new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                new SqlParameter("@EMAIL",            SqlDbType.VarChar,   50),
                new SqlParameter("@URL",              SqlDbType.VarChar,   50),
                new SqlParameter("@MEMO",             SqlDbType.NVarChar, 255),
                new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
            };
            parameters[0].Value  = model.CODE;
            parameters[1].Value  = model.NAME;
            parameters[2].Value  = model.NAME_SHORT;
            parameters[3].Value  = model.NAME_ENGLISH;
            parameters[4].Value  = model.ZIP_CODE;
            parameters[5].Value  = model.ADDRESS_FIRST;
            parameters[6].Value  = model.ADDRESS_MIDDLE;
            parameters[7].Value  = model.ADDRESS_LAST;
            parameters[8].Value  = model.PHONE_NUMBER;
            parameters[9].Value  = model.FAX_NUMBER;
            parameters[10].Value = model.EMAIL;
            parameters[11].Value = model.URL;
            parameters[12].Value = model.MEMO;
            parameters[13].Value = model.STATUS_FLAG;
            parameters[14].Value = model.LAST_UPDATE_USER;

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

            if (rows > 0)
            {
                CCacheData.Company = null;
                return(true);
            }
            else
            {
                return(false);
            }
        }