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.DYForms.ShopForms { public partial class DYShopAddEditForm : LRBaseForm { ShopLoginInfo shopLoginInfo = null; bool isAdd = true; public DYShopAddEditForm(ShopLoginInfo shop = null) { InitializeComponent(); shopLoginInfo = shop; if (shopLoginInfo != null) isAdd = false; } private void btnOk_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.txtLoginName.Text.Trim())) { BaseMsgForm.ShowError("用户名不能为空!"); return; } if (shopLoginInfo == null && string.IsNullOrEmpty(this.txtShopPassword.Text.Trim())) { BaseMsgForm.ShowError("密码不能为空!"); return; } if (shopLoginInfo == null) shopLoginInfo = new ShopLoginInfo(); shopLoginInfo.LoginName = this.txtLoginName.Text.Trim(); if (!string.IsNullOrEmpty(this.txtShopPassword.Text.Trim())) shopLoginInfo.Password = DataOpenSSL.EncryptString(this.txtShopPassword.Text.Trim()); shopLoginInfo.GroupName = this.cmbGroup.Text; shopLoginInfo.Notes = this.txtNotes.Text; shopLoginInfo.CompanyName = AllBase.BaseClass.CompanyName; // 同一个登录账号下的店铺使用同样的groupName和Notes var shopLst = GlobalConfig.ShopLoginList.Where(s => s.LoginName == shopLoginInfo.LoginName && s.ShopId != shopLoginInfo.ShopId).ToList(); foreach (var shop in shopLst) { shop.GroupName = shopLoginInfo.GroupName; shop.Notes = shopLoginInfo.Notes; } this.OnSaveComplete(shopLoginInfo, 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 (shopLoginInfo != null) { this.txtLoginName.Text = shopLoginInfo.LoginName; this.cmbGroup.Text = shopLoginInfo.GroupName; this.txtNotes.Text = shopLoginInfo.Notes; this.btnOk.Text = "更新"; this.TitleText = "编辑店铺 - " + shopLoginInfo.ShopAccount; this.txtBuyAccount.Text = shopLoginInfo.BuyAccount; //this.txtChatAccount.Text = shopLoginInfo.ChatAccount; this.txtChatAccount.Text = shopLoginInfo.SubUserName; this.txtUploadAccount.Text = shopLoginInfo.UploadAccount; this.label7.Visible = true; this.txtLoginName.Enabled = false; } 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) { DYSubAccountShopEditForm f = new DYSubAccountShopEditForm(shopLoginInfo); 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; } } } }