public string  SaveComAddress(DeliveryAddress query)
 {
     string json = string.Empty;
     try
     {
         if (query.da_id== 0)
         {
             if (_vipUserGroupDao.SaveComAddress(query) > 0)
             {
                 json = "{success:'true'}";
             }
             else
             {
                 json = "{success:'false'}";
             }
         }
         else
         {
             int n=100;
             if (!int.TryParse(query.da_dist, out n))
             {
                 query.da_dist = _vipUserGroupDao.GetZiPCode(query.da_dist);
             }
             if (_vipUserGroupDao.UPComAddress(query) > 0)
             {
                 json = "{success:'true'}";
             }
             else
             {
                 json = "{success:'false'}";
             }
         }
      
         return json;
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->SaveComAddress-->" + ex.Message, ex);
     }
 }
 public string DeleteDeliveryAddress(DeliveryAddress query)
 {
     string json = string.Empty;
     try
     {
         if (_vipUserGroupDao.DeleteDeliveryAddress(query) > 0)
         {
             json = "{success:'true'}";
         }
         else
         {
             json = "{success:'false'}";
         }
         return json;
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->DeleteDeliveryAddress-->" + ex.Message, ex);
     }
 }
 public HttpResponseBase DeleteDeliveryAddress()
 {
     string json = string.Empty;
     DeliveryAddress query = new DeliveryAddress();
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["da_id"])) 
         {
             query.da_id = Convert.ToInt32(Request.Params["da_id"]);
             _vipUserGroup = new VipUserGroupMgr(mySqlConnectionString);
             json = _vipUserGroup.DeleteDeliveryAddress(query);
         }
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
 public List<DeliveryAddress> GetComAddress(DeliveryAddress query)
 {
     try
     {
         return _vipUserGroupDao.GetComAddress(query);
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->GetComAddress-->" + ex.Message, ex);
     }
 }
 public HttpResponseBase GetComAddress()
 {
     List<DeliveryAddress> store = new List<DeliveryAddress>();
     DeliveryAddress query = new DeliveryAddress();
     string  json = "{success:true,data:[]}";
     try
     {
         _vipUserGroup = new VipUserGroupMgr(mySqlConnectionString);
         if (!string.IsNullOrEmpty(Request.Params["user_id"]))
         {
             query.user_id = Convert.ToInt32(Request.Params["user_id"]);
             store = _vipUserGroup.GetComAddress(query);
             json = "{success:true,data:" + JsonConvert.SerializeObject(store) + "}";
         }
      
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         json = "{success:false}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
 public int DeleteDeliveryAddress(DeliveryAddress query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         sql.AppendFormat("delete from delivery_address where da_id='{0}';", query.da_id);
         return _accessMySql.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->DeleteDeliveryAddress-->" + sql.ToString() + ex.Message, ex);
     }
 }
 public int UPComAddress(DeliveryAddress query)
 {
     StringBuilder sql = new StringBuilder();
     try
     {
         query.Replace4MySQL();
         sql.AppendFormat("update  delivery_address  set da_address='{0}' ,da_dist='{1}' ,da_title='{2}' where da_id='{3}';", query.da_address, query.da_dist,query.da_title, query.da_id);
         return _accessMySql.execCommand(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->SaveComAddress-->" + ex.Message + sql.ToString(), ex);
     }
 }
        public int SaveComAddress(DeliveryAddress query)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                query.Replace4MySQL();
                sql.Append("insert into delivery_address(user_id,da_title,da_name,da_gender,da_mobile_no,");
                sql.Append("da_tel_no,da_dist,da_address,da_default,da_created) values(");



                sql.AppendFormat("'{0}','{1}','{2}','{3}','{4}',",query.user_id,query.da_title,query.da_name,query.da_gender,query.da_mobile_no);
                sql.AppendFormat("'{0}','{1}','{2}','{3}','{4}');",query.da_tel_no,query.da_dist,query.da_address,query.da_default,CommonFunction.DateTimeToString( query.da_created));
                return _accessMySql.execCommand(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("VipUserGroupDao-->SaveComAddress-->" + ex.Message + sql.ToString(), ex);
            }
        }
 public List<DeliveryAddress> GetComAddress(DeliveryAddress query)
 {
     StringBuilder sql = new StringBuilder();
     StringBuilder sqlFrom = new StringBuilder();
     StringBuilder sqlWhere = new StringBuilder();
     try
     {
         sql.Append("select da.da_id,da.user_id,da.da_title,CONCAT(da.da_dist,tzc.middle,'  ',tzc.small) as 'da_dist',da.da_address ");
         sqlFrom.Append(" from delivery_address da left join t_zip_code tzc on da.da_dist=tzc.zipcode ");
         sqlWhere.Append(" where 1= 1 ");
         if (query.user_id != 0)
         {
             sqlWhere.AppendFormat(" and da.user_id='{0}';", query.user_id);
         }
         sql.Append(sqlFrom.ToString()+sqlWhere.ToString());
         return _accessMySql.getDataTableForObj<DeliveryAddress>(sql.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("VipUserGroupDao-->GetComAddress-->" + ex.Message + sql.ToString(), ex);
     }
 }