华恒Mes鼎捷代码
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.

844 lines
31 KiB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.IO;
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;
namespace ICSSoft.Frame.APP
{
public partial class FormICSInStorage : DevExpress.XtraEditors.XtraForm
{
private string sqltxt = "";
private string sqlconn = "";
String guid = AppConfig.GetGuid();
private DataTable dataSource = null;
private DataTable dataSource1 = null;
bool b = false;
//0817新增
string mocode = "";//工单编码
string moseq = "";//生产订单行号
#region 构造函数
public FormICSInStorage()
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
{
// col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
// col.OptionsColumn.ReadOnly = true;
}
b = true;
}
public FormICSInStorage(string mocode)
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
b = false;
foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
{
// col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
// col.OptionsColumn.ReadOnly = true;
}
searchInfo(mocode);
}
#endregion
#region 构造函数
public FormICSInStorage(string mocode,string moseq)
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
b = false;
foreach (DevExpress.XtraGrid.Columns.GridColumn col in grvDetail.Columns)
{
// col.OptionsColumn.AllowEdit = col.Name == colSerial.Name;
// col.OptionsColumn.ReadOnly = true;
}
searchInfo(mocode,moseq);
}
/// <summary>
/// 传入产品追踪单号
/// </summary>
/// <param name="lotno"></param>
/// <param name="islotno"></param>
public FormICSInStorage(List<string> lotno)
{
InitializeComponent();
this.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
this.WindowState = FormWindowState.Maximized;
b = false;
searchInform(lotno);
}
#endregion
private void searchInform(List<string> lotno)
{
try
{
this.Tag = "10.24.04";
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
string sql = @"SELECT DISTINCT
'' AS [isSelect],
e.LOTNO as LOTNO,
a.ID AS ID,
--a.ProjectCode AS ProjectCode,
a.MOCODE AS MOCODE,
a.MOTYPE AS MOTYPE,
a.MOSEQ AS MOSEQ,
b.ROUTECODE AS RouteCode,
b.ROUTETYPE AS ROUTETYPE,
a.MOPLANQTY AS MOPLANQTY,
a.MOPLANSTARTDATE AS MOPLANSTARTDATE,
a.MOPLANENDDATE AS MOPLANENDDATE,
f.INVSTD as ItemCtrTypeCode
FROM
--ICSMO2Lot e
ICSITEMLot e
INNER JOIN ICSMO2User c ON e.LOTNO = c.LOTNO
INNER JOIN ICSMO a on e.TransNO=a.MOCODE AND e.TransLine=a.MOSEQ
INNER JOIN ICSMO2ROUTE b ON a.MOCODE = b.MOCODE
INNER JOIN ICSINVENTORY f ON a.ITEMCODE = f.INVCODE
WHERE 1=1 ";
for (int i = 0; i < lotno.Count; i++)
{
if (i == 0)
{
sql += " and e.LOTNO='" + lotno[i] + "'";
}
else
{
sql += " or e.LOTNO='" + lotno[i] + "'";
}
}
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
btnprint.DataSource = data;
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void searchInfo(string mocode)
{
try
{
this.Tag = "10.24.04";
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
string sql = @"SELECT DISTINCT
'' AS [isSelect],
e.LOTNO as LOTNO,
a.ID AS ID,
a.ProjectCode AS ProjectCode,
a.MOCODE AS MOCODE,
a.MOTYPE AS MOTYPE,
a.MOSEQ AS MOSEQ,
b.ROUTECODE AS RouteCode,
b.ROUTETYPE AS ROUTETYPE,
a.MOPLANQTY AS MOPLANQTY,
a.MOPLANSTARTDATE AS MOPLANSTARTDATE,
a.MOPLANENDDATE AS MOPLANENDDATE,
f.ItemCtrTypeCode as ItemCtrTypeCode
FROM
ICSMO2Lot e
INNER JOIN ICSMO2User c ON e.LOTNO = c.LOTNO
INNER JOIN ICSMO a on e.MOCODE=a.MOCODE
INNER JOIN ICSMO2ROUTE b ON a.MOCODE = b.MOCODE
INNER JOIN Base_Inventory f ON a.ITEMCODE = f.ItemCode
WHERE
a.MOCODE='" + mocode + "' order by e.LOTNO asc";
sql = string.Format(sql);
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
btnprint.DataSource = data;
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void searchInfo(string mocode,string moseq)
{
try
{
this.Tag = "10.24.04";
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
string sql = @" SELECT DISTINCT
'' AS [isSelect],
f.INVCODE as INVCODE,
f.INVNAME as INVNAME,
f.INVSTD as INVSTD,
e.LOTQTY as QTY,
f.INVUOM as INVUOM,
a.MOCODE AS MOCODE,
a.MOSEQ as MOSEQ,
a.MOVER AS MOVER,
e.MUSERName as MUSER,
e.MTIME as MTIME,
CAST(CASE WHEN i.LotNO IS NOT NULL THEN '1' ELSE '0' END AS bit) AS ISPUT,
e.LOTNO as LOTNO,
cast(e.EATTRIBUTE3 as decimal(18,2)) *cast(e.LOTQTY as decimal(18,2)) as AuxiliaryQTY,
f.INVEXPORTIMPORT as AuxiliaryUOM
FROM
ICSITEMLot e
INNER JOIN ICSMO a on e.TransNO=a.MOCODE AND e.TransLine=a.MOSEQ
INNER JOIN ICSINVENTORY f ON a.ITEMCODE = f.INVCODE
LEFT JOIN ICSWareHouseLotInfo i ON e.LOTNO=i.LotNO
WHERE 1=1 AND e.TYPE='工单'
AND MOCODE='" + mocode + "' AND MOSEQ='" + moseq + "' order by e.LOTNO asc";
sql = string.Format(sql);
DataTable data = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
btnprint.DataSource = data;
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
#region 操作权限
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);
foreach (Control ctr in panelControl3.Controls)
{
if (ctr.Name == btnFilter.Name || ctr.Name == btnConfig.Name ||
ctr.Name == btnSelectAll.Name || ctr.Name == btnCancelAll.Name ||
ctr.Name == btnOutPut.Name || ctr.Name == txtTarckList.Name||
ctr.Name == btnRefresh.Name || ctr.Name == btnExit.Name || ctr.Name == MOTitle.Name || ctr.Name == btnClose.Name || ctr.Name == btnrkadd.Name || ctr.Name == btndelete.Name|| ctr.Name == btnprint.Name)
continue;
DataRow dr = rData.NewRow();
dr["BtnName"] = ctr.Name;
dr["ActionName"] = ctr.Text;
rData.Rows.Add(dr);
}
rData.AcceptChanges();
return rData;
}
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 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 列表
private void grvDetail_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
{
if (e.Info.IsRowIndicator && e.RowHandle >= 0)
e.Info.DisplayText = (e.RowHandle + 1).ToString();
}
#endregion
#region 过滤
private string tempTableName = "";
private void btnFilter_Click(object sender, EventArgs e)
{
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name));
filter.OldTempTableName = tempTableName;
if (filter.ShowDialog() == DialogResult.OK)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
try
{
_wait.Show();
tempTableName = filter.NewTempTableName;
sqltxt = filter.SqlText;
sqlconn = filter.FilterConnectString;
dataSource = filter.FilterData.Tables[0];
btnprint.DataSource = dataSource;
grvDetail.BestFitColumns();
rptPage.RecordNum = dataSource.Rows.Count;
rptPage.PageSize = 500;
rptPage.PageIndex = 1;
rptPage.ReLoad();
string sql = @"select a.rkcode,mocode,moseq,a.lotno,a.invcode,b.invname,b.invstd,b.invuom,d.lotqty,a.muser,a.mtime,'' as isselect from icsinstoragedetail a
left join ICSINVENTORY b on b.INVCODE = a.invcode
left join ICSITEMLot d on d.LotNO = a.lotno order by mtime desc";
dataSource1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
gridControl1.DataSource = dataSource1;
gridView1.BestFitColumns();
rptPage1.RecordNum = dataSource1.Rows.Count;
rptPage1.PageSize = 500;
rptPage1.PageIndex = 1;
rptPage1.ReLoad();
_wait.Close();
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
_wait.Close();
}
}
}
#endregion
#region 绑定数据源
private void btnConfig_Click(object sender, EventArgs e)
{
if (AppConfig.UserCode.ToLower() != "demo")
{
ICSBaseSimpleCode.AppshowMessageBox("您没有权限设置数据源,请联系软件提供商!");
return;
}
FormDataSource fdata = new FormDataSource(AppConfig.GetMenuId(this.Tag.ToString()), btnConfig.Name);
fdata.ShowDialog();
}
#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);
btnprint.DataSource = data;
}
#endregion
#region 过滤方法
private void FormContainerManager_FormClosing(object sender, FormClosingEventArgs e)
{
AppConfig.DropTemTable(tempTableName);
}
#endregion
#region 全选
private void btnSelectAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
for (int i = 0; i < grvDetail.RowCount; i++)
{
grvDetail.SetRowCellValue(i, colisSelect, "Y");
}
}
#endregion
#region 全消
private void btnCancelAll_Click(object sender, EventArgs e)
{
grvDetail.PostEditor();
this.Validate();
for (int i = 0; i < grvDetail.RowCount; i++)
{
grvDetail.SetRowCellValue(i, colisSelect, "");
}
}
#endregion
#region 双击
private void grvDetail_DoubleClick(object sender, EventArgs e)
{
if (grvDetail.FocusedRowHandle < 0)
{
return;
}
if (grvDetail.FocusedColumn == colisSelect)
{
if (grvDetail.GetRowCellValue(grvDetail.FocusedRowHandle, colisSelect).ToString() == "")
{
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "Y");
}
else
{
grvDetail.SetRowCellValue(grvDetail.FocusedRowHandle, colisSelect, "");
}
}
}
#endregion
#region 导出
private void btnOutPut_Click(object sender, EventArgs e)
{
try
{
FormOutExcel foe = new FormOutExcel(this.Tag.ToString(), btnprint);
foe.ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
//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);
// }
//}
}
#endregion
#region 刷新
private void btnRefresh_Click(object sender, EventArgs e)
{
DevExpress.Utils.WaitDialogForm _wait = new DevExpress.Utils.WaitDialogForm("正在查找...请稍等...");
try
{
_wait.Show();
FormFilter filter = new FormFilter(AppConfig.GetSourceId(this.Tag.ToString(), btnConfig.Name), false);
filter.OldTempTableName = tempTableName;
//tempTableName = filter.NewTempTableName;
//DataTable data = DBHelper.ExecuteDataset(AppConfig.FrameConnectString, CommandType.Text, "select * from " + tempTableName).Tables[0];
dataSource = DBHelper.ExecuteDataset(sqlconn, CommandType.Text, sqltxt).Tables[0];
btnprint.DataSource = dataSource;
grvDetail.BestFitColumns();
rptPage.RecordNum = dataSource.Rows.Count;
rptPage.PageIndex = 1;
rptPage.ReLoad();
string sql = @"select a.rkcode,mocode,moseq,a.lotno,a.invcode,b.invname,b.invstd,b.invuom,d.lotqty,a.muser,a.mtime,'' as isselect,c.InstorageType from icsinstoragedetail a
left join ICSINVENTORY b on b.INVCODE = a.invcode
left join ICSITEMLot d on d.LotNO = a.lotno
left join ICSInStorage c on c.RKCode=a.RKCode
order by mtime desc
";
dataSource1 = DBHelper.ExecuteDataset(AppConfig.AppConnectString, CommandType.Text, sql).Tables[0];
gridControl1.DataSource = dataSource1;
gridView1.BestFitColumns();
rptPage1.RecordNum = dataSource1.Rows.Count;
rptPage1.PageSize = 500;
rptPage1.PageIndex = 1;
rptPage1.ReLoad();
_wait.Close();
}
catch (Exception ex)
{
MessageBox.Show("异常:" + ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error);
_wait.Close();
}
}
#endregion
private void ICSItemLot_FormClosing(object sender, FormClosingEventArgs e)
{
AppConfig.DropTemTable(tempTableName);
}
private void FormICSMO_Load(object sender, EventArgs e)
{
if (b == true)
{
btnFilter_Click(sender, e);
}
}
#region 跟踪单打印
private void txtTarckList_Click(object sender, EventArgs e)
{
SimpleButton btntemp = (SimpleButton)sender;
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
{
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
return;
}
if (grvDetail.FocusedRowHandle < 0)
{
return;
}
try
{
List<PrintPara> barCodeList = new List<PrintPara>();
List<ICSITEMLot> InfoList = new List<ICSITEMLot>();
for (int i = 0; i < grvDetail.RowCount; i++)
{
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
string barCode = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
PrintPara printInfo = new PrintPara();
printInfo.PrintKey = "LOTNO";
printInfo.PrintValues = new object[] { barCode };
barCodeList.Add(printInfo);
ICSITEMLot Info = new ICSITEMLot();
Info.LotNO = grvDetail.GetRowCellValue(i, colLOTNO).ToString();
//Info.PrintTimes = Convert.ToInt32(grvDetail.GetRowCellValue(i, colPrintTimes).ToString()) + 1;
Info.lastPrintUSERID = AppConfig.UserId;
Info.lastPrintTime = AppConfig.GetSeverDateTime("yyyy-MM-dd hh:mm:ss");
Info.WorkPoint = AppConfig.WorkPointCode;
InfoList.Add(Info);
}
}
if (barCodeList.Count == 0)
{
ICSBaseSimpleCode.AppshowMessageBox("没有选择数据");
return;
}
FormPrintDialog printDialog = new FormPrintDialog("007", "ICSProduct", barCodeList, false, null);
printDialog.ShowDialog();
//更新打印信息
ICSRdrecord2LOTBLL.updatePrint(InfoList, AppConfig.AppConnectString);
// for (int i = 0; i < grvDetail.RowCount; i++)
// {
// string sql = "";
// if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
// {
// sql = @"Insert into WM_BarCodePrintLog
// Values
// (NEWID(),'{0}','0001','{1}','{2}',GetDate(),null,null)";
// sql = string.Format(sql, grvDetail.GetRowCellValue(i, colLOTNO).ToString(), AppConfig.UserCode
// , AppConfig.UserName);
// DBHelper.ExecuteNonQuery(AppConfig.AppConnectString, CommandType.Text, sql);
// }
// }
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
#endregion
private void tableLayoutPanel1_Paint(object sender, PaintEventArgs e)
{
}
private void rptPage1_PageIndexChanged(object Sender, EventArgs e)
{
DataTable data = AppConfig.GetPageData(dataSource1, rptPage.PageIndex, rptPage.PageSize).Copy();
//DataTable data = AppConfig.GetPageDataByDb(tempTableName, "pagerowindex", rptPage.PageSize, rptPage.PageIndex, dataSource.Rows.Count);
gridControl1.DataSource = data;
}
private void btnrkadd_Click(object sender, EventArgs e)
{
SimpleButton btntemp = (SimpleButton)sender;
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
{
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
return;
}
int count = 0;
for (int i = 0; i < grvDetail.RowCount; i++) {
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y")
{
count++;
}
}
if (count <= 0) {
ICSBaseSimpleCode.AppshowMessageBox("请选择要生成入库单的条码");
return;
}
string rkcode = AppConfig.GetSerialCode(AppConfig.AppConnectString, AppConfig.WorkPointCode, "ICSInStorage", "RKCode", "CPRKD" + DateTime.Now.ToString("yyMMdd"), 4);
ICSInStorage instorage = new ICSInStorage();
instorage.id = AppConfig.GetGuid();
instorage.RKCode = rkcode;
instorage.Muser = AppConfig.UserCode;
instorage.Mtime = DateTime.Now;
List<ICSInStorageDetail> list = new List<ICSInStorageDetail>();
List<string> status = new List<string>();
for (int i = 0; i < grvDetail.RowCount; i++) {
if (grvDetail.GetRowCellValue(i, colisSelect).ToString() == "Y") {
ICSInStorageDetail detail = new ICSInStorageDetail();
detail.id = AppConfig.GetGuid();
detail.invcode = grvDetail.GetRowCellValue(i, colINVCODE).ToString();
detail.RKCode = rkcode;
detail.Lotno= grvDetail.GetRowCellValue(i, colLOTNO).ToString();
detail.Mocode = grvDetail.GetRowCellValue(i,colMOCODE).ToString();
detail.Moseq=Convert.ToInt32(grvDetail.GetRowCellValue(i, colMOSEQ));
detail.Mtime = DateTime.Now;
detail.Muser = AppConfig.UserCode;
if (!status.Contains(grvDetail.GetRowCellValue(i, Result).ToString())) {
status.Add(grvDetail.GetRowCellValue(i, Result).ToString());
}
if (status.Count > 1) {
ICSBaseSimpleCode.AppshowMessageBox("只能选择相同状态的条码生成入库单!");
return;
}
list.Add(detail);
}
}
instorage.InstorageType = status[0];
try
{
ICSInstorageBLL.Insert(instorage, list, AppConfig.AppConnectString);
ICSBaseSimpleCode.AppshowMessageBox("生成成功!");
btnRefresh_Click(null, null);
}
catch (Exception ex) {
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
private void simpleButton1_Click(object sender, EventArgs e)
{
SimpleButton btntemp = (SimpleButton)sender;
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
{
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
return;
}
int count = 0;
for (int i = 0; i < gridView1.RowCount; i++)
{
if (gridView1.GetRowCellValue(i, select).ToString() == "Y")
{
count++;
}
}
if (count <= 0)
{
ICSBaseSimpleCode.AppshowMessageBox("请选择要删除入库单!");
return;
}
List<string> rkcode1 = new List<string>();
for (int i = 0; i < gridView1.RowCount; i++)
{
if (gridView1.GetRowCellValue(i, select).ToString() == "Y")
{
if (rkcode1.Contains(gridView1.GetRowCellValue(i, rkcode).ToString())) {
continue;
}
rkcode1.Add(gridView1.GetRowCellValue(i, rkcode).ToString());
}
}
try {
ICSInstorageBLL.Delete(rkcode1, AppConfig.AppConnectString);
ICSBaseSimpleCode.AppshowMessageBox("删除成功!");
btnRefresh_Click(null, null);
}
catch (Exception ex) {
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
private void gridView1_DoubleClick(object sender, EventArgs e)
{
if (gridView1.FocusedRowHandle < 0)
{
return;
}
if (gridView1.FocusedColumn == select)
{
if (gridView1.GetRowCellValue(gridView1.FocusedRowHandle, select).ToString() == "")
{
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, select, "Y");
}
else
{
gridView1.SetRowCellValue(gridView1.FocusedRowHandle, select, "");
}
}
}
private void simpleButton2_Click(object sender, EventArgs e)
{
try
{
SimpleButton btntemp = (SimpleButton)sender;
if (AppConfig.GetUserExcuteRight(this.Tag.ToString(), btntemp.Name) == false)
{
ICSBaseSimpleCode.AppshowMessageBox("对不起您没有:" + btntemp.Text + "权限,请联系系统管理员!");
return;
}
string para1 = "1 and a.rkcode in(";
List<string> list = new List<string>();
for (int i = 0; i < gridView1.RowCount; i++)
{
if (gridView1.GetRowCellValue(i, select).ToString() == "Y")
{
if (list.Contains(gridView1.GetRowCellValue(i, rkcode).ToString())){
continue;
}
else {
list.Add(gridView1.GetRowCellValue(i, rkcode).ToString());
para1 += "'"+ gridView1.GetRowCellValue(i, rkcode).ToString()+"',";
}
}
}
if (para1 == "1 and a.rkcode in(")
{
ICSBaseSimpleCode.AppshowMessageBox("请选择要打印的数据!");
return;
}
para1 = para1.TrimEnd(',');
para1 += ")";
List<PrintPara> parasList = new List<PrintPara>();
PrintPara para = new PrintPara();
para.PrintKey = "1=1";
para.PrintValues = new object[] { para1 };
parasList.Add(para);
FormPrintDialog f = new FormPrintDialog("098", this.Text, parasList, false, null);
f.ShowDialog();
}
catch (Exception ex)
{
ICSBaseSimpleCode.AppshowMessageBox(ex.Message);
}
}
}
}