using AllBase.Helper; using AllBase.Model.Result; using TemuKJD.BaseForms; 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; namespace TemuKJD.WXForms.ShopForms { public partial class WXShopAddEditForm : BaseGeneralForm { List lstShopLoginInfo = null; ShopLoginInfo shop = null; bool isAdd = true; public WXShopAddEditForm(List shopLst = null) { InitializeComponent(); lstShopLoginInfo = shopLst; if (lstShopLoginInfo != null && lstShopLoginInfo.Count > 0) { shop = lstShopLoginInfo.FirstOrDefault(); isAdd = false; } } private void btnOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtLoginName.Text.Trim())) { BaseMsgForm.ShowError("用户名不能为空!"); return; } if (lstShopLoginInfo == null && string.IsNullOrEmpty(this.txtShopPassword.Text.Trim())) { BaseMsgForm.ShowError("密码不能为空!"); return; } if (lstShopLoginInfo == null || lstShopLoginInfo.Count == 0) { lstShopLoginInfo = new List(); shop = new ShopLoginInfo(); } shop.LoginName = this.txtLoginName.Text.Trim(); if (!string.IsNullOrEmpty(this.txtShopPassword.Text.Trim())) shop.Password = DataOpenSSL.EncryptString(this.txtShopPassword.Text.Trim()); shop.GroupName = this.cmbGroup.Text; shop.Notes = this.txtNotes.Text; shop.CompanyName = AllBase.BaseClass.CompanyName; // 同一个登录账号下的店铺使用同样的groupName和Notes var shopLst = GlobalConfig.ShopLoginList.Where(s => s.LoginName == shop.LoginName && s.ShopId != shop.ShopId).ToList(); foreach (var shop in shopLst) { shop.GroupName = shop.GroupName; shop.Notes = shop.Notes; } var shopSubAccountLstTmp = shop.ShopSubAccountList; foreach (var sp in lstShopLoginInfo) { sp.GroupName = this.cmbGroup.Text; sp.Notes = this.txtNotes.Text; sp.CompanyName = AllBase.BaseClass.CompanyName; sp.ShopSubAccountList.Clear(); sp.ShopSubAccountList.AddRange(shopSubAccountLstTmp); } this.OnSaveComplete(lstShopLoginInfo, isAdd); this.Close(); } private void panel2_Paint(object sender, PaintEventArgs e) { } private void ShopAddEditForm_Load(object sender, EventArgs e) { this.cmbGroup.Items.Clear(); this.cmbGroup.Items.Add(string.Empty); foreach (var shop in GlobalConfig.ShopLoginList) { if (!string.IsNullOrEmpty(shop.GroupName) && !this.cmbGroup.Items.Contains(shop.GroupName)) this.cmbGroup.Items.Add(shop.GroupName); } if (lstShopLoginInfo != null && lstShopLoginInfo.Count > 0 && shop != null) { this.txtLoginName.Text = shop.LoginName; this.cmbGroup.Text = shop.GroupName; this.txtNotes.Text = shop.Notes; this.btnOk.Text = "更新"; this.TitleText = "编辑店铺 - " + shop.ShopAccount; this.txtBuyAccount.Text = shop.BuyAccount; this.txtChatAccount.Text = shop.ChatAccount; this.txtUploadAccount.Text = shop.UploadAccount; this.txtChatAccount.Text = shop.SubUserName; this.txtLoginName.Enabled = false; //this.lblAttention.Visible = true; } else { this.txtBuyAccount.Enabled = false; this.txtChatAccount.Enabled = false; this.txtUploadAccount.Enabled = false; this.txtBuyAccount.Text = this.txtChatAccount.Text = this.txtUploadAccount.Text = "请在编辑账户时修改子账户"; } } private void txtUploadAccount_TextChanged(object sender, EventArgs e) { } private void txtChat_TextChanged(object sender, EventArgs e) { } private void txtBuyAccount_TextChanged(object sender, EventArgs e) { } private void txt_Click(object sender, EventArgs e) { WXSubAccountShopEditForm f = new WXSubAccountShopEditForm(shop); f.SaveComplete += F_SaveComplete; f.ShowDialog(); } private void F_SaveComplete(object obj) { var shop = obj as ShopLoginInfo; if (shop != null) { this.txtBuyAccount.Text = shop.BuyAccount; this.txtChatAccount.Text = shop.ChatAccount; this.txtUploadAccount.Text = shop.UploadAccount; } } } }