You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
4.0 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using POSV.Entity;
namespace POSV.Component
{
public partial class PaySettings : AbstractSettings
{
public PaySettings()
{
InitializeComponent();
this.superTabControl.SelectedTabChanging += OnSelectedTabChanging;
this.superTabControl.SelectedTabChanged += OnSelectedTabChanged;
}
private void OnSelectedTabChanged(object sender , DevComponents.DotNetBar.SuperTabStripSelectedTabChangedEventArgs e)
{
}
private void OnSelectedTabChanging(object sender , DevComponents.DotNetBar.SuperTabStripSelectedTabChangingEventArgs e)
{
if (e.OldValue == null)
{
return;
}
//移动支付参数
if (this.payParameter1 is AbstractParameter)
{
var newValue = this.payParameter1.NewChanged();
if (newValue.Count > 0)
{
this.payParameter1.SaveChanged(newValue);
}
}
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (this.DesignMode) return;
this.BackColor = Color.Transparent;
}
public override List<Config> NewChanged()
{
var result = new List<Config>();
//收银小票参数
var payValue = this.payParameter1.NewChanged();
result.AddRange(payValue);
return result;
}
public override Tuple<bool , string> SaveChanged(List<Config> data)
{
bool isSuccess = true;
string message = "参数更新成功";
try
{
var changed = CheckChanged();
isSuccess = changed.Item1;
message = changed.Item2;
}
catch (Exception ex)
{
isSuccess = false;
message = "参数更新异常";
LOGGER.Error(ex , message);
}
return new Tuple<bool , string>(isSuccess , message);
}
private Tuple<bool , string> CheckChanged()
{
var result = new Tuple<bool , string>(true , "没有任何更新");
var selected = this.superTabControl.SelectedTabIndex;
switch (selected)
{
case 0:
{
var newValue = payParameter1.NewChanged();
if (newValue.Count > 0)
{
result = payParameter1.SaveChanged(newValue);
}
}
break;
}
return result;
}
private void OnButtonOKClick(object sender , EventArgs e)
{
var result = CheckChanged();
if (result.Item1)
{
string message = "[" + this.Tag.ToString() + "]的参数修改成功";
DialogForm dialog = new DialogForm("参数更新成功" , message , MessageBoxIcon.Information , MessageBoxButtons.OK);
dialog.ShowDialog();
}
else
{
string message = "[" + this.Tag.ToString() + "]的参数修改失败";
DialogForm dialog = new DialogForm("参数更新失败" , message , MessageBoxIcon.Error , MessageBoxButtons.OK);
dialog.ShowDialog();
}
}
private void OnButtonCloseClick(object sender , EventArgs e)
{
var parent = this.FindForm();
if (parent != null && parent is SettingsForm)
{
var settings = parent as SettingsForm;
settings.FormClose();
}
}
}
}