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.

207 lines
6.9 KiB
C#

using DevComponents.DotNetBar.Controls;
using POS.Language.Language;
using POSV.Entity;
using POSV.StoreBusiness;
using POSV.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace POSV.Business
{
public partial class PosSetForm : BusinessForm
{
private List<PosSetPlanResponse> posSetPlanList = new List<PosSetPlanResponse>();
private string planId = "";
private string planName = LangProxy.ToLang("请选择参数方案");
private bool isUpLoad = false;
public PosSetForm()
{
InitializeComponent();
this.controlBox1.Text = LangProxy.ToLang("云参数上传");
this.controlBox1.ShowApplicationVersion = false;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
InitPosSetPlan();
}
private void InitPosSetPlan()
{
PosSetPlanResponse posSetPlanResponse = new PosSetPlanResponse();
posSetPlanResponse.Id ="";
posSetPlanResponse.Name = "请选择参数方案";
posSetPlanList.Add(posSetPlanResponse);
PosSetPlanRequest request = new PosSetPlanRequest();
request.StoreId = Global.Instance.BusinessPlanLog.StoreId;
var response = StoreBusinessUtils.PosSetPlan(request);
if (response != null && response.Item1)
{
posSetPlanList.AddRange(response.Item3.List);
}
this.PosSetplanCheckBox.DisplayMember = "name";
this.PosSetplanCheckBox.ValueMember = "id";
this.PosSetplanCheckBox.DataSource = posSetPlanList;
this.PosSetplanCheckBox.SelectedIndexChanged += OnPosSetplanSelectedIndexChanged;
}
private void OnPosSetplanSelectedIndexChanged(object sender, EventArgs e)
{
var obj = sender as ComboBoxEx;
this.planId = StringUtils.GetString(obj.SelectedValue);
PosSetPlanResponse posSetPlan = posSetPlanList.Find(x => planId.Equals(x.Id));
if (posSetPlan != null)
{
this.planName = posSetPlan.Name;
}
else
{
this.planName = "";
}
}
private void OnCloseTouchClick(object sender, EventArgs e)
{
//先关闭父窗体
if (this.Owner != null)
{
this.Owner.Close();
}
//再关闭当前窗体
this.Close();
}
private void BtnExitClick(object sender, EventArgs e)
{
//先关闭父窗体
if (this.Owner != null)
{
this.Owner.Close();
}
//再关闭当前窗体
this.Close();
}
private void BtnOkClick(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(this.planId))
{
ShowMessage(this.lblInfo, "请选择门店方案!", true);
return;
}
if (isUpLoad) {
ShowMessage(this.lblInfo, "正在上传,请稍后...", true);
return;
}
ShowMessage(this.lblInfo, "正在上传,请稍后...", false);
this.labelX3.Text = "正在上传,请稍后(整个过程需要5到10秒钟)...";
//组装数据
string resources = JsonUtils.Serialize(LoadResources());
string shortcut = JsonUtils.Serialize(LoadShortcutMenu());
string module = JsonUtils.Serialize(LoadModuleMenu());
isUpLoad = true;
PosSetPlanUpRequest request = new PosSetPlanUpRequest();
request.PlanId = this.planId;
request.Resources = resources;
request.Shortcut = shortcut;
request.Module = module;
request.Config = "";
var response = StoreBusinessUtils.PosSetPlanUp(request);
if (response != null && response.Item1)
{
this.labelX3.Text = "上传成功!";
}
else {
this.labelX3.Text = "上传失败,请重试!";
}
isUpLoad = false;
}
/// <summary>
/// 获取前台资源
/// </summary>
/// <returns></returns>
public List<Resources> LoadResources()
{
List<Resources> list = null;
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" SELECT `id`,`group`,`name`,`keycode`,`keydata`,`enable`,`permission` FROM pos_resources ");
list = db.Query<Resources>(sqlBuld.ToString()).ToList();
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return list;
}
/// <summary>
/// 获取快捷菜单
/// </summary>
/// <returns></returns>
public List<ShortcutMenu> LoadShortcutMenu()
{
List<ShortcutMenu> list = null;
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" SELECT `id`,`area`,`parentId`,`name`,`alias`,`keycode`,`keydata`,`color1`, ");
sqlBuld.Append(" `color2`,`color3`,`fontSize`,`shortcut`,`orderNo`,`icon`,`resourceId`,`enable` ");
sqlBuld.Append(" FROM pos_shortcut ");
list = db.Query<ShortcutMenu>(sqlBuld.ToString()).ToList();
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return list;
}
/// <summary>
/// 获取功能按钮
/// </summary>
/// <returns></returns>
public List<ModuleMenu> LoadModuleMenu()
{
List<ModuleMenu> list = null;
try
{
using (var db = Global.Instance.OpenDataBase)
{
StringBuilder sqlBuld = new StringBuilder();
sqlBuld.Append(" SELECT `id`,`area`,`parentId`,`name`,`alias`,`keycode`,`keydata`,`color1`, ");
sqlBuld.Append(" `color2`,`color3`,`fontSize`,`shortcut`,`orderNo`,`icon`,`resourceId`,`enable`,`layout` ");
sqlBuld.Append(" FROM pos_module ");
list = db.Query<ModuleMenu>(sqlBuld.ToString()).ToList();
}
}
catch (Exception ex)
{
LOGGER.Error(ex);
}
return list;
}
}
}