using AllBase; 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 TemuKJD.BaseForms; using TemuKJD.PDDForms.ProductSelectForms; using Work; namespace TemuKJD.PDDForms.AdminForms { public partial class RandomComProductForm : BaseForm { public RandomComProductForm() { InitializeComponent(); } private void RandomComProductForm_Load(object sender, EventArgs e) { pbLoading.Visible = true; Task.Run(() => { PDDDBProdListForm.GetPDDProductGroup(new List { cmbProductGroup, }); var url = BaseClass.BuildObjString("product/get_random_company_product_config"); var data = UserLogin.GetSignaturex(); 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("\"code\":200")) { BaseMsgForm.ShowError("获取随机厂商商品配置失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); } else { //this.pictureBox2.ImageLocation = imgListForm.SelectDbImgUrl; //dbProd.sku_img_replace_id = imgListForm.SelectDbImgId; //dbProd.sku_img_replace_url = imgListForm.SelectDbImgUrl; Invoke(new Action(() => { this.txtProductInterval.Text = BaseRegex.GetStringJson(ref html, "product_interval"); this.cmbProductGroup.Text = BaseRegex.GetStringJson(ref html, "product_group"); this.chkIsOn.Checked = BaseRegex.GetStringJson(ref html, "is_on") == "1"; })); } Invoke(new Action(() => { pbLoading.Visible = false; })); }); } private void btnSave_Click(object sender, EventArgs e) { pbLoading.Visible = true; Task.Run(() => { var url = BaseClass.BuildObjString("product/set_random_company_product_config"); var data = UserLogin.GetSignaturex(); Invoke(new Action(() => { data += "&product_interval=" + txtProductInterval.Text.Trim(); data += "&product_group=" + cmbProductGroup.Text.Trim(); data += "&is_on=" + (chkIsOn.Checked ? 1 : 0); })); 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("\"code\":200")) { BaseMsgForm.ShowError("配置随机厂商商品失败,请重试!" + BaseRegex.GetStringJson(ref html, "msg")); } else { BaseMsgForm.ShowInfo("配置随机厂商商品成功"); } Invoke(new Action(() => { pbLoading.Visible = false; })); }); } } }