You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
593 lines
23 KiB
593 lines
23 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using DevExpress.XtraEditors;
|
|
using ICSSoft.Frame.User.BLL;
|
|
using ICSSoft.Base.Language.Tool;
|
|
using ICSSoft.Base.UserControl.MessageControl;
|
|
using System.Data.SqlClient;
|
|
using ICSSoft.Base.Config.AppConfig;
|
|
using ICSSoft.Base.Report.Filter;
|
|
using ICSSoft.Base.Config.DBHelper;
|
|
using ICSSoft.Base.UserControl.FormControl;
|
|
using ICSSoft.Base.ReferForm.AppReferForm;
|
|
using ICSSoft.Base.Lable.PrintTool;
|
|
using ICSSoft.Frame.Data.DAL;
|
|
using ICSSoft.Frame.Data.BLL;
|
|
using ICSSoft.Frame.Data.Entity;
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
|
namespace ICSSoft.Frame.APP
|
|
{
|
|
public partial class FormICSProjectReports1 : DevExpress.XtraEditors.XtraForm
|
|
{
|
|
private string sqltxt = "";
|
|
private string sqlconn = "";
|
|
DataTable dt;
|
|
string opcodes = "";
|
|
string vencode = "";
|
|
string pocode = "";
|
|
Color color ;
|
|
private DataTable dataSource = null;
|
|
DataTable Color_table = null;
|
|
#region 构造函数
|
|
public FormICSProjectReports1()
|
|
{
|
|
InitializeComponent();
|
|
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
|
|
this.WindowState = FormWindowState.Maximized;
|
|
button7.BackColor = Color.FromArgb(254, 177, 95);
|
|
checkDate.Checked = true;
|
|
txtStartDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
|
|
txtEndDate.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).AddMonths(1).AddDays(-1);
|
|
Search();
|
|
}
|
|
#endregion
|
|
|
|
private void Search()
|
|
{
|
|
string sql = @"select * from dbo.ICSLOTONWIP order by MTIME desc";
|
|
sql = string.Format(sql);
|
|
dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
|
|
}
|
|
|
|
#region 移动窗体
|
|
private const int WM_NCHITTEST = 0x84;
|
|
private const int HTCLIENT = 0x1;
|
|
private const int HTCAPTION = 0x2;
|
|
//首先必须了解Windows的消息传递机制,当有鼠标活动消息时,
|
|
//系统发送WM_NCHITTEST 消息给窗体作为判断消息发生地的根据。 nchittest
|
|
//假如你点击的是标题栏,窗体收到的消息值就是 HTCAPTION ,
|
|
//同样地,若接受到的消息是 HTCLIENT,说明用户点击的是客户区,也就是鼠标消息发生在客户区。
|
|
|
|
//重写窗体,使窗体可以不通过自带标题栏实现移动
|
|
protected override void WndProc(ref Message m)
|
|
{
|
|
|
|
|
|
//当重载窗体的 WndProc 方法时,可以截获 WM_NCHITTEST 消息并改些该消息,
|
|
//当判断鼠标事件发生在客户区时,改写改消息,发送 HTCAPTION 给窗体,
|
|
//这样,窗体收到的消息就时 HTCAPTION ,在客户区通过鼠标来拖动窗体就如同通过标题栏来拖动一样。
|
|
//注意:当你重载 WndProc 并改写鼠标事件后,整个窗体的鼠标事件也就随之改变了。
|
|
switch (m.Msg)
|
|
{
|
|
case WM_NCHITTEST:
|
|
base.WndProc(ref m);
|
|
if ((int)m.Result == HTCLIENT)
|
|
m.Result = (IntPtr)HTCAPTION;
|
|
return;
|
|
}
|
|
//拦截双击标题栏、移动窗体的系统消息
|
|
if (m.Msg != 0xA3)
|
|
{
|
|
base.WndProc(ref m);
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 权限
|
|
|
|
/// <summary>
|
|
/// 操作权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable RightOfExute()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BtnName");
|
|
rData.Columns.Add("ActionName");
|
|
//查看权限(必须有)
|
|
DataRow seeRow = rData.NewRow();
|
|
seeRow["BtnName"] = "see";
|
|
seeRow["ActionName"] = "查看";
|
|
rData.Rows.Add(seeRow);
|
|
|
|
|
|
//List<Control> ControlList = new List<Control>();
|
|
|
|
//foreach (Control ctr in ControlList)
|
|
//{
|
|
|
|
// if (ctr.GetType() == typeof(SimpleButton))
|
|
// {
|
|
// DataRow dr = rData.NewRow();
|
|
// dr["BtnName"] = ctr.Name;
|
|
// dr["ActionName"] = ctr.Text;
|
|
// rData.Rows.Add(dr);
|
|
// }
|
|
//}
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
/// <summary>
|
|
/// 数据权限
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public DataTable RightOfData()
|
|
{
|
|
DataTable rData = new DataTable();
|
|
rData.Columns.Add("BodyName");
|
|
rData.Columns.Add("ControlName");
|
|
rData.Columns.Add("ControlCaption");
|
|
|
|
rData.AcceptChanges();
|
|
return rData;
|
|
}
|
|
#endregion
|
|
|
|
#region 退出
|
|
private void btnClose_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
AppConfig.CloseFormShow(this.Text);
|
|
this.Close();
|
|
}
|
|
#endregion
|
|
|
|
#region 拼接查询条件
|
|
private string getWhere()
|
|
{
|
|
string where = "1=1";
|
|
|
|
if (!string.IsNullOrEmpty(txtMoCodeS.Text)) {
|
|
where += " and c.transno like '"+txtMoCodeS.Text+"' ";
|
|
}
|
|
//if (!string.IsNullOrEmpty(txtStartDate.Text.Trim()))
|
|
//{
|
|
// where += " and c.transno like '" + txtMoCodeS.Text + "' ";
|
|
//}
|
|
|
|
|
|
if (!string.IsNullOrEmpty(txtLotNOS.Text)) {
|
|
where += " and c.lotno like '"+txtLotNOS.Text+"'";
|
|
}
|
|
if (!string.IsNullOrEmpty(MDeptCode.Text))
|
|
{
|
|
where += " and MDeptCode like '" + MDeptCode.Text + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(txtOrderNo.Text.Trim()))
|
|
{
|
|
where += " and d.OrderNO like '%" + txtOrderNo.Text.Trim() + "%'";
|
|
}
|
|
|
|
#region 预计完工时间
|
|
if (checkDate.Checked)
|
|
{
|
|
where += " and d.MOPLANENDDATE BETWEEN " + "'" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "'" + " AND " + "'" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "'";
|
|
}
|
|
#endregion
|
|
return where;
|
|
}
|
|
#endregion
|
|
|
|
#region 拼接查询条件
|
|
private string getWhere2()
|
|
{
|
|
string where = "1=1";
|
|
if (!string.IsNullOrEmpty(txtMoCodeS.Text))
|
|
{
|
|
where += " and a.mocode like ''" + txtMoCodeS.Text + "'' ";
|
|
}
|
|
if (!string.IsNullOrEmpty(txtLotNOS.Text))
|
|
{
|
|
where += " and b.lotno like ''" + txtLotNOS.Text + "''";
|
|
}
|
|
if (!string.IsNullOrEmpty(MDeptCode.Text))
|
|
{
|
|
where += " and MDeptCode like ''" + MDeptCode.Text + "''";
|
|
}
|
|
if (!string.IsNullOrEmpty(txtOrderNo.Text.Trim()))
|
|
{
|
|
where += " and A.OrderNO like ''%" + txtOrderNo.Text.Trim() + "%''";
|
|
}
|
|
|
|
#region 预计完工时间
|
|
if (checkDate.Checked)
|
|
{
|
|
where += " and a.MOPLANENDDATE BETWEEN " + "''" + Convert.ToDateTime(txtStartDate.Text).ToString("yyyy-MM-dd") + "''" + " AND " + "''" + Convert.ToDateTime(txtEndDate.Text).ToString("yyyy-MM-dd") + "''";
|
|
}
|
|
#endregion
|
|
return where;
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
private void btnFilter_Click(object sender, EventArgs e)
|
|
{
|
|
grvDetail.Columns.Clear();
|
|
grdDetail.DataSource = null;
|
|
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
|
|
try
|
|
{
|
|
|
|
_wait.Show();
|
|
|
|
string sql = @"SELECT DISTINCT
|
|
lot.LOTNO,
|
|
mo2user.id,
|
|
a.OPCODE,
|
|
b.Result,
|
|
a.ACTIONRESULT,
|
|
ncr.ID
|
|
FROM
|
|
icsitemlot lot WITH(nolock)
|
|
inner join icsmo mo WITH(nolock) on mo.mocode=lot.transno and mo.moseq=lot.transline
|
|
left join icsmo2user mo2user on mo2user.lotno=lot.lotno
|
|
left join ICSLOTONWIP a WITH(nolock) on a.lotno=lot.lotno and a.opcode=mo2user.opcode
|
|
LEFT JOIN ICSLOTONWIPCheck b WITH(nolock) ON a.ID=b.ONWIPID
|
|
LEFT JOIN ICSLOTSIMULATION c WITH(nolock) ON a.MOCODE=c.MOCODE AND a.MOSEQ=c.MOSEQ AND a.LOTNO=c.LOTNO
|
|
LEFT JOIN ICSNCRDoc ncr on ncr.LOTNO=A.LotNO and ncr.OPCode=A.OPCODE and ncr.ErrorType='自检'
|
|
WHERE (a.EATTRIBUTE1 is null OR a.EATTRIBUTE1 <>'转移') ";
|
|
|
|
Color_table = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
|
|
|
|
dataSource = null;
|
|
|
|
|
|
#region 查询sql
|
|
sqltxt = @"if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#TEMP1') and type='U')
|
|
DROP TABLE #TEMP1
|
|
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tempopname') and type='U')
|
|
DROP TABLE #tempopname
|
|
if exists (select * from tempdb.dbo.sysobjects where id = object_id(N'tempdb..##tempmain') and type='U')
|
|
DROP TABLE ##tempmain
|
|
|
|
|
|
select a.lotno,opcode,'工序'+CONVERT(NVARCHAR(20),opseq) AS 工序,opseq INTO #TEMP1 from (select a.lotno,a.OPCODE+':'+b.OPNAME as opcode,ROW_NUMBER() OVER( PARTITION BY a.LOTNO ORDER BY a.LOTNO,OPSEQ) AS opseq from ICSITEMROUTE2OPLot a
|
|
left join ICSOP b on b.OPCODE=a.OPCODE
|
|
inner join ICSITEMLot c on c.lotno=a.LotNo
|
|
inner join icsmo d on d.mocode=c.transno and d.moseq=c.transline
|
|
where d.mostatus<>'关单' and {0}
|
|
)a
|
|
if @@ROWCOUNT=0
|
|
raiserror('该工单行未生成条码或已关闭!',16,1)
|
|
|
|
select distinct 工序,opseq into #tempopname from #TEMP1
|
|
order by opseq
|
|
|
|
declare @sqlopname nvarchar(100)=''
|
|
select @sqlopname= STUFF((select ','+工序 from #tempopname
|
|
FOR XML PATH('')),1,1,'')
|
|
|
|
|
|
declare @sql nvarchar(max)='select * into ##tempmain from (select a.MOCODE as 工单号,a.MOSEQ as 工单行号,a.MOPLANQTY as 工单行数量,a.MOPLANSTARTDATE as 计划开工日期,a.MOPLANENDDATE as 计划完工日期,b.LotNO as 产品跟踪码,convert(decimal(18,2),b.LOTQTY) as 跟踪单数量 ,a.ITEMCODE as 物料编码,c.invname as 物料名称,A.ORDERNO AS 项目号,d.opcode,d.工序,E.工序数,A.eattribute4 AS 生产部门,
|
|
CASE WHEN h.ISCOM=1 THEN h.MTIME WHEN h.ISCOM=0 THEN null END AS 完工日期,
|
|
CASE WHEN ISNULL(B.ISCOM,'''')=''1'' THEN ''是'' else ''否'' end as 是否入库,b.storageMUser as 入库人,B.STORAGEDATE AS 入库时间
|
|
from ICSMO a
|
|
inner join ICSITEMLot b on a.MOCODE=b.TransNO and a.MOSEQ=b.TransLine
|
|
left join ICSINVENTORY c on c.INVCODE=a.ITEMCODE
|
|
LEFT JOIN ICSLOTSIMULATION h with(nolock) ON h.LOTNO=b.LOTNO
|
|
left join #TEMP1 d on d.lotno=b.LotNO
|
|
left join (
|
|
select lotno,count(*) as 工序数 from ICSITEMROUTE2OPLot group by lotno
|
|
)E ON E.LOTNO=B.LOTNO
|
|
where {1}
|
|
)a
|
|
pivot(
|
|
max(opcode)
|
|
FOR a.工序 IN ('+@sqlopname+')
|
|
)b
|
|
select * from ##tempmain
|
|
'
|
|
exec(@sql)";
|
|
string where = getWhere();
|
|
string where1 = getWhere2();
|
|
//if (!string.IsNullOrWhiteSpace(where))
|
|
//{
|
|
// sqltxt += where;
|
|
//}
|
|
//sqltxt += " ORDER BY a.MOVER,a.MOCODE,g.LOTNO";
|
|
#endregion
|
|
sqltxt = string.Format(sqltxt, where, where1);
|
|
DataTable dt = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sqltxt).Tables[0];
|
|
grdDetail.DataSource = dt;
|
|
grvDetail.BestFitColumns();
|
|
rptPage.PageSize = 100;
|
|
rptPage.PageIndex = 1;
|
|
rptPage.ReLoad();
|
|
|
|
_wait.Close();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
//MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
ICSBaseSimpleCode.AppshowMessageBox("异常:" + ex.Message);
|
|
grdDetail.DataSource = null;
|
|
_wait.Close();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region 分页
|
|
private void rptPage_PageIndexChanged(object Sender, EventArgs e)
|
|
{
|
|
|
|
DataTable data = AppConfig.GetPageData(dataSource, rptPage.PageIndex, rptPage.PageSize).Copy();
|
|
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
|
|
grdDetail.DataSource = data;
|
|
}
|
|
#endregion
|
|
|
|
#region 列表
|
|
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
|
|
{
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region 加载
|
|
private void FormICSFACTORY_Load(object sender, EventArgs e)
|
|
{
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 导出
|
|
private void btnOutPut_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
FormOutExcel foe = new FormOutExcel();
|
|
if (foe.ShowDialog() == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
string outtype = foe._OutType;
|
|
string exceltype = foe._ExcelType;
|
|
string filename = foe._FileName;
|
|
string url = foe._Url;
|
|
string sheetname = foe._SheetName;
|
|
string name = "";
|
|
if (outtype.ToLower() == "excel")
|
|
{
|
|
DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
|
|
op.SheetName = sheetname;
|
|
grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
|
|
name = url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx");
|
|
}
|
|
else
|
|
{
|
|
grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
|
|
name = url + "\\" + filename + ".pdf";
|
|
}
|
|
DialogResult result = MessageBox.Show("导出成功,是否打开此文件?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
|
|
if (result == DialogResult.OK && !string.IsNullOrWhiteSpace(name))
|
|
{
|
|
System.Diagnostics.Process.Start(name);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
private void chkMO2UserDate_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//if (chkMO2UserDate.Checked)
|
|
//{
|
|
// dtpMO2UserDateS.Enabled = true;
|
|
// dtpMO2UserDateE.Enabled = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// dtpMO2UserDateS.Enabled = false;
|
|
// dtpMO2UserDateE.Enabled = false;
|
|
//}
|
|
}
|
|
|
|
private void chkLotBeginDate_CheckedChanged(object sender, EventArgs e)
|
|
{
|
|
//if (chkLotBeginDate.Checked)
|
|
//{
|
|
// dtpLotBeginDateS.Enabled = true;
|
|
// dtpLotBeginDateE.Enabled = true;
|
|
//}
|
|
//else
|
|
//{
|
|
// dtpLotBeginDateS.Enabled = false;
|
|
// dtpLotBeginDateE.Enabled = false;
|
|
//}
|
|
}
|
|
|
|
|
|
|
|
#region 单元格背景色设置
|
|
private void grvDetail_RowCellStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowCellStyleEventArgs e)
|
|
{
|
|
|
|
#region 现逻辑
|
|
|
|
//单元格
|
|
if (e != null && e.RowHandle >= 0 && e.Column.FieldName.Contains("工序") && grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName) != null && e.Column.FieldName != "工序数")
|
|
{
|
|
string oppcode = "";
|
|
string oppcodes = "";
|
|
string opcode = grvDetail.GetRowCellValue(e.RowHandle, e.Column.FieldName).ToString();
|
|
string lotno = grvDetail.GetRowCellValue(e.RowHandle, "产品跟踪码").ToString();
|
|
string[] opArray = opcode.Split(':');
|
|
if (opArray.Length == 3)
|
|
{
|
|
oppcode = opArray[1];
|
|
}
|
|
else
|
|
{
|
|
oppcode = opArray[0];
|
|
}
|
|
|
|
DataTable dt = Color_table.AsEnumerable().Where(a => a["LOTNO"].ToString()== lotno && a["OPCODE"].ToString()== oppcode).AsDataView().ToTable();
|
|
|
|
//未派工
|
|
if ((dt.Rows.Count<=0|| string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()))&&oppcode!="")
|
|
{
|
|
e.Appearance.BackColor = Color.Blue;
|
|
}
|
|
//派工,未开工
|
|
else if (dt != null && dt.Rows.Count > 0 && string.IsNullOrEmpty(dt.Rows[0]["id"].ToString()) == false && string.IsNullOrEmpty(dt.Rows[0]["OPCODE"].ToString()))
|
|
{
|
|
e.Appearance.BackColor = Color.Aqua;
|
|
}
|
|
//完工、检验合格
|
|
else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Green;
|
|
color = Color.Green;
|
|
}
|
|
//完工、检验不合格
|
|
else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["Result"].ToString() == "不合格" && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Red;
|
|
color = Color.Red;
|
|
}
|
|
//完工、自检不合格
|
|
else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END" && !String.IsNullOrEmpty(dt.Rows[0]["ID"].ToString()))
|
|
{
|
|
e.Appearance.BackColor = Color.FromArgb(254, 177, 95);
|
|
color = Color.FromArgb(254, 177, 95);
|
|
}
|
|
//完工、未检验
|
|
else if (dt != null && dt.Rows.Count > 0 && (dt.Rows[0]["Result"].ToString() == "" || dt.Rows[0]["Result"].ToString() == "待检") && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.GreenYellow;
|
|
color = Color.GreenYellow;
|
|
}
|
|
//开工、未完工
|
|
else if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["ACTIONRESULT"].ToString() == "COLLECT_BEGIN" && dt.Rows[0]["ACTIONRESULT"].ToString() != "COLLECT_END")
|
|
{
|
|
e.Appearance.BackColor = Color.Yellow;
|
|
color = Color.Yellow;
|
|
}
|
|
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 单元格背景色设置
|
|
private void grdView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
|
|
{
|
|
|
|
|
|
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
private void rptPage_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void panel1_Paint(object sender, PaintEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void MDeptCode_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
|
|
{
|
|
ButtonEdit btn = (ButtonEdit)sender;
|
|
string sql = @"select distinct MDeptCode from icsmo";
|
|
//object obj = AppConfig.InvokeWebservice(AppConfig.BaseServiceUri, "WebBaseService", "BaseService", "GetHuaRongErpConnectString", new object[] { });
|
|
//if (obj == null)
|
|
//{
|
|
// ICSBaseSimpleCode.AppshowMessageBox(1, "ERP数据库连接取得失败!");
|
|
|
|
//}
|
|
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString.ToString(), CommandType.Text, sql).Tables[0];
|
|
FormDataRefer reForm = new FormDataRefer();
|
|
reForm.FormTitle = "生产部门";
|
|
DataTable menuData = data;
|
|
reForm.DataSource = menuData;
|
|
reForm.MSelectFlag = false;
|
|
reForm.RowIndexWidth = 35;
|
|
reForm.FormWidth = 500;
|
|
reForm.FormHeight = 500;
|
|
//reForm.FilterKey = btn.Text;
|
|
//grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, grvDetail.FocusedColumn).ToString().Trim();
|
|
if (reForm.ShowDialog() == DialogResult.OK)
|
|
{
|
|
DataTable retData = reForm.ReturnData;
|
|
string type = "";
|
|
foreach (DataRow dr in retData.Rows)
|
|
{
|
|
MDeptCode.Text = dr["MDeptCode"].ToString();
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
private void simpleButton1_Click(object sender, EventArgs e)
|
|
{
|
|
FormOutExcel foe = new FormOutExcel();
|
|
if (foe.ShowDialog() == DialogResult.OK)
|
|
{
|
|
try
|
|
{
|
|
string outtype = foe._OutType;
|
|
string exceltype = foe._ExcelType;
|
|
string filename = foe._FileName;
|
|
string url = foe._Url;
|
|
string sheetname = foe._SheetName;
|
|
if (outtype.ToLower() == "excel")
|
|
{
|
|
DevExpress.XtraPrinting.XlsExportOptions op = new DevExpress.XtraPrinting.XlsExportOptions();
|
|
op.SheetName = sheetname;
|
|
grdDetail.MainView.ExportToXls((url + "\\" + filename + (exceltype == "2003" ? ".xls" : ".xlsx")), op);
|
|
}
|
|
else
|
|
{
|
|
grdDetail.MainView.ExportToPdf(url + "\\" + filename + ".pdf");
|
|
}
|
|
MessageBox.Show("导出成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|