private void LoginButton_Click(object sender, EventArgs e) { MainMethodInterface MainMethod = new MainMethodInterface(); string Uname, Upassword; Uname = UserNameBox.Text.Trim(); Upassword = PasswordBox.Text.Trim(); if (Uname == "" || Upassword == "") { StatusLabel.ForeColor = Color.Red; StatusLabel.Text = "请输入账号或者密码"; } else { StatusLabel.Text = "正在登录中..."; //使用task进行多线程操作获取带有返回值的函数,lamba表达式 Task <string[]> Tasks = Task.Factory.StartNew <string[]>(() => MainMethod.PostHttpResponJson(HzWebApi.LoginUrlApiAddress, Uname, Upassword)); string[] LoginInfoArray = Tasks.Result; if (LoginInfoArray.Length != 0) { //StatusLabel.Text = "登录成功"; //Task.Delay(1000); this.Hide(); ProfileForm PFM = new ProfileForm(); PFM.Show(); } else { StatusLabel.ForeColor = Color.Red; StatusLabel.Text = "登录失败,可能是密码或者账号错误"; } } }
private void EditProductForm_Load(object sender, EventArgs e) { string goodid; //ProfileForm PF = new ProfileForm(); MainMethodInterface MMI = new MainMethodInterface(); goodid = ProfileForm.goodid; HzWebApi.ProductDetailsApiAddress = "http://m.idsdz.com/api/applet-shop/workbench/goodsdetail?goodsId=" + goodid; MMI.GetProductDetailsOutMethod(out JToken JpostToken, out string[] FullInfoList, HzWebApi.ProductDetailsApiAddress); ProductnameBox.Text = FullInfoList[0].Trim(); ProductUname.Text = FullInfoList[1].Trim(); ProductUpassword.Text = FullInfoList[2].Trim(); ProductExpirtime.Text = MMI.GetTimeSampToDate(FullInfoList[3].Trim()).ToString("yyyy-MM-dd"); }
private void SubmitButton_Click(object sender, EventArgs e) { string goodid; MainMethodInterface MMI = new MainMethodInterface(); goodid = ProfileForm.goodid; HzWebApi.ProductDetailsApiAddress = "http://m.idsdz.com/api/applet-shop/workbench/goodsdetail?goodsId=" + goodid; MMI.GetProductDetailsOutMethod(out JToken JpostToken, out string[] FullInfoList, HzWebApi.ProductDetailsApiAddress); string UpdateProductName, UpdateUserName, UPdatePassword; UpdateProductName = ProductnameBox.Text.Trim(); UpdateUserName = ProductUname.Text.Trim(); UPdatePassword = ProductUpassword.Text.Trim(); JArray JsonArrayText = JArray.Parse(JpostToken["skuJson"].ToString()); JArray JsonDescPic = JArray.Parse(JpostToken["descriptionImages"].ToString()); JObject NewParaOBJ = new JObject(); NewParaOBJ.Add("id", goodid); NewParaOBJ.Add("shelfId", JpostToken["shelfId"]); NewParaOBJ.Add("categoryId", JpostToken["categoryId"]); NewParaOBJ.Add("goodsName", UpdateProductName); NewParaOBJ.Add("username", UpdateUserName); NewParaOBJ.Add("password", UPdatePassword); NewParaOBJ.Add("usernameExpire", ProductExpirtime.Text); NewParaOBJ.Add("stockTotal", JpostToken["stockTotal"]); NewParaOBJ.Add("description", JpostToken["description"]); NewParaOBJ.Add("sku", JsonArrayText); NewParaOBJ.Add("descriptionImages", JsonDescPic); Task <string> TS = Task.Factory.StartNew <string>(() => MMI.PostHttp(NewParaOBJ, HzWebApi.UpdateProductApiAddress)); Editstatus.Text = "正在提交修改..."; Editstatus.ForeColor = Color.Green; string Message = TS.Result; if (Message != null) { MessageBox.Show(Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); Editstatus.Text = ""; this.Close(); Application.Restart(); } else { MessageBox.Show("修改失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Editstatus.Text = ""; } }
private void Form1_Load(object sender, EventArgs e) { MainMethodInterface MMF = new MainMethodInterface(); if (MMF.GetNetWorkStatus() == true) { StatusLabel.ForeColor = Color.Green; StatusLabel.Text = "网络连接正常,请登录"; } else { StatusLabel.Text = string.Format("网络连接异常,3秒后将会退出..."); this.Enabled = false; Task.Run( async delegate { await Task.Delay(3000); Application.Exit(); } ); } }
public void ProfileForm_Load(object sender, EventArgs e) { MainMethodInterface MMI = new MainMethodInterface(); Task <string[]> Tasks = Task.Factory.StartNew <string[]>(() => MMI.GetUserDetailInfo()); Task <string[]> Tasks0 = Task.Factory.StartNew <string[]>(() => MMI.GetTodayOrderInfo()); Task <string[]> Tasks1 = Task.Factory.StartNew <string[]>(() => MMI.GetUserWalletInfo()); Task <ArrayList> Tasks2 = Task.Factory.StartNew <ArrayList>(() => MMI.GetEachOrderDetailsWithId()); Task <string[]> Tasks3 = Task.Factory.StartNew <string[]>(() => MMI.GetUserProductList()); string[] UserInfoList = Tasks.Result; string[] OrderCountInfo = Tasks0.Result; string[] UserWalletInfo = Tasks1.Result; string[] ProductInfo = Tasks3.Result; ArrayList LendingOrderInfo = Tasks2.Result; if (ProductInfo != null) { string ProducStus, ProductClasName, ProductName; //public string goodid; ProducStus = ProductInfo[0]; ProductName = ProductInfo[1]; ProductClasName = ProductInfo[2]; goodid = ProductInfo[3]; switch (ProducStus) { case "3": ProducStus = "出租中"; break; case "2": ProducStus = "待出租"; break; case "4": ProducStus = "密码待更新"; break; } if (goodid == null) { CategoryInfo1.Text = "您还没有上架商品."; EditButton1.Visible = false; } else { if (ProducStus == "密码待更新") { EditButton1.Visible = true; } CategoryInfo1.Text += $"商品名称:{ProductName}\n\n状态:{ProducStus}\n\n规格:{ProductClasName}"; } } if (LendingOrderInfo != null) { string ShownTime, FullText; int SubHours; foreach (var EachInfo in LendingOrderInfo) { JObject GetDeailInfo = MMI.GetSerialJson(EachInfo.ToString()); JToken OrderNum = GetDeailInfo["orderNum"]; JToken LendingExpireTime = GetDeailInfo["leaseExpireTime"]; JToken Status = GetDeailInfo["status"]; JToken PayNum = GetDeailInfo["realPrice"]; JToken OrderClass = GetDeailInfo["specName"]; DateTime ExpirTime = MMI.GetTimeSampToDate(LendingExpireTime.ToString()); ShownTime = ExpirTime.ToString(); if (Status.ToString() == "2") { Status = "租用中"; } PayNum = MMI.GetFormatDoubleString(PayNum.ToString()); FullText = $"订单编号:#{OrderNum.ToString()}\n\n状态:{Status}\n\n到期时间:{ExpirTime}\n\n规格:{OrderClass.ToString()}\n\n支付金额:{PayNum}元\n\n#######################################\n"; LendingTB.Text += FullText; DateTime NowLocalTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); TimeSpan TimeSub = ExpirTime - NowLocalTime; SubHours = TimeSub.Hours; if (SubHours <= 2) { MessageBox.Show("有一个或者多个订单距离到期时间只有两个小时,请注意", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { LendingTB.ForeColor = Color.Red; LendingTB.Text = "暂时没有租用中的订单\n\n\n软件5分钟刷新一次信息\n\n\n也可以退出重新登录获取最新订单信息"; HZDZHOMEWEB.Text = "点击这里查看登录官网查询"; XUNLEILABEL.Text = "点击这里快速修改迅雷密码"; } if (UserInfoList == null || OrderCountInfo == null) { MessageBox.Show("发生异常错误!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } if (UserInfoList != null) { UserNameLabel.Text += UserInfoList[6]; //用户名 UserEmail.Text += UserInfoList[1]; //邮箱 UserPhoneNum.Text += UserInfoList[4]; //手机号码 UserPayAccount.Text += UserInfoList[3]; //收款账号 UserShopLevel.Text += UserInfoList[5]; //店铺等级 UserRealName.Text += UserInfoList[2]; } if (OrderCountInfo != null) { OrderLabel.Text += OrderCountInfo[1]; PriceLabel.Text += OrderCountInfo[2] + "元"; } if (OrderCountInfo != null) { TotalLeave.Text += UserWalletInfo[0] + "元"; CanRecLabel.Text += UserWalletInfo[1] + "元"; Lendinglabel.Text += UserWalletInfo[2] + "元"; } }