编程与数学 03-008 《看潮企业管理软件》项目开发 17 单据查询 4-3
摘要:本文介绍了《看潮企业管理软件》中单据查询功能模型的设计与实现。该模块基于.NET WinForms框架和DevExpress控件库开发,采用主从表架构展示单据头和明细数据,支持动态表单生成、多条件查询、模板化打印及XML数据导出。系统实现了灵活的权限控制机制、个性化界面布局保存、以及图片附件管理功能,为企业ERP系统提供了完整的单据查询解决方案。
关键词:企业管理软件;单据查询;ERP系统;WinForms;DevExpress;动态表单;数据导出;权限控制
人工智能助手:DeepSeek、Kimi
三、窗体功能代码
(二)第二部分
csharp
/// <summary>
/// 载入数据:执行查询条件输入,并根据条件查询数据
/// </summary>
private void Dtzr()
{
if (sfljcx)
{
// 链接查询模式,直接使用传递过来的单据列表
dqdjs = listoid.Count;
if (dqdjs > 0)
{
dqdjh = 0;
if (ljoid != "")
{
int h = listoid.IndexOf(ljoid);
if (h >= 0)
{
dqdjh = h;
}
}
}
else
{
dqdjh = -1;
}
sfzr = true;
Djload();
return;
}
loading = true;
try
{
string sqltj1;
sqltj1 = "select dyid,tjxh,tjmc,tjjg,tjsm,tjedit,rxkz from x9_gn_0zrtj nolock where gnbh='" + fgnbh + "' and yhmc='" + pDQYH + "' order by tjxh";
dttj1 = new DataTable();
dttj1 = KcDb.DtRead(sqltj1);
if (dttj1.Rows.Count <= 0)
{
KcDb.DBexec("select x9_zrtjcs('" + fgnbh + "','" + pDQYH + "')");
dttj1 = KcDb.DtRead(sqltj1);
}
if (dttj1.Rows.Count > 0)
{
// 弹出条件输入窗口
FmZRTJ fmtj = new FmZRTJ();
fmtj.Text = fgnmc + "输入条件";
fmtj.fgnbh = fgnbh;
fmtj.fgnmc = fgnmc;
fmtj.Loadtjfm();
fmtj.Tjedit(ref dttj1);
dttj1.AcceptChanges();
fmtj.ShowDialog(this);
if (!fmtj.sfok)
{
if (!sfzr)
{
this.Close();
}
return;
}
Zrtjsave(fmtj.tjlc, ref dttj1);
DataTable udt1 = dttj1.GetChanges();
if (udt1 != null)
{
if (KcDb.GetDtSavev("x9_gn_0zrtj", ref udt1, "tjjg"))
{
dttj1.AcceptChanges();
}
}
fmtj.Dispose();
}
Baroid.EditValue = "";
Lczs.Text = "";
dqdjh = -1;
dqdjs = 0;
for (int i = 0; i < dttj1.Rows.Count; i++)
{
string tjedit = dttj1.Rows[i]["tjedit"].ToString();
switch (tjedit)
{
case "dateedit":
DateTime tjdate;
try
{
tjdate = Convert.ToDateTime(dttj1.Rows[i]["tjjg"]);
}
catch (Exception)
{
tjdate = Getywdate();
}
zrtjstr += dttj1.Rows[i]["tjmc"].ToString() + "@" + tjdate.ToString("yyyy-MM-dd") + "@";
break;
default:
zrtjstr += dttj1.Rows[i]["tjmc"].ToString() + "@" + dttj1.Rows[i]["tjjg"].ToString() + "@";
break;
}
}
string fttj1 = TjStr(ref dttj1, ft1where);
string fttj2 = TjStr(ref dttj1, ft2where);
DataTable kdt1 = new DataTable();
DataTable kdt2 = new DataTable();
string ksql1 = "select " + ft1oid + " from " + ft1 + " where " + fttj1 + " order by " + ft1order;
kdt1 = KcDb.DtRead(ksql1);
string ksql2 = "select " + ft2oid + " from " + ft2 + " where " + fttj2 + " order by " + ft2order;
kdt2 = KcDb.DtRead(ksql2);
if (kdt1 == null || kdt2 == null)
{
if (!sfzr)
{
this.Close();
}
return;
}
string[] o1 = new string[kdt1.Rows.Count];
for (int i = 0; i < kdt1.Rows.Count; i++)
{
o1[i] = kdt1.Rows[i][0].ToString();
}
string[] o2 = new string[kdt2.Rows.Count];
for (int i = 0; i < kdt2.Rows.Count; i++)
{
o2[i] = kdt2.Rows[i][0].ToString();
}
// 取两个结果的交集作为最终查询结果
listoid = o1.Distinct().Intersect(o2.Distinct()).ToList();
if (listoid.Count <= 0)
{
MsgXxShow("没有符合条件的数据,请检查输入条件的正确性或功能定义的正确性");
if (!sfzr)
{
this.Close();
}
return;
}
if (pSFSJ)
{
// 如果是设计模式,更新帮助信息
string t1 = ksql1.Replace("'", "`");
string t2 = ksql2.Replace("'", "`");
string d1 = ("select * from x9_sjzd where tname='" + ft1 + "' and zdbb ='" + ftbb + "'").Replace("'", "`");
string d2 = ("select * from x9_sjzd where tname='" + ft2 + "' and zdbb ='" + ftbb + "'").Replace("'", "`");
KcDb.DBexec("update x9_gn_0dymb set t1='" + t1 + "',t2='" + t2 + "',d1='" + d1 + "',d2='" + d2 +
"' where gnbh='" + fgnbh + "' and sjsd=false");
string strhelp = Environment.NewLine + fgnmc + Environment.NewLine + new string('=', fgnmc.Length * 2) + Environment.NewLine + Environment.NewLine +
"一、功能用途" + Environment.NewLine + Environment.NewLine;
string dt1xm = "二、单据头项目 全部可选项" + Environment.NewLine;
DataRow[] d1r = dtzd2.Select("tname='" + ft1 + "'");
for (int c = 0; c < d1r.Length; c++)
{
dt1xm += d1r[0]["fmemo"].ToString() + "(" + d1r[0]["fname"].ToString() + ")。" + Environment.NewLine;
}
string dt2xm = Environment.NewLine + "三、单据体项目 全部可选项" + Environment.NewLine;
DataRow[] d2r = dtzd2.Select("tname='" + ft2 + "'");
for (int c = 0; c < d2r.Length; c++)
{
dt2xm += d2r[0]["fmemo"].ToString() + "(" + d2r[0]["fname"].ToString() + ")。" + Environment.NewLine;
}
strhelp += "单据查询功能是按月查询,一般不附加更多条件,条件查询请使用相关单据的汇总查询功能" + Environment.NewLine + dt1xm + dt2xm;
strhelp += Environment.NewLine + "四、注意事项" + Environment.NewLine;
strhelp += Environment.NewLine + "五、操作方法(参见单据查询功能操作方法)" + Environment.NewLine;
KcDb.DBexec("update x9_help_yy set mbhelp='" + strhelp + "' where ztbh='" + fgnbh + "'");
}
dqdjs = listoid.Count;
if (dqdjs > 0)
{
dqdjh = 0;
}
else
{
dqdjh = -1;
}
sfzr = true;
loading = false;
Btpg1_itemclick(null, null);
KcDb.DBclose();
}
catch (Exception ex)
{
loading = false;
MsgExShow("数据载入", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 自动配置列宽菜单点击事件
/// </summary>
private void Dxmenuclick(object sender, EventArgs e)
{
Gvoptionwith(ref mtgv, GridDM.Width);
}
/// <summary>
/// 手动配置列宽菜单点击事件
/// </summary>
private void Dxsdclick(object sender, EventArgs e)
{
Gvsdoption(ref mtgv);
}
/// <summary>
/// 主表文件字段按钮点击事件
/// </summary>
private void Filem_buttonclick(object sender, ButtonPressedEventArgs e)
{
if (dqdjh > -1)
{
try
{
string bm = "";
FileOL_edit(this, e.Button.Caption, ft2, e.Button.Tag.ToString(), bm, sender as ButtonEdit);
}
catch (Exception ex)
{
MsgExShow("文件操作", ex.Message, ex.Source, ex.StackTrace);
}
}
}
/// <summary>
/// 主表文件字段按钮点击事件
/// </summary>
private void Fileo_buttonclick(object sender, ButtonPressedEventArgs e)
{
if (dqdjh > -1)
{
try
{
string bm = "";
FileOL_edit(this, e.Button.Caption, ft1, e.Button.Tag.ToString(), bm, sender as ButtonEdit);
}
catch (Exception ex)
{
MsgExShow("文件操作", ex.Message, ex.Source, ex.StackTrace);
}
}
}
/// <summary>
/// 明细表文件字段按钮点击事件
/// </summary>
private void Filep_buttonclick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
try
{
if (mtgv.RowCount <= 0) return;
string bm = "";
FileOL_edit(this, e.Button.Caption, ft2, e.Button.Tag.ToString(), bm, sender as ButtonEdit);
}
catch (Exception ex)
{
MsgExShow("图片文件操作", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 窗体可见性改变事件,用于处理返回后的重新载入
/// </summary>
private void Fm_visiblechanged(object sender, EventArgs e)
{
if (fh && this.Visible)
{
sfzr = false;
Dtzr();
fh = false;
}
}
/// <summary>
/// 清空所有页签中的编辑控件值
/// </summary>
private void Fmxmclear(bool rw)
{
for (int k = 0; k < DJTab.TabPages.Count; k++)
{
LayoutControl lc = DJTab.TabPages[k].Controls[0] as LayoutControl;
Fmxmcls(ref lc, ref rw);
}
Lczs.Text = "";
}
/// <summary>
/// 加载主表数据到界面控件
/// </summary>
private void Fmxmload()
{
if (loading) return;
try
{
DataRow dr = dt1.Rows[0];
if (dr != null)
{
for (int k = 0; k < DJTab.TabPages.Count; k++)
{
LayoutControl lc = DJTab.TabPages[k].Controls[0] as LayoutControl;
Fmecload(ref lc, ref dr);
}
}
else
{
Fmxmclear(true);
}
Barenabled();
}
catch (Exception ex)
{
MsgExShow("加载单据头数据", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 设置所有页签中编辑控件的只读属性
/// </summary>
private void Fmxmrw(bool rw)
{
for (int k = 0; k < DJTab.TabPages.Count; k++)
{
LayoutControl lc = DJTab.TabPages[k].Controls[0] as LayoutControl;
Fmxmec(ref lc, ref rw);
}
}
/// <summary>
/// 窗体关闭中事件,激活其他打开窗口
/// </summary>
private void Form_closing(object sender, CancelEventArgs e)
{
try
{
Form dqfm = null;
foreach (Form opfm in Application.OpenForms)
{
opfm.WindowState = FormWindowState.Normal;
dqfm = opfm;
}
if (dqfm != null)
{
dqfm.Activate();
}
}
catch (Exception ex)
{
MsgExShow("查找父窗口", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 窗体销毁事件,清理资源
/// </summary>
private void Form_disposed(object sender, System.EventArgs e)
{
try
{
for (int i = 0; i < DJTab.TabPages.Count; i++)
{
DJTab.TabPages[i].Controls.Clear();
}
ft1 = null;
ft2 = null;
ftbb = null;
fxz = null;
fgnbh = null;
fgnmc = null;
fdjmc = null;
ft1list = null;
ft1oid = null;
ft1tz = null;
ft1sh = null;
ft1dj = null;
ft1qj = null;
ft1where = null;
ft1order = null;
ft2mid = null;
ft2oid = null;
ft2list = null;
ft2qj = null;
ft2where = null;
ft2order = null;
ft2nryc = null;
ft2mdzd = null;
ft2tpzd = null;
xzdy = false;
xzwj = false;
xzdc = false;
jzzd = null;
dt1 = null;
dtzd1 = null;
dttj1 = null;
dtzd2 = null;
listft2sx = null;
sfzr = false;
sfzf = false;
dqdt2 = null;
ft1fd = null;
ft2fd = null;
mtgv = null;
listoid = null;
GC.Collect();
}
catch (Exception ex)
{
MsgExShow("卸载窗口对象", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 窗体关闭后事件,激活其他打开窗口
/// </summary>
private void Form_FormClosed(object sender, FormClosedEventArgs e)
{
Form dqfm = null;
foreach (Form opfm in Application.OpenForms)
{
opfm.WindowState = FormWindowState.Normal;
dqfm = opfm;
}
if (dqfm != null)
{
dqfm.Activate();
}
}
/// <summary>
/// 加载单据体Grid视图(明细表)
/// </summary>
private void Loaddjgv()
{
try
{
if (ft2 == "")
{
return;
}
if (GridDM == null)
{
loaderr = true;
return;
}
GridDM.ViewCollection.Clear();
mtgv = new GridView(GridDM);
mtgv.BeginUpdate();
mtgv.Name = "mtgv";
mtgv.OptionsBehavior.AutoPopulateColumns = false;
GridDM.DataSource = dqdt2;
GridDM.ForceInitialize();
GridDM.MainView = mtgv;
mtgv.PopulateColumns(dqdt2);
SetGv(ref mtgv, true);
mtgv.PopupMenuShowing += Mtgv_popupmenushowing;
mtgv.OptionsSelection.MultiSelect = true;
mtgv.OptionsSelection.MultiSelectMode = GridMultiSelectMode.RowSelect;
mtgv.OptionsView.EnableAppearanceEvenRow = true;
mtgv.OptionsView.EnableAppearanceOddRow = true;
mtgv.Columns[ft2oid].Visible = false;
mtgv.Columns[ft2mid].Visible = false;
if (hasdjmc) mtgv.Columns["djmc"].Visible = false;
string[] jccol = ft2nryc.Split(',');
for (int k = 0; k < jccol.Length; k++)
{
if (jccol[k].Trim() != "")
{
mtgv.Columns[jccol[k]].Visible = false;
}
}
if (ft2qj != "") mtgv.Columns[ft2qj].Visible = false;
string zdsql = "select * from x9_sjzd where zdbb='" + ftbb + "' and tname='" + ft2 + "' and fmemo<>'' order by fxh";
dtzd2 = KcDb.DtRead(zdsql);
if (dtzd2 != null)
{
if (dtzd2.Rows.Count > 0)
{
Gdloread(ref GridDM, ref mtgv, ref dtzd2, xzwj);
mtgv.KeyDown += Djview_keydown;
mtgv.FocusedRowChanged += Dj_focusedrowchanged;
mtgv.OptionsBehavior.ReadOnly = true;
string[] ctag;
string[] artag = "fileedit,fileread,buttontextedit,buttontextread".Split(',');
for (int col = 0; col < mtgv.Columns.Count; col++)
{
ctag = mtgv.Columns[col].Tag.ToString().Split(',');
if (Array.IndexOf(artag, ctag[0]) < 0)
{
continue;
}
switch (ctag[0])
{
case "fileedit":
case "fileread":
RepositoryItemButtonEdit rc = mtgv.Columns[col].ColumnEdit as RepositoryItemButtonEdit;
rc.ButtonClick += Filem_buttonclick;
if (ft2wjzd == "")
{
ft2wjzd = mtgv.Columns[col].FieldName;
}
else
{
ft2wjzd += "," + mtgv.Columns[col].FieldName;
}
break;
case "buttontextedit":
case "buttontextread":
RepositoryItemButtonEdit rc2 = mtgv.Columns[col].ColumnEdit as RepositoryItemButtonEdit;
rc2.ButtonClick += Text_buttonclick;
break;
}
}
}
}
mtgv.OptionsBehavior.AutoUpdateTotalSummary = false;
string fmset = FmRead(fgnmc + "单据体列宽行高");
string[] fmay = fmset.Split(',');
if (mtgv != null)
{
if (fmay.Length == mtgv.VisibleColumns.Count + 1)
{
for (int c = 0; c < mtgv.VisibleColumns.Count; c++)
{
mtgv.VisibleColumns[c].Width = Convert.ToInt32(fmay[c]);
}
mtgv.RowHeight = Convert.ToInt32(fmay[mtgv.VisibleColumns.Count]);
}
else
{
Gvoptionwith(ref mtgv, GridDM.Width);
}
}
mtgv.EndUpdate();
string strfd = "";
string strcp = "";
for (int c = 0; c < mtgv.Columns.Count; c++)
{
if (mtgv.Columns[c].Visible && (mtgv.Columns[c].Caption.Contains("*")))
{
strfd += mtgv.Columns[c].FieldName + ",";
strcp += mtgv.Columns[c].Caption.Replace("*", "") + ",";
}
}
GridDM.Tag = "gvend";
GridDM.UseEmbeddedNavigator = false;
GridDM.Visible = true;
}
catch (Exception ex)
{
loaderr = true;
MsgExShow("初始单据体主表视图", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 加载窗体布局设置(位置、大小、分割条位置等)
/// </summary>
private void Loadfmset()
{
try
{
string fmset = FmRead(fgnmc);
string[] fmay = fmset.Split(',');
if (fmay.Length >= 5)
{
short ws = 0;
if (fmay.Length == 6)
{
ws = Convert.ToInt16(fmay[5]);
if (ws == 2)
{
this.WindowState = FormWindowState.Maximized;
}
}
if (ws == 0)
{
if (Convert.ToInt16(fmay[0]) > 0) this.Top = Convert.ToInt32(fmay[0]);
if (Convert.ToInt16(fmay[1]) > 0) this.Left = Convert.ToInt32(fmay[1]);
if (Convert.ToInt16(fmay[2]) > 50) this.Width = Convert.ToInt32(fmay[2]);
if (Convert.ToInt16(fmay[3]) > 50) this.Height = Convert.ToInt32(fmay[3]);
}
if (Convert.ToInt16(fmay[4]) > 50) Sp2.SplitterPosition = Convert.ToInt32(fmay[4]);
}
if (!string.IsNullOrEmpty(ft2))
{
fmset = FmRead(fgnmc + "单据体");
fmay = fmset.Split(',');
if (mtgv != null)
{
if (fmay.Length == mtgv.Columns.Count + 1)
{
for (int c = 0; c < mtgv.Columns.Count; c++)
{
int cw = Convert.ToInt32(fmay[c]);
if (cw <= 0)
{
mtgv.Columns[c].Visible = false;
}
else
{
mtgv.Columns[c].Width = cw;
}
}
mtgv.RowHeight = Convert.ToInt32(fmay[mtgv.Columns.Count]);
}
else
{
Gvoptionwith(ref mtgv, GridDM.Width);
}
}
}
}
catch (Exception ex)
{
MsgExShow("应用窗口参数", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// Grid视图右键菜单显示事件,增加自定义菜单项
/// </summary>
private void Mtgv_popupmenushowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
{
try
{
if (e.Menu == null)
{
return;
}
if (e.HitInfo.InColumnPanel)
{
bool ists = false;
foreach (DXMenuItem mi in e.Menu.Items)
{
if (mi.Caption == "自动配置列宽")
{
ists = true;
}
}
if (!ists)
{
DXMenuItem dxmenu = new DXMenuItem();
dxmenu.Caption = "自动配置列宽";
dxmenu.Click += Dxmenuclick;
e.Menu.Items.Add(dxmenu);
DXMenuItem dxmenusd = new DXMenuItem();
dxmenusd.Caption = "手动配置列宽";
dxmenusd.Click += Dxsdclick;
e.Menu.Items.Add(dxmenusd);
}
}
}
catch (Exception ex)
{
MsgExShow("增加配置列宽右键菜单", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 窗体加载事件,初始化界面和数据
/// </summary>
private void Form_load(object sender, System.EventArgs e)
{
try
{
if (KcDb.KcCn.State != ConnectionState.Open)
{
KcDb.DBLJ();
if (!KcDb.SFlj)
{
MsgXxShow("网络数据库未能连接,请在主窗口重试!");
this.Close();
return;
}
}
SetDg(this, 1450, 680, true);
RibbonControl.ApplicationCaption = fgnmc;
RibbonPage1.Text = fgnmc;
if (pCdimage.Images.Count > 0)
{
foreach (BarItem item in RibbonControl.Items)
{
if (item.GetType().Name.ToLower() == "barbuttonitem")
{
if (pCdimage.Images.Keys.IndexOf(item.Caption) > -1)
{
item.LargeGlyph = pCdimage.Images[item.Caption];
}
}
}
}
}
catch (Exception ex)
{
loaderr = true;
MsgExShow("加载菜单图标", ex.Message, ex.Source, ex.StackTrace);
}
try
{
RcCZJL.Items.Clear();
L1.Caption = "[" + fgnmc + "]";
L2.Caption = "[当前用户:" + pDQYH + "]";
L3.Caption = "";
R1.Caption = "";
R2.Caption = "[" + pZTMC + "]";
//加载窗口图标
djcxzs = GetSzcs("单件最大查询张数", 100);
xzdy = (fxz.Substring(1, 1) == "1");
xzwj = (fxz.Substring(3, 1) == "1");
xzdc = (fxz.Substring(4, 1) == "1");
DataRow[] dr = pDTQX.Select("gnbh='" + fgnbh + "'");
if (dr.Length > 0)
{
jzzd = dr[0]["jzzd"].ToString().Trim();
}
if (jzzd.Length > 0)
{
string[] jz = jzzd.Split(',');
for (int j = 0; j < jz.Length; j++)
{
ft1list = ft1list.Replace(jz[j].Trim(), "");
if (ft2 != "")
{
ft2list = ft2list.Replace(jz[j].Trim(), "");
}
}
ft1list = ft1list.Replace(" ", "");
if (ft2 != "")
{
ft2list = ft2list.Replace(" ", "");
while (ft1list.Contains(",,"))
{
ft1list = ft1list.Replace(",,", ",");
}
while (ft2list.Contains(",,"))
{
ft2list = ft2list.Replace(",,", ",");
}
}
}
BarEditDJMC.EditValue = fdjmc;
Baroid.EditValue = "";
Bardjqj.EditValue = "";
if (fdjmc.Length < 8)
{
BarEditDJMC.Width = 150;
}
else
{
BarEditDJMC.Width = 150 + (fdjmc.Length - 7) * 20;
}
if (ft1list.Contains("djmc") && ft2list.Contains("djmc"))
{
hasdjmc = true;
ft1where = ft1where.Replace("{fdjmc}", fdjmc);
ft2where = ft2where.Replace("{fdjmc}", fdjmc);
}
Lctz.Text = "";
Lczs.Text = "";
Lcdj.Text = "";
dtzd1 = new DataTable();
string sqlzd1 = "select * from x9_sjzd nolock where zdbb='" + ftbb + "' and tname='" + ft1 + "' order by fxh";
dtzd1 = KcDb.DtRead(sqlzd1);
//查询分组情况
DataTable dtfz1 = new DataTable();
string sqlfz1 = "select distinct fzmc from x9_sjzd nolock where zdbb='" + ftbb + "' and tname='" + ft1 + "' order by fzmc";
dtfz1 = KcDb.DtRead(sqlfz1);
DJTab.TabPages.Clear();
string fzstr = "";
for (int k = 0; k < dtfz1.Rows.Count; k++)
{
fzstr = dtfz1.Rows[k]["fzmc"].ToString();
DataRow[] fzzdrow = dtzd1.Select("fzmc='" + fzstr + "'");
string[] zdlist = ft1list.Split(',');
bool fzzdhave = false;
for (int l = 0; l < fzzdrow.Length; l++)
{
if (Array.IndexOf(zdlist, fzzdrow[l]["fname"].ToString()) >= 0)
{
fzzdhave = true;
}
}
if (!fzzdhave)
{
continue;
}
XtraTabPage pgfz = DJTab.TabPages.Add();
pgfz.Text = fzstr;
LayoutControl pglc = new LayoutControl
{
Name = fzstr
};
pglc.BeginUpdate();
pgfz.Controls.Add(pglc);
pglc.Dock = DockStyle.Fill;
pglc.OptionsCustomizationForm.ShowLoadButton = false;
pglc.OptionsCustomizationForm.ShowSaveButton = false;
pglc.OptionsCustomizationForm.AllowHandleDeleteKey = true;
pglc.OptionsCustomizationForm.ShowPropertyGrid = true;
pglc.AllowCustomization = false;
Control ctl = GridDM as Control;
string lft = ft1list;
lft = lft.Replace(ft1oid, "");
lft = lft.Replace("djmc", "");
lft = lft.Replace(ft1tz, "");
lft = lft.Replace(ft1qj, "");
lft = lft.Replace(ft1sh, "");
lft = lft.Replace(ft1dj, "");
if (ft2mdzd != "" || ft2tpzd != "")
{
ft1ecol = (short)(ft1ecol - 1);
}
if (ft1ecol > 6) ft1ecol = 6;
if (ft1ecol < 1) ft1ecol = 1;
Fmloread(ref pglc, ref dtzd1, fzstr, lft, k, ft1ecol, true);
string[] artag = "fileedit,fileread,buttontextedit,buttontextread".Split(',');
foreach (LayoutControlItem litem in pglc.Root.Items)
{
string[] ltag = litem.Tag.ToString().Split(',');
if (ltag.Length == 5)
{
string ei = ltag[1];
if (Array.IndexOf(artag, ei) < 0)
{
continue;
}
switch (ei)
{
case "fileedit":
case "fileread":
ButtonEdit xc = litem.Control as ButtonEdit;
if (xc != null)
{
xc.ButtonClick += Fileo_buttonclick;
if (ft1wjzd == "")
{
ft1wjzd = ltag[2];
}
else
{
ft1wjzd += "," + ltag[2];
}
}
break;
case "buttontextedit":
case "buttontextread":
ButtonEdit xc2 = litem.Control as ButtonEdit;
if (xc2 != null)
{
xc2.ButtonClick += Text_buttonclick;
}
break;
}
}
}
pglc.EndUpdate();
}
SetTab(ref DJTab, TabHeaderLocation.Top, TabOrientation.Horizontal);
}
catch (Exception ex)
{
loaderr = true;
MsgExShow("加载窗口,初始单件头控件", ex.Message, ex.Source, ex.StackTrace);
}
try
{
if (ft2 != "")
{
dqdt2 = KcDb.DtRead("select " + ft2list + " from " + ft2 + " where 0=1");
Loaddjgv();
}
}
catch (Exception ex)
{
loaderr = true;
MsgExShow("加载窗口,初始单件体控件", ex.Message, ex.Source, ex.StackTrace);
}
try
{
//加载报表模板
Rcdymb.Items.Clear();
Rcdymb.TextEditStyle = TextEditStyles.DisableTextEditor;
DataTable dtbb = new DataTable();
dtbb = KcDb.DtRead("select mbmc as bbmb from x9_gn_0dymb where gnbh= '" + fgnbh +
"' and ((czry like '%" + pDQYH + "%') or czry='') order by mbxh");
if (dtbb != null)
{
if (dtbb.Rows.Count > 0)
{
for (int i = 0; i < dtbb.Rows.Count; i++)
{
Rcdymb.Items.Add(dtbb.Rows[i]["bbmb"].ToString());
}
Bardymb.EditValue = Rcdymb.Items[0];
}
}
}
catch (Exception ex)
{
loaderr = true;
MsgExShow("加载报表模板", ex.Message, ex.Source, ex.StackTrace);
}
if (loaderr)
{
MsgXxShow("加载功能时出错,请检查功能设计的正确性");
this.Close();
return;
}
Dtzr();
if (!sfzr)
{
return;
}
Loadfmset();
}
/// <summary>
/// 保存窗体布局设置(位置、大小、分割条位置、Grid列宽等)
/// </summary>
private void SaveFmSet()
{
try
{
if (!sfzr) return;
string fmset = this.Top.ToString().Trim() + "," +
this.Left.ToString().Trim() + "," +
this.Width.ToString().Trim() + "," +
this.Height.ToString().Trim() + "," +
Sp2.SplitterPosition.ToString().Trim() + "," +
Convert.ToInt32(this.WindowState).ToString();
FmSave(fgnmc, fmset);
if (mtgv != null && mtgv.RowCount > 0)
{
fmset = mtgv.Columns[0].Width.ToString();
for (int g = 1; g < mtgv.Columns.Count; g++)
{
int cw = -1;
if (mtgv.Columns[g].Visible)
{
cw = mtgv.Columns[g].Width;
}
fmset += "," + cw.ToString();
}
FmSave(fgnmc + "单据体", fmset + "," + mtgv.RowHeight.ToString());
}
}
catch (Exception ex)
{
MsgExShow("保存窗口参数", ex.Message, ex.Source, ex.StackTrace);
}
}
/// <summary>
/// 文本字段按钮点击事件,弹出文本编辑窗口
/// </summary>
private void Text_buttonclick(object sender, ButtonPressedEventArgs e)
{
if (dqdjh > -1)
{
ButtonEdit be = sender as ButtonEdit;
FmTEXT fmrt = new FmTEXT();
Text_edit(fmrt, this, ref be, e.Button.Caption);
fmrt.Dispose();
}
}
/// <summary>
/// 查找单据功能,根据输入的后四位数字或字符串查找单据
/// </summary>
private void Textss()
{
try
{
string czstr = "";
czstr = XtraInputBox.Show("请输入单据号后四位的数值或其他字符:", pZTMC, "");
if (czstr == "")
{
return;
}
string czoid = "";
if (IsNumeric(czstr))
{
for (int r = dqdjh + 1; r < listoid.Count; r++)
{
czoid = listoid[r];
if (Convert.ToInt32(czstr) == Convert.ToInt32(czoid.Substring(czoid.Length - 4, 4)))
{
dqdjh = r;
Djload();
return;
}
}
for (int r = 0; r < dqdjh; r++)
{
czoid = listoid[r];
if (Convert.ToInt32(czstr) == Convert.ToInt32(czoid.Substring(czoid.Length - 4, 4)))
{
dqdjh = r;
Djload();
return;
}
}
}
if (czstr.Length < dqoid.Length)
{
for (int r = dqdjh + 1; r < listoid.Count; r++)
{
czoid = listoid[r];
if (czoid.IndexOf(czstr) > 0)
{
dqdjh = r;
Djload();
return;
}
}
for (int r = 0; r < dqdjh; r++)
{
czoid = listoid[r];
if (czoid.IndexOf(czstr) > 0)
{
dqdjh = r;
Djload();
return;
}
}
}
}
catch (Exception ex)
{
MsgExShow("单据查找", ex.Message, ex.Source, ex.StackTrace);
}
}