Example #1
0
 private static void LoadFromReader(GeoZone geoZone, IDataReader reader)
 {
     if (reader.Read())
     {
         geoZone.guid        = new Guid(reader["Guid"].ToString());
         geoZone.countryGuid = new Guid(reader["CountryGuid"].ToString());
         geoZone.name        = reader["Name"].ToString();
         geoZone.code        = reader["Code"].ToString();
     }
 }
Example #2
0
        public static GeoZone GetByCode(Guid countryGuid, string code)
        {
            GeoZone geoZone = new GeoZone();

            using (IDataReader reader = DBGeoZone.GetByCode(countryGuid, code))
            {
                LoadFromReader(geoZone, reader);
            }

            if (geoZone.Guid == Guid.Empty)
            {
                return(null);
            }
            return(geoZone);
        }
Example #3
0
        public static GeoZone GetByCode(Guid countryGuid, string code)
        {
            GeoZone geoZone = new GeoZone();
            using (IDataReader reader = DBGeoZone.GetByCode(countryGuid, code))
            {
                LoadFromReader(geoZone, reader);
            }

            if (geoZone.Guid == Guid.Empty)
            {
                return null;
            }
            return geoZone;
        }
Example #4
0
        private static void LoadFromReader(GeoZone geoZone, IDataReader reader)
        {
            if (reader.Read())
            {
                geoZone.guid = new Guid(reader["Guid"].ToString());
                geoZone.countryGuid = new Guid(reader["CountryGuid"].ToString());
                geoZone.name = reader["Name"].ToString();
                geoZone.code = reader["Code"].ToString();

            }
        }
Example #5
0
        private void grdGeoZone_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView grid = (GridView)sender;
            Guid guid = new Guid(grid.DataKeys[e.RowIndex].Value.ToString());

            TextBox txtName = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtName");
            TextBox txtCode = (TextBox)grid.Rows[e.RowIndex].Cells[1].FindControl("txtCode");

            GeoZone geoZone;
            if (guid != Guid.Empty)
            {
                geoZone = new GeoZone(guid);
            }
            else
            {
                geoZone = new GeoZone();
            }

            if (ddCountry.SelectedIndex > -1)
            {
                countryGuid = new Guid(ddCountry.SelectedValue);
            }
            else
            {
                if (countryGuid == Guid.Empty)
                {
                    countryGuid = defaultCountry;
                }
            }

            geoZone.CountryGuid = countryGuid;
            geoZone.Name = txtName.Text;
            geoZone.Code = txtCode.Text;
            geoZone.Save();

            WebUtils.SetupRedirect(this, GetRefreshUrl());
        }