177 lines
6.6 KiB
C#
177 lines
6.6 KiB
C#
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;
|
|
using AllBase;
|
|
|
|
namespace TemuKJD.WXForms.ShopForms
|
|
{
|
|
public partial class WXShopAddEditForm : BaseGeneralForm
|
|
{
|
|
List<ShopLoginInfo> lstShopLoginInfo = null;
|
|
ShopLoginInfo shop = null;
|
|
bool isAdd = true;
|
|
|
|
public WXShopAddEditForm(List<ShopLoginInfo> 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<ShopLoginInfo>();
|
|
shop = new ShopLoginInfo();
|
|
}
|
|
|
|
shop.LoginName = this.txtLoginName.Text.Trim();
|
|
if (!string.IsNullOrEmpty(this.txtShopPassword.Text.Trim()))
|
|
shop.Password = DataOpenSSL.EncryptString(this.txtShopPassword.Text.Trim());
|
|
|
|
if (chkNotes.Checked)
|
|
shop.Notes = this.txtNotes.Text;
|
|
if (chkShopGroup.Checked)
|
|
shop.GroupName = this.cmbGroup.Text;
|
|
if (chkSubAccount.Checked)
|
|
{
|
|
if (shopSubAccountTmp == null)
|
|
shopSubAccountTmp = JsonHelper.DeserializeJsonToObject<ShopLoginInfo>(JsonHelper.SerializeObject(shop));
|
|
shop.SubUserName = shopSubAccountTmp.SubUserName;
|
|
}
|
|
|
|
shop.CompanyName = AllBase.BaseClass.CompanyName;
|
|
|
|
foreach (var sp in lstShopLoginInfo)
|
|
{
|
|
sp.CompanyName = AllBase.BaseClass.CompanyName;
|
|
if (chkNotes.Checked)
|
|
sp.Notes = this.txtNotes.Text;
|
|
if (chkShopGroup.Checked)
|
|
sp.GroupName = this.cmbGroup.Text;
|
|
if (chkSubAccount.Checked)
|
|
sp.SubUserName = shop.SubUserName;
|
|
}
|
|
|
|
this.OnSaveComplete(lstShopLoginInfo, isAdd, this);
|
|
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.txtChatAccount.Text = shop.SubUserName;
|
|
if (!string.IsNullOrEmpty( shop.SubUserName))
|
|
{
|
|
var subUserNames = shop.SubUserName.Split(',').Where(su => !string.IsNullOrEmpty(su));
|
|
var subUsers = WXSubAccountShopEditForm.lstAllSubAccount.Where(su => subUserNames.Contains(su.user_name));
|
|
this.txtChatNick.Text = string.Join(",", subUsers.Select(s => s.nick_name));
|
|
}
|
|
this.txtUploadAccount.Text = shop.UploadAccount;
|
|
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 = "请在编辑账户时修改子账户";
|
|
}
|
|
if (AllBase.BaseClass.GroupId != 3)
|
|
{
|
|
this.txtChatAccount.Enabled = false;
|
|
//this.cmbGroup.Enabled = false;
|
|
}
|
|
}
|
|
|
|
private void txtUploadAccount_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtChat_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void txtBuyAccount_TextChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
ShopLoginInfo shopSubAccountTmp;
|
|
private void txt_Click(object sender, EventArgs e)
|
|
{
|
|
shopSubAccountTmp = JsonHelper.DeserializeJsonToObject<ShopLoginInfo>(JsonHelper.SerializeObject(shop));
|
|
WXSubAccountShopEditForm f = new WXSubAccountShopEditForm(shopSubAccountTmp);
|
|
f.SaveComplete += F_SaveComplete;
|
|
f.ShowDialog();
|
|
}
|
|
|
|
private void F_SaveComplete(object obj)
|
|
{
|
|
var shopSubAccountTmp = obj as ShopLoginInfo;
|
|
if (shopSubAccountTmp != null)
|
|
{
|
|
this.txtBuyAccount.Text = shopSubAccountTmp.BuyAccount;
|
|
this.txtChatAccount.Text = shopSubAccountTmp.ChatAccount;
|
|
this.txtUploadAccount.Text = shopSubAccountTmp.UploadAccount;
|
|
|
|
this.txtChatAccount.Text = shopSubAccountTmp.SubUserName;
|
|
if (!string.IsNullOrEmpty(shopSubAccountTmp.SubUserName))
|
|
{
|
|
var subUserNames = shopSubAccountTmp.SubUserName.Split(',').Where(su => !string.IsNullOrEmpty(su));
|
|
var subUsers = WXSubAccountShopEditForm.lstAllSubAccount.Where(su => subUserNames.Contains(su.user_name));
|
|
this.txtChatNick.Text = string.Join(",", subUsers.Select(s => s.nick_name));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|