Files
KJD/TEMUKJD/KJDForms/AdminForms/AdminProductPriceCheckForm.cs
T

174 lines
6.4 KiB
C#

using AllBase;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using NaiBa.Util.Winform.Extension;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Work;
namespace TemuKJD.KJDForms.AdminForms
{
public partial class AdminProductPriceCheckForm : Form
{
public static List<ShopLoginInfo> lstAdminShopInfo { get; set; } = new List<ShopLoginInfo>();
public AdminProductPriceCheckForm()
{
InitializeComponent();
}
private void AdminProductPriceCheckForm_Load(object sender, EventArgs e)
{
this.dgvShop.AddSelectorColumn("colSelect");
if (BaseClass.SaLevel != 1)
{
//this.chkShowDelete.Visible = false;
//dgvShop.Columns["colSubSa"].Visible = false;
//btnSetSubSa.Visible = false;
}
}
bool firstLoad = true;
private void AdminProductPriceCheckForm_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible && this.firstLoad)
{
firstLoad = false;
this.pbShopLoading.Visible = true;
SearchShop(this.ucSplitPage1.CurrentPage);
}
}
private void btnRefreshShop_Click(object sender, EventArgs e)
{
if (this.ucSplitPage1.CurrentPage != 1)
this.ucSplitPage1.CurrentPage = 1;
else
SearchShop(1);
}
private void ucSplitPage1_PageChange(object obj)
{
SearchShop(this.ucSplitPage1.CurrentPage);
}
public void SearchShop(int page)
{
List<string> shopIdList = GetCheckedShopIdList();
if (InvokeRequired)
{
Invoke(new Action(() =>
{
this.pbShopLoading.Visible = true;
this.dgvShop.Rows.Clear();
lstAdminShopInfo.Clear();
}));
}
else
{
this.pbShopLoading.Visible = true;
this.dgvShop.Rows.Clear();
lstAdminShopInfo.Clear();
}
Task.Run(() =>
{
int pageCount;
var list = AdminGetServerShopLst(out pageCount, page);
lstAdminShopInfo.AddRange(list);
this.ucSplitPage1.TotalPage = pageCount;
foreach (var shop in lstAdminShopInfo)
{
bool canUse = shop.LoginStatus2 == "国际版在线";
Invoke(new Action(() =>
{
int rowIndex = this.dgvShop.Rows.Add(
shopIdList.Contains(shop.ShopId + shop.UserName),
shop.LoginName,
shop.ShopId,
shop.ShopAccount,
shop.Notes,
canUse ? "在线" : "掉线",
canUse,
string.Empty
);
var row = dgvShop.Rows[rowIndex];
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).Style.ForeColor = canUse ? Color.Green : Color.Red;
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).LinkColor = canUse ? Color.Green : Color.Red;
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).ActiveLinkColor = canUse ? Color.LightGreen : Color.OrangeRed;
(row.Cells["colLoginStatus"] as DataGridViewLinkCell).VisitedLinkColor = canUse ? Color.DarkGreen : Color.DarkRed;
}));
}
Invoke(new Action(() =>
{
this.pbShopLoading.Visible = false;
}));
});
}
private List<string> GetCheckedShopIdList()
{
List<string> shopNameList = new List<string>();
for (int i = 0; i < dgvShop.Rows.Count; i++)
{
if (dgvShop.Rows[i].Cells["colSelect"].Value.ParseToBool())
{
string shopName = dgvShop.Rows[i].Cells["colShopId"].Value.ParseToString();
shopName += dgvShop.Rows[i].Cells["colUser"].Value.ParseToString();
shopNameList.Add(shopName);
}
}
return shopNameList;
}
public List<ShopLoginInfo> AdminGetServerShopLst(out int pageCount, int page = 1, int pageSize = 500)
{
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
pageCount = 1;
var url = BaseClass.BuildObjString("shop/admin_get_shop_list");
if (BaseClass.SaLevel > 1 && !chkAllShop.Checked)
url = BaseClass.BuildObjString("shop/sub_sa_get_select_prod_shop");
var data = UserLogin.GetSignaturex() +
"&page=" + page +
"&page_size=" + pageSize +
"&shop_ids=" + txtShopId.Text.Trim() +
"&shop_names=" + txtShopName.Text.Trim() +
"&search_notes=" + txtNotes.Text.Trim();
if (BaseClass.SaLevel > 1 && !chkAllShop.Checked)
data += "&operate_sub_sa_name=" + BaseClass.UserName;
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html)
|| !html.Contains("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
return list;
}
int count = BaseRegex.GetIntJson(ref html, "count");
pageCount = Math.Ceiling(1.0 * count / pageSize).ParseToInt();
pageCount = Math.Max(pageCount, 1);
return AdminShopListForm.DeserializationShop(html);
}
private void btnEmpty_Click(object sender, EventArgs e)
{
txtNotes.Text = txtShopId.Text = txtShopName.Text = "";
}
}
}