| | |
| | | { |
| | | InitializeComponent(); |
| | | this.Load += PersonalCenterDlg_Load; |
| | | this.gridView1.SetNormalView(20); |
| | | this.gridView2.SetNormalView(20); |
| | | this.IconOptions.Icon = Yw.WinFrmUI.GlobalParas.AppIcon; |
| | | } |
| | | |
| | | private const string _smsTemplate = "hzkw_sms_template";//手机号登录模板 |
| | | private const string _vxTemplate = "hzkw_wx_template";//微信登录模板 |
| | | private const string _software = "HStation_XHS_DESKTOP";//软件编码 |
| | | |
| | | private List<PhoneData> _phoneNuberBinding; |
| | | private List<WxData> _WxBinding; |
| | | private long _wxId; |
| | | private long _phoneId; |
| | | |
| | | //初始化 |
| | | private void PersonalCenterDlg_Load(object? sender, EventArgs e) |
| | | private async void PersonalCenterDlg_Load(object? sender, EventArgs e) |
| | | { |
| | | this.txtEditUserName.Text = GlobalParas._GlobalParas.LoginName; |
| | | this.txtEditAdminType.Text = GlobalParas._GlobalParas.AdminType; |
| | | this.txtAccountName.Text = GlobalParas._GlobalParas.AccountName; |
| | | this.textAccountType.Text = GlobalParas._GlobalParas.LoginType; |
| | | phoneInitialize(); |
| | | wxInitialize(); |
| | | |
| | | var allPhones = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.GetSmsByUserID(GlobalParas._GlobalParas.UserID); |
| | | var allWeChat = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.GetWechatByUserID(GlobalParas._GlobalParas.UserID); |
| | | if (allPhones!=null&&allPhones.Any()) |
| | | { |
| | | _phoneId = allPhones.First().ID; |
| | | this.buttonEditPhone.EditValue = allPhones.First().Credential; |
| | | } |
| | | if (allWeChat!=null&&allWeChat.Any()) |
| | | { |
| | | _wxId = allWeChat.First().ID; |
| | | this.buttonEditWeChat.EditValue = allWeChat.First().Credential; |
| | | } |
| | | } |
| | | |
| | | public class PhoneData |
| | |
| | | { |
| | | public long ID { get; set; } |
| | | public string Wxid { get; set; } |
| | | } |
| | | |
| | | //手机号初始化 |
| | | private async void phoneInitialize() |
| | | { |
| | | _phoneNuberBinding = new List<PhoneData>(); |
| | | var allPhones = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.GetSmsByUserID(GlobalParas._GlobalParas.UserID); |
| | | if (allPhones != null) |
| | | { |
| | | foreach (var item in allPhones) |
| | | { |
| | | _phoneNuberBinding.Add(new PhoneData |
| | | { |
| | | Phone = item.Credential, |
| | | ID = item.ID |
| | | }); |
| | | } |
| | | } |
| | | this.gridControl1.DataSource = _phoneNuberBinding; |
| | | } |
| | | |
| | | //微信绑定初始化 |
| | | private async void wxInitialize() |
| | | { |
| | | _WxBinding = new List<WxData>(); |
| | | var allPhones = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.GetWechatByUserID(GlobalParas._GlobalParas.UserID); |
| | | if (allPhones != null) |
| | | { |
| | | foreach (var item in allPhones) |
| | | { |
| | | _WxBinding.Add(new WxData |
| | | { |
| | | Wxid = item.Credential, |
| | | ID = item.ID |
| | | }); |
| | | } |
| | | } |
| | | this.gridControl2.DataSource = _WxBinding; |
| | | } |
| | | |
| | | //修改密码 |
| | |
| | | } |
| | | } |
| | | |
| | | //添加手机号 |
| | | private void btnAddPhone_Click(object sender, EventArgs e) |
| | | { |
| | | var dlg = new AddPhoneNumberDlg(); |
| | | dlg.ReloadDataEvent += async (phoneNumber) => |
| | | { |
| | | var id = await PhoneBinding(phoneNumber); |
| | | if (id > 0) |
| | | /* |
| | | //添加手机号 |
| | | private void btnAddPhone_Click(object sender, EventArgs e) |
| | | { |
| | | _phoneNuberBinding.Add(new PhoneData { Phone = phoneNumber, ID = id }); |
| | | this.gridControl1.RefreshDataSource(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | var dlg = new AddPhoneNumberDlg(); |
| | | dlg.ReloadDataEvent += async (phoneNumber) => |
| | | { |
| | | var id = await PhoneBinding(phoneNumber); |
| | | if (id > 0) |
| | | { |
| | | _phoneNuberBinding.Add(new PhoneData { Phone = phoneNumber, ID = id }); |
| | | this.gridControl1.RefreshDataSource(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | }*/ |
| | | |
| | | //手机号单元格点击事件 |
| | | private async void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
| | | /* //添加微信 |
| | | private void btnAddWx_Click(object sender, EventArgs e) |
| | | { |
| | | var dlg = new WechatBindingDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.CodeReloadData += async (code) => |
| | | { |
| | | var id = await WechatBinding(code); |
| | | if (id > 0) |
| | | { |
| | | _WxBinding.Add(new WxData { Wxid = code, ID = id }); |
| | | this.gridControl2.RefreshDataSource(); |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | }*/ |
| | | |
| | | private async void buttonEditPhone_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | var vm = this.gridView1.GetCurrentViewModel(_phoneNuberBinding); |
| | | if (vm == null) |
| | | if (e.Button.Tag.ToString() == "import") |
| | | { |
| | | return; |
| | | } |
| | | if (e.Column == this.colDel) |
| | | { |
| | | var bol = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.DeleteByID(vm.ID); |
| | | if (!bol) |
| | | if (this.buttonEditPhone.EditValue != null) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | TipFormHelper.ShowWarn("已存在手机号"); |
| | | return; |
| | | } |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | _phoneNuberBinding.Remove(vm); |
| | | this.gridControl1.RefreshDataSource(); |
| | | var dlg = new AddPhoneNumberDlg(); |
| | | dlg.ReloadDataEvent += async (phoneNumber) => |
| | | { |
| | | var id = await PhoneBinding(phoneNumber); |
| | | if (id > 0) |
| | | { |
| | | _phoneId = id; |
| | | this.buttonEditPhone.EditValue = phoneNumber; |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | else if (e.Button.Tag.ToString() == "delete") |
| | | { |
| | | if (_phoneId > 0) |
| | | { |
| | | var bol = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.DeleteByID(_phoneId); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | return; |
| | | } |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | _phoneId = default; |
| | | this.buttonEditPhone.EditValue = null; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //微信单元格点击事件 |
| | | private async void gridView2_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e) |
| | | private async void buttonEditWeChat_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) |
| | | { |
| | | var vm = this.gridView2.GetCurrentViewModel(_WxBinding); |
| | | if (vm == null) |
| | | if (e.Button.Tag.ToString() == "import") |
| | | { |
| | | return; |
| | | } |
| | | if (e.Column == this.colWxDel) |
| | | { |
| | | var bol = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.DeleteByID(vm.ID); |
| | | if (!bol) |
| | | if (this.buttonEditWeChat.EditValue != null) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | TipFormHelper.ShowWarn("已存在微信"); |
| | | return; |
| | | } |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | _WxBinding.Remove(vm); |
| | | this.gridControl2.RefreshDataSource(); |
| | | } |
| | | } |
| | | |
| | | //添加微信 |
| | | private void btnAddWx_Click(object sender, EventArgs e) |
| | | { |
| | | var dlg = new WechatBindingDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.CodeReloadData += async (code) => |
| | | { |
| | | var id = await WechatBinding(code); |
| | | if (id > 0) |
| | | var dlg = new WechatBindingDlg(); |
| | | dlg.SetBindingData(); |
| | | dlg.CodeReloadData += async (code) => |
| | | { |
| | | _WxBinding.Add(new WxData { Wxid = code, ID = id }); |
| | | this.gridControl2.RefreshDataSource(); |
| | | var id = await WechatBinding(code); |
| | | if (id > 0) |
| | | { |
| | | _wxId = id; |
| | | this.buttonEditWeChat.EditValue = id; |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | else if (e.Button.Tag.ToString() == "delete") |
| | | { |
| | | if (_wxId > 0) |
| | | { |
| | | var bol = await BLLFactory<Yw.BLL.UserLoginAccount>.Instance.DeleteByID(_wxId); |
| | | if (!bol) |
| | | { |
| | | TipFormHelper.ShowError("删除失败!"); |
| | | return; |
| | | } |
| | | TipFormHelper.ShowSucceed("删除成功!"); |
| | | _wxId = default; |
| | | this.buttonEditWeChat.EditValue = null; |
| | | } |
| | | }; |
| | | dlg.ShowDialog(); |
| | | } |
| | | } |
| | | } |
| | | } |