Files
kami_itunes_june/AppleBatch_June/CountryOptions.cs
danial cb905409f8 Refactor AppleBatch_June project:
- Removed DotRas library dependency in RasTools.cs, providing empty implementations for Connect and Disconnect methods.
- Updated context menu implementation in ReddemHelp.cs to use ToolStripMenuItem and ContextMenuStrip.
- Replaced caching mechanism in SiteHelper.cs with a custom dictionary-based implementation, removing reliance on HttpRuntime.Cache.
- Switched from JavaScriptSerializer to Newtonsoft.Json for JSON serialization/deserialization in multiple files (Tools.cs, addMaterial.cs).
- Added WebHeaderCollection property to HttpItem.cs for better header management.
- Deleted obsolete AssemblyInfo.cs file.
- Introduced apple_balance_query.py for querying Apple ID balance via Privacy Center, implementing authentication and balance retrieval logic.
2025-11-10 17:38:18 +08:00

151 lines
4.8 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using System.Windows.Forms;
using AppleBatch_June.Domain;
using AppleBatch_June.Model;
using AppleBatch_June.Properties;
namespace AppleBatch_June
{
public class CountryOptions : Form
{
private CountriesReachableAt reachableAt;
private IContainer components;
private Button button2;
private ListView listView1;
private ColumnHeader columnHeader1;
private ColumnHeader columnHeader3;
private Button button1;
public CountryOptions()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (new addMaterial().ShowDialog() == DialogResult.OK)
{
load();
}
}
private void CountryOptions_Load(object sender, EventArgs e)
{
string @string = Encoding.UTF8.GetString(Resources.localizedResources);
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(@string);
load();
}
private void load()
{
listView1.Items.Clear();
List<NationalList> mation = new UserNationalData().getMation();
int num = 0;
foreach (NationalList item in mation)
{
num++;
ListViewItem listViewItem = new ListViewItem(num.ToString());
listViewItem.SubItems.Add(item.name);
string guoaji = item.payment.billingAddress.countryCode;
CountriesReachableAt.Smssupportedcountriesreachableat smssupportedcountriesreachableat = reachableAt.smsSupportedCountriesReachableAt.Where((CountriesReachableAt.Smssupportedcountriesreachableat c) => c.code == guoaji).FirstOrDefault();
if (smssupportedcountriesreachableat != null)
{
listViewItem.SubItems.Add(smssupportedcountriesreachableat.name);
}
else
{
listViewItem.SubItems.Add("未知国家");
}
listViewItem.SubItems.Add(item.payment.ownerName.lastName + item.payment.ownerName.firstName);
listViewItem.SubItems.Add(item.Id);
listView1.Items.Add(listViewItem);
}
}
private void button2_Click(object sender, EventArgs e)
{
if (MessageBox.Show("删除选中资料?", "提示", MessageBoxButtons.OKCancel) != DialogResult.OK || listView1.SelectedItems.Count <= 0)
{
return;
}
UserNationalData userNationalData = new UserNationalData();
foreach (ListViewItem selectedItem in listView1.SelectedItems)
{
string code = selectedItem.SubItems[4].Text;
userNationalData.removeMation(code);
}
load();
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.button2 = new System.Windows.Forms.Button();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader3 = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
base.SuspendLayout();
this.button2.Location = new System.Drawing.Point(132, 24);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(81, 24);
this.button2.TabIndex = 5;
this.button2.Text = "删除";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(button2_Click);
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] { this.columnHeader1, this.columnHeader3 });
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(12, 66);
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(402, 273);
this.listView1.TabIndex = 4;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.columnHeader1.Text = "序号";
this.columnHeader3.Text = "自定义国家";
this.columnHeader3.Width = 200;
this.button1.Location = new System.Drawing.Point(12, 24);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 24);
this.button1.TabIndex = 3;
this.button1.Text = "新增国家资料";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(button1_Click);
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(457, 376);
base.Controls.Add(this.button2);
base.Controls.Add(this.listView1);
base.Controls.Add(this.button1);
base.MaximizeBox = false;
base.MinimizeBox = false;
base.Name = "CountryOptions";
base.ShowIcon = false;
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "新增国家";
base.Load += new System.EventHandler(CountryOptions_Load);
base.ResumeLayout(false);
}
}
}