protected void SaveLocation_Click(object sender, EventArgs e)
 {
     #region 保存区域修改
     int row = 0;
     DataTable dt = DbProvider.GetInstance().GetLocationsTable();
     string errorinfo = "";
     bool iserror = false;
     foreach (object o in DataGrid1.GetKeyIDArray())
     {
         int id = int.Parse(o.ToString());
         string country = DataGrid1.GetControlValue(row, "country").Trim();
         string state = DataGrid1.GetControlValue(row, "state").Trim();
         string city = DataGrid1.GetControlValue(row, "city").Trim();
         string zipcode = DataGrid1.GetControlValue(row, "zipcode").Trim();
         row++;
         DataRow oldrow = null;
         foreach (DataRow dr in dt.Rows)
         {
             if (dr["lid"].ToString() == id.ToString())
             {
                 oldrow = dr;
                 break;
             }
         }
         if (country == "" || state == "" || city == "")
         {
             iserror = true;
             errorinfo += "原<b>" + oldrow["city"].ToString() + "</b>行修改后信息不完整!<br>";
             continue;
         }
         bool isreply = false;
         foreach (DataRow dr in dt.Rows)
         {
             if (dr["lid"].ToString() != id.ToString() && dr["country"].ToString() == country && dr["state"].ToString() == state && dr["city"].ToString() == city)
             {
                 iserror = true;
                 errorinfo += "原<b>" + oldrow["city"].ToString() + "</b>修改后与其它记录重复!<br>";
                 isreply = true;
                 break;
             }
         }
         if (isreply)
             continue;
         Locationinfo local = new Locationinfo();
         local.Lid = id;
         local.Country = country;
         local.State = state;
         local.City = city;
         local.Zipcode = zipcode;
         DbProvider.GetInstance().UpdateLocations(local);
     }
     Locations.GetInstance.WriteJsonFile();
     if (iserror)
     {
         RegisterMessage(errorinfo + "<a href=\\'mall_locationsmanage.aspx\\'>返回</a>");
     }
     else
     {
         RegisterStartupScript("PAGE", "window.location.href='mall_locationsmanage.aspx';");
     }
     #endregion
 }
 protected void AddNewRec_Click(object sender, EventArgs e)
 {
     string country = DNTRequest.GetString("combox_country_select");
     string state = DNTRequest.GetString("combox_state_select");
     string city = DNTRequest.GetString("city");
     string zipcode = DNTRequest.GetString("zipcode");
     if (country == "" || state == "" || city == "")
     {
         RegisterMessage("国家、省份或城市信息没有填写!<br><a href=\\'mall_locationsmanage.aspx\\'>返回</a>");
         return;
     }
     DataTable dt = DbProvider.GetInstance().GetLocationsTable();
     foreach (DataRow dr in dt.Rows)
     {
         if (dr["country"].ToString() == country && dr["state"].ToString() == state && dr["city"].ToString() == city)
         {
             RegisterMessage("新建记录与其它记录重复!<br><a href=\\'mall_locationsmanage.aspx\\'>返回</a>");
             return;
         }
     }
     Locationinfo local = new Locationinfo();
     local.Country = country;
     local.State = state;
     local.City = city;
     local.Zipcode = zipcode;
     DbProvider.GetInstance().CreateLocations(local);
     Locations.GetInstance.WriteJsonFile();
     RegisterStartupScript("PAGE", "window.location.href='mall_locationsmanage.aspx';");
 }
예제 #3
0
            /// <summary>
            /// 获得所在地信息(DTO)
            /// </summary>
            /// <param name="__idatareader">要转换的数据</param>
            /// <returns>返回所在地信息</returns>
            public static Locationinfo GetLocationInfo(IDataReader reader)
            {
                Locationinfo locationinfo = null;
                if (reader.Read())
                {
                    locationinfo = new Locationinfo();
                    locationinfo.Lid = TypeConverter.ObjectToInt(reader["lid"]);
                    locationinfo.City = reader["city"].ToString().Trim();
                    locationinfo.State = reader["state"].ToString().Trim();
                    locationinfo.Country = reader["country"].ToString().Trim();
                    locationinfo.Zipcode = reader["zipcode"].ToString().Trim();

                    reader.Close();
                }
                return locationinfo;
            }
예제 #4
0
            public static Locationinfo[] GetLocationInfoArray(DataTable dt)
            {
                if (dt == null || dt.Rows.Count == 0)
                    return null;

                Locationinfo[] locationInfoArray = new Locationinfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    locationInfoArray[i] = new Locationinfo();
                    locationInfoArray[i].Lid = TypeConverter.ObjectToInt(dt.Rows[i]["lid"]);
                    locationInfoArray[i].City = dt.Rows[i]["city"].ToString();
                    locationInfoArray[i].State = dt.Rows[i]["state"].ToString();
                    locationInfoArray[i].Country = dt.Rows[i]["country"].ToString();
                    locationInfoArray[i].Zipcode = dt.Rows[i]["zipcode"].ToString();
                }
                dt.Dispose();
                return locationInfoArray;
            }
예제 #5
0
        /// <summary>
        /// 更新所在地信息
        /// </summary>
        /// <param name="locations">要更新的所在地信息</param>
        /// <returns></returns>
        public bool UpdateLocations(Locationinfo locations)
        {

            DbParameter[] parms = 
				{
						DbHelper.MakeInParam("@city", (DbType)SqlDbType.NVarChar, 50,locations.City),
						DbHelper.MakeInParam("@state", (DbType)SqlDbType.NVarChar, 50,locations.State),
						DbHelper.MakeInParam("@country", (DbType)SqlDbType.NVarChar, 50,locations.Country),
						DbHelper.MakeInParam("@zipcode", (DbType)SqlDbType.NVarChar, 20,locations.Zipcode),
                        DbHelper.MakeInParam("@lid", (DbType)SqlDbType.Int, 4,locations.Lid)
				};
            string commandText = String.Format("Update [{0}locations]  Set [city] = @city, [state] = @state, [country] = @country, [zipcode] = @zipcode WHERE [lid] = @lid", BaseConfigs.GetTablePrefix);
            DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms);
            return true;
        }
예제 #6
0
        /// <summary>
        /// 创建所在地信息
        /// </summary>
        /// <param name="locations">要创建的所在地信息</param>
        /// <returns></returns>
        public int CreateLocations(Locationinfo locations)
        {
            DbParameter[] parms = 
				{
						DbHelper.MakeInParam("@city", (DbType)SqlDbType.NVarChar, 50,locations.City),
						DbHelper.MakeInParam("@state", (DbType)SqlDbType.NVarChar, 50,locations.State),
						DbHelper.MakeInParam("@country", (DbType)SqlDbType.NVarChar, 50,locations.Country),
						DbHelper.MakeInParam("@zipcode", (DbType)SqlDbType.NVarChar, 20,locations.Zipcode)
				};
            string commandText = String.Format("INSERT INTO [{0}locations] ([city], [state], [country], [zipcode]) VALUES (@city, @state, @country, @zipcode);SELECT SCOPE_IDENTITY()  AS 'lid'", BaseConfigs.GetTablePrefix);
            return TypeConverter.ObjectToInt(DbHelper.ExecuteDataset(CommandType.Text, commandText, parms).Tables[0].Rows[0][0], -1);
        }