using DevExpress.Data;
using DevExpress.Utils;
using DevExpress.XtraBars;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraTab;
using DevExpress.XtraTreeList.Columns;
using DevExpress.XtraTreeList.Nodes;
using Lskj.Business;
using Lskj.Business.Impl;
using Lskj.Control;
using Lskj.Control.BrowserSetting;
using Lskj.Control.Model;
using Lskj.Core;
using Lskj.Data;
using Lskj.Model;
using Lskj.PubBillManagement.Model;
using Lskj.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Lskj.PubBillManagement
{
public partial class FrmBill : BaseForm
{
///
/// 是否为初始化创建
///
private bool _isInitFinish;
///
/// 是否加载右侧控件数据
///
private bool _isLoadRightControlValue = true;
///
/// 是否手动选择了模版
///
private bool _isSelectedTemplete;
///
/// 是否直接打印
///
private bool _isExcPrint;
///
/// 是否选择关联下发
///
private bool _isCheck;
///
/// 主打印Sql
///
private string _mainPrintSql;
private string guidField = "xxxxx_guid";
///
/// 主键字段
///
private string mRecordPrimaryField;
///
/// 单据水印
///
private WaterMark _waterMark;
///
/// 导入单据明细数据、导入单据明细并更新
///
private BarButtonItem _itemImport, _itemImportUpdate;
///
/// 打印主sql中关联打印次数返回条件
///
private string _printModeCond;
///
/// 打印完成后添加数据用到的参数: 表名,列前缀,主键字段,主键值,模块编号,主打印Sql
///
private List _printSaveParams;
///
/// 单据明细列
///
private DataTable _detailColumns;
private bool IsCopying = false;
protected DataRow BillRowItem;
///
/// 主表控件
///
public MyControl ControlObj;
///
/// 入口参数
///
protected DynamicBillModel SysModel;
///
/// 是否为Brp模版
///
/// true if this instance is BRP templete; otherwise, false.
protected bool IsBrpTemplete { get { return SysModel is DynamicBillBrpModel; } }
///
///
///
public BillModel BillModel;
///
/// 快速扫码控件
///
/// The main bottom input object.
public PanelControl MainBottomInputObj { get { return this.pl_input; } }
///
/// Brp模版控件
///
/// The main bottom templete object.
public PanelControl MainBottomTempleteObj { get { return this.pl_templete; } }
///
/// 明细表格数据
///
/// The main bottom templete object.
public GridControlEx gcMainDetilObj { get { return this.gcMain; } }
///
/// Brp模版控件
///
/// 扫码框
public TextEdit txtinputobj { get { return this.txt_input; } }
///
/// 数量名称
///
public string NumberMc;
///
/// 红字单据的分配管理模块
///
public string rdRedUnionCode;
///
/// 蓝字单据的分配管理模块
///
public string rdBlueUnionCode;
///
/// 是否拖拽换行展示
///
public bool isDragWrap = true;
///
/// 是否执行了加载储存过程
///
//public bool ProcessExists = false;
///
/// 保存或修改时报错信息
///
public string SaveErrorMessage = string.Empty;
///
/// 单据明细删除的行
///
// private Dictionary ToWithdrawRows = new Dictionary();
private List> ToWithdrawRows = new List>();
///
///改变颜色行
///
private List ChangeColorRow = new List();
///
///
///
public string AssociatedField = string.Empty;
///
/// 注册设置公共事件私有类
///
private static PubEvenImpl _eventHandler;
///
/// 注册设置公共事件类
///
private static PubEvenImpl eventHandler;
///
/// 当前人员是否有导出权限
///
public bool ExportPermission;
///
/// 新增
///
public string addText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("新增") + ")" : "(新增)";
///
/// 修改
///
public string updateText = Business.Impl.LanguageTranslation.Translatable ? "(" + Business.Impl.LanguageTranslation.GetTranslatedText("修改") + ")" : "(修改)";
///
/// 主表动态生成的日期列
///
public List DateColumnList = new List();
///
/// 主表动态生成的合计列
///
public GridColumn SumGridColumn = new GridColumn();
///
/// 附加右键菜单集合
///
public List itemCommonList = new List();
///
/// 是否已经添加了多行汇总
///
public bool MultiLineSummary;
///
/// 扫码框
///
public TextEdit ScanCodeTextEdit = null;
///
/// 当前操作的ImageEdit
///
private LabelImageEdit _imageEdit;
///
/// 保存验证条件表
///
public DataTable SaveCondTab = new DataTable();
private BarManager barManager1;
private PopupMenu pMenu;
private PopupMenu pmBillExp;
private PopupMenu pmBill;
private PopupMenu pMprint;
private PopupMenu pmFP;
///
/// 单据保存或提交成功后通知来源界面刷新。
///
public event EventHandler BillChanged;
public FrmBill()
{
InitializeComponent();
InitializeMainEvents();
}
public FrmBill(DynamicBillModel model)
: this()
{
OnLoad(model);
}
private void InitializeMainEvents()
{
this.dbpFP.Click += new EventHandler(this.OnBtnFPOldClick);
this.btnRefresh.Click += new EventHandler(this.btnRefresh_Click);
this.btnHiding.Click += new EventHandler(this.OnMainTableHiding);
this.btnHelp.Click += new EventHandler(this.OnHelpClick);
this.cb_templete.QueryCloseUp += new CancelEventHandler(this.cb_templete_QueryCloseUp);
this.cb_templete.Click += new EventHandler(this.OnTempleteClick);
this.txt_input.KeyDown += new KeyEventHandler(this.OnInputKeyDown);
this.btn_input.Click += new EventHandler(this.OnInputClick);
this.btnBillAdd.Click += new EventHandler(this.OnBillAddClick);
this.btnBillApply.Click += new EventHandler(this.OnBillApplyClick);
this.dpbTools.Click += new EventHandler(this.OnToolsClick);
this.btnDelete.Click += new EventHandler(this.OnDeleteClick);
this.btnBillSave.Click += new EventHandler(this.OnBillSaveClick);
this.lbTitle.Paint += new PaintEventHandler(this.OnLabelTitlePaint);
this.rdRed.Click += new EventHandler(this.OnRedStateClick);
this.rdBlue.Click += new EventHandler(this.OnBlueStateClick);
this.pl_main_center_master.Click += new EventHandler(this.OnMainFocusAfter);
this.KeyDown += new KeyEventHandler(this.OnFrmMainKeyDown);
}
private void InitializePopupMenus()
{
if (this.barManager1 != null) return;
if (this.components == null)
{
this.components = new Container();
}
this.barManager1 = new BarManager(this.components);
this.barManager1.Form = this;
this.pmFP = new PopupMenu(this.components) { Manager = this.barManager1 };
this.pmBillExp = new PopupMenu(this.components) { Manager = this.barManager1 };
this.pmBill = new PopupMenu(this.components) { Manager = this.barManager1 };
this.pMprint = new PopupMenu(this.components) { Manager = this.barManager1 };
this.pMenu = new PopupMenu(this.components) { Manager = this.barManager1 };
this.dbpFP.DropDownControl = this.pmFP;
this.dpbImport.DropDownControl = this.pmBillExp;
this.dpCopyBill.DropDownControl = this.pmBill;
this.btnPrint.DropDownControl = this.pMprint;
this.dpbTools.DropDownControl = this.pMenu;
this.txt_input.MenuManager = this.barManager1;
}
protected virtual void OnBillChanged(EventArgs e)
{
EventHandler handler = BillChanged;
if (handler != null) handler(this, e);
}
///
/// 说明:窗口加载
/// 创建人:龚宇超
/// 创建日期:2017-11-23
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The instance containing the event data.
public void OnLoad(DynamicBillModel Model)
{
try
{
this.SysModel = Model;// 单据动态链接库参数,入口参数
this._isInitFinish = false;// 是否为初始化创建
this.pl_main.Visible = false; //获取或设置一个值,该值指示是否显示该控件及其所有子控件。
//this.ProcessExists = (Lskj.Data.Caches.CacheSYSConfig.Instance().JudgeProcessExists() && SystemInfo.Instance.isExecload);
if (true)//5.0控件样式
{
this.pl_main_bottom.BorderStyle = DevExpress.XtraEditors.Controls.BorderStyles.NoBorder;
this.pl_main_bottom.BackColor = Color.FromArgb(240, 240, 240);
this.pl_main_bottom.LookAndFeel.UseDefaultLookAndFeel = false;
this.pl_main_bottom.LookAndFeel.UseWindowsXPTheme = true;
}
Dictionary