Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CZZD.ERP.Model.BaseDeliveryTable model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BASE_DELIVERY set ");
            strSql.Append("ADDRESS_FIRST=@ADDRESS_FIRST,");
            strSql.Append("ADDRESS_MIDDLE=@ADDRESS_MIDDLE,");
            strSql.Append("ADDRESS_LAST=@ADDRESS_LAST,");
            strSql.Append("ZIP_CODE=@ZIP_CODE,");
            strSql.Append("PHONE_NUMBER=@PHONE_NUMBER,");
            strSql.Append("FAX_NUMBER=@FAX_NUMBER,");
            strSql.Append("MOBIL_NUMBER=@MOBIL_NUMBER,");
            strSql.Append("CONTACT_NAME=@CONTACT_NAME,");
            strSql.Append("STATUS_FLAG=@STATUS_FLAG,");
            strSql.Append("LAST_UPDATE_USER=@LAST_UPDATE_USER,");
            strSql.Append("LAST_UPDATE_TIME=GETDATE()");
            strSql.Append(" where CUSTOMER_CODE=@CUSTOMER_CODE and DELIVERY_CODE=@DELIVERY_CODE ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@CUSTOMER_CODE",    SqlDbType.VarChar,   20),
                new SqlParameter("@DELIVERY_CODE",    SqlDbType.VarChar,   20),
                new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                new SqlParameter("@MOBIL_NUMBER",     SqlDbType.VarChar,   20),
                new SqlParameter("@CONTACT_NAME",     SqlDbType.NVarChar,  50),
                new SqlParameter("@STATUS_FLAG",      SqlDbType.Int,        4),
                new SqlParameter("@LAST_UPDATE_USER", SqlDbType.VarChar, 20)
            };
            parameters[0].Value  = model.CUSTOMER_CODE;
            parameters[1].Value  = model.DELIVERY_CODE;
            parameters[2].Value  = model.ADDRESS_FIRST;
            parameters[3].Value  = model.ADDRESS_MIDDLE;
            parameters[4].Value  = model.ADDRESS_LAST;
            parameters[5].Value  = model.ZIP_CODE;
            parameters[6].Value  = model.PHONE_NUMBER;
            parameters[7].Value  = model.FAX_NUMBER;
            parameters[8].Value  = model.MOBIL_NUMBER;
            parameters[9].Value  = model.CONTACT_NAME;
            parameters[10].Value = model.STATUS_FLAG;
            parameters[11].Value = model.LAST_UPDATE_USER;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CZZD.ERP.Model.BaseDeliveryTable GetModel(string CUSTOMER_CODE, string DELIVERY_CODE)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 CUSTOMER_CODE,DELIVERY_CODE,ADDRESS_FIRST,ADDRESS_MIDDLE,ADDRESS_LAST,ZIP_CODE,PHONE_NUMBER,FAX_NUMBER,MOBIL_NUMBER,CONTACT_NAME,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME from BASE_DELIVERY ");
            strSql.Append(" where CUSTOMER_CODE=@CUSTOMER_CODE and DELIVERY_CODE=@DELIVERY_CODE ");
            strSql.AppendFormat(" and STATUS_FLAG <> {0}", CConstant.DELETE_STATUS);
            SqlParameter[] parameters =
            {
                new SqlParameter("@CUSTOMER_CODE", SqlDbType.VarChar, 50),
                new SqlParameter("@DELIVERY_CODE", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = CUSTOMER_CODE;
            parameters[1].Value = DELIVERY_CODE;

            CZZD.ERP.Model.BaseDeliveryTable model = new CZZD.ERP.Model.BaseDeliveryTable();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.CUSTOMER_CODE  = ds.Tables[0].Rows[0]["CUSTOMER_CODE"].ToString();
                model.DELIVERY_CODE  = ds.Tables[0].Rows[0]["DELIVERY_CODE"].ToString();
                model.ADDRESS_FIRST  = ds.Tables[0].Rows[0]["ADDRESS_FIRST"].ToString();
                model.ADDRESS_MIDDLE = ds.Tables[0].Rows[0]["ADDRESS_MIDDLE"].ToString();
                model.ADDRESS_LAST   = ds.Tables[0].Rows[0]["ADDRESS_LAST"].ToString();
                model.ZIP_CODE       = ds.Tables[0].Rows[0]["ZIP_CODE"].ToString();
                model.PHONE_NUMBER   = ds.Tables[0].Rows[0]["PHONE_NUMBER"].ToString();
                model.FAX_NUMBER     = ds.Tables[0].Rows[0]["FAX_NUMBER"].ToString();
                model.MOBIL_NUMBER   = ds.Tables[0].Rows[0]["MOBIL_NUMBER"].ToString();
                model.CONTACT_NAME   = ds.Tables[0].Rows[0]["CONTACT_NAME"].ToString();
                if (ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString() != "")
                {
                    model.STATUS_FLAG = int.Parse(ds.Tables[0].Rows[0]["STATUS_FLAG"].ToString());
                }
                model.CREATE_USER = ds.Tables[0].Rows[0]["CREATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString() != "")
                {
                    model.CREATE_DATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["CREATE_DATE_TIME"].ToString());
                }
                model.LAST_UPDATE_USER = ds.Tables[0].Rows[0]["LAST_UPDATE_USER"].ToString();
                if (ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString() != "")
                {
                    model.LAST_UPDATE_TIME = DateTime.Parse(ds.Tables[0].Rows[0]["LAST_UPDATE_TIME"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CZZD.ERP.Model.BaseDeliveryTable model)
        {
            StringBuilder strSql = null;
            int           rows   = 0;

            if (Exists(model.CUSTOMER_CODE, model.DELIVERY_CODE))
            {
                #region 更新
                strSql = new StringBuilder();
                strSql.Append("update BASE_DELIVERY set ");
                strSql.Append("ADDRESS_FIRST=@ADDRESS_FIRST,");
                strSql.Append("ADDRESS_MIDDLE=@ADDRESS_MIDDLE,");
                strSql.Append("ADDRESS_LAST=@ADDRESS_LAST,");
                strSql.Append("ZIP_CODE=@ZIP_CODE,");
                strSql.Append("PHONE_NUMBER=@PHONE_NUMBER,");
                strSql.Append("FAX_NUMBER=@FAX_NUMBER,");
                strSql.Append("MOBIL_NUMBER=@MOBIL_NUMBER,");
                strSql.Append("CONTACT_NAME=@CONTACT_NAME,");
                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 CUSTOMER_CODE=@CUSTOMER_CODE and DELIVERY_CODE=@DELIVERY_CODE ");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CUSTOMER_CODE",    SqlDbType.VarChar,   20),
                    new SqlParameter("@DELIVERY_CODE",    SqlDbType.VarChar,   20),
                    new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                    new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                    new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                    new SqlParameter("@MOBIL_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@CONTACT_NAME",     SqlDbType.NVarChar,  50),
                    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.CUSTOMER_CODE;
                parameters[1].Value  = model.DELIVERY_CODE;
                parameters[2].Value  = model.ADDRESS_FIRST;
                parameters[3].Value  = model.ADDRESS_MIDDLE;
                parameters[4].Value  = model.ADDRESS_LAST;
                parameters[5].Value  = model.ZIP_CODE;
                parameters[6].Value  = model.PHONE_NUMBER;
                parameters[7].Value  = model.FAX_NUMBER;
                parameters[8].Value  = model.MOBIL_NUMBER;
                parameters[9].Value  = model.CONTACT_NAME;
                parameters[10].Value = model.STATUS_FLAG;
                parameters[11].Value = model.CREATE_USER;
                parameters[12].Value = model.LAST_UPDATE_USER;

                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            else
            {
                #region 增加
                strSql = new StringBuilder();
                strSql.Append("insert into BASE_DELIVERY(");
                strSql.Append("CUSTOMER_CODE,DELIVERY_CODE,ADDRESS_FIRST,ADDRESS_MIDDLE,ADDRESS_LAST,ZIP_CODE,PHONE_NUMBER,FAX_NUMBER,MOBIL_NUMBER,CONTACT_NAME,STATUS_FLAG,CREATE_USER,CREATE_DATE_TIME,LAST_UPDATE_USER,LAST_UPDATE_TIME)");
                strSql.Append(" values (");
                strSql.Append("@CUSTOMER_CODE,@DELIVERY_CODE,@ADDRESS_FIRST,@ADDRESS_MIDDLE,@ADDRESS_LAST,@ZIP_CODE,@PHONE_NUMBER,@FAX_NUMBER,@MOBIL_NUMBER,@CONTACT_NAME,@STATUS_FLAG,@CREATE_USER,GETDATE(),@LAST_UPDATE_USER,GETDATE())");
                SqlParameter[] parameters =
                {
                    new SqlParameter("@CUSTOMER_CODE",    SqlDbType.VarChar,   20),
                    new SqlParameter("@DELIVERY_CODE",    SqlDbType.VarChar,   20),
                    new SqlParameter("@ADDRESS_FIRST",    SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_MIDDLE",   SqlDbType.NVarChar, 100),
                    new SqlParameter("@ADDRESS_LAST",     SqlDbType.NVarChar, 100),
                    new SqlParameter("@ZIP_CODE",         SqlDbType.VarChar,    8),
                    new SqlParameter("@PHONE_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@FAX_NUMBER",       SqlDbType.VarChar,   20),
                    new SqlParameter("@MOBIL_NUMBER",     SqlDbType.VarChar,   20),
                    new SqlParameter("@CONTACT_NAME",     SqlDbType.NVarChar,  50),
                    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.CUSTOMER_CODE;
                parameters[1].Value  = model.DELIVERY_CODE;
                parameters[2].Value  = model.ADDRESS_FIRST;
                parameters[3].Value  = model.ADDRESS_MIDDLE;
                parameters[4].Value  = model.ADDRESS_LAST;
                parameters[5].Value  = model.ZIP_CODE;
                parameters[6].Value  = model.PHONE_NUMBER;
                parameters[7].Value  = model.FAX_NUMBER;
                parameters[8].Value  = model.MOBIL_NUMBER;
                parameters[9].Value  = model.CONTACT_NAME;
                parameters[10].Value = model.STATUS_FLAG;
                parameters[11].Value = model.CREATE_USER;
                parameters[12].Value = model.LAST_UPDATE_USER;

                rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
                #endregion
            }
            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }