using System;
|
using System.Collections.Generic;
|
using System.ComponentModel;
|
using System.Data;
|
using System.Drawing;
|
using System.Text;
|
using System.Threading;
|
using System.Windows.Forms;
|
using gregn6Lib;
|
using Pub_Class;
|
|
namespace SCM
|
{
|
public partial class Sc_PackUnionBillList : Form
|
{
|
public Sc_PackUnionBillList()
|
{
|
InitializeComponent();
|
}
|
public string ViewName = "h_v_ProductionLinePackagingList";
|
public string ModCaption = "生产包装单列表";
|
public const string ModRightName = "Sc_PackUnionBillList";
|
public string HSourceBillType = "";
|
SCM.WMSWeb.WebService1 oWeb = new SCM.WMSWeb.WebService1();
|
|
private void initGrid()
|
{
|
ClsPub1.initGridList(grdMain, this.Name);
|
grdMain.RowTemplate.Height = 60;//行高
|
grdMain.ColumnHeadersHeight = 60;//设置表头行高
|
grdMain.RowHeadersWidth = 260;
|
grdMain.RowsDefaultCellStyle.Font = new Font("宋体", 22);
|
grdMain.ReadOnly = true;
|
}
|
|
private void timer1_Tick(object sender, EventArgs e)
|
{
|
timer1.Enabled = false;
|
initGrid();
|
dtpHBDate.Value = DBUtility.ClsPub.isDate(DateTime.Now.Date.ToShortDateString());
|
dtpHEDate.Value = DBUtility.ClsPub.isDate(DateTime.Now.AddDays(1).ToShortDateString());
|
Display();
|
}
|
|
private void Sc_PackUnionBillList_Load(object sender, EventArgs e)
|
{
|
//设置动态URL
|
oWeb.Url = SCM.ClsPub1.WEBSURL;
|
//
|
//frmCondition = new frmBillQueryCondition_Base();
|
this.Text = ModCaption;
|
//lblCaption.Text = ModCaption;
|
//oSumGrid.ogrdMain = grdMain; //初始化 new
|
//oSumGrid.oGridsum = grdSum;
|
initGrid();
|
|
dtpHBDate.Value = DBUtility.ClsPub.isDate(DateTime.Now.Date.ToShortDateString());
|
dtpHEDate.Value = DBUtility.ClsPub.isDate(DateTime.Now.AddDays(1).ToShortDateString());
|
}
|
|
|
private void timer2_Tick(object sender, EventArgs e)
|
{
|
timer2.Enabled = false;
|
//cmbHSourceBillType.Text = HSourceBillType;
|
//txtHSourceBillNo.Focus();
|
//txtHSourceBillNo.SelectAll();
|
}
|
|
private void grdMain_Paint(object sender, PaintEventArgs e)
|
{
|
GraphicsGrid();
|
}
|
|
private void GraphicsGrid()
|
{
|
//画底线
|
DBUtility.Xt_BaseBillFun.GraphicsGrid(grdMain);
|
//画横线
|
//DBUtility.Xt_BaseBillFun.GraphicsRowGrid(grdMain, iTopRow, iTopRow + 50, Fun_GetCol("hmainid"));
|
}
|
|
private Int32 Fun_GetCol(string sCol)
|
{
|
return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
|
}
|
|
//保存列宽
|
private void bclk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
|
}
|
|
//默认列宽
|
private void mrlk_Click(object sender, EventArgs e)
|
{
|
DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
|
}
|
|
|
|
|
private void Display()
|
{
|
string sql = " where 1 = 1 ";
|
if (txtHSourceBillNo.Text.Trim() != "")
|
{
|
sql += " and 生产订单号 like '%" + txtHSourceBillNo.Text.Trim() + "%'";
|
}
|
if (txtHBarCode.Text.Trim() != "")
|
{
|
sql += " and 条码编号 like '%" + txtHBarCode.Text.Trim() + "%'";
|
}
|
sql += " and 制单日期 >= '" + dtpHBDate.Text.Trim() + "'";
|
sql += " and 制单日期 <= '" + dtpHEDate.Text.Trim() + "'";
|
//得到信息
|
string sql2 = "select * from " + ViewName + sql;/*+" order by 唯一条码 desc";*/
|
DataSet DS = oWeb.getDataSetBySQL(sql2, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS==null || DS.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("没有找到相关源单信息!" + DBUtility.ClsPub.sExeReturnInfo);
|
return;
|
}
|
grdMain.DataSource = DS.Tables[0].DefaultView;
|
|
|
DBUtility.Xt_BaseBillFun.GetGrid(grdMain, this.Name);
|
int FrCol =0;
|
string s = "是";
|
ClsPub1.DisplayGrid(grdMain, this.Name, s, FrCol);
|
}
|
|
|
|
|
|
//双击列表
|
private void grdMain_DoubleClick(object sender, EventArgs e)
|
{
|
|
}
|
|
|
private void txtHSourceBillNo_TextChanged(object sender, EventArgs e)
|
{
|
|
}
|
|
private void Tool_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
{
|
|
}
|
|
private void btnOK_Click(object sender, EventArgs e)
|
{
|
Display();
|
}
|
|
private void btnTC_Click(object sender, EventArgs e)
|
{
|
this.Close();
|
}
|
|
private void cmbHSourceBillType_SelectedIndexChanged(object sender, EventArgs e)
|
{
|
|
}
|
|
//删除按钮
|
private void button1_Click(object sender, EventArgs e)
|
{
|
Sub_DeleteBill();
|
}
|
|
//删除
|
private void Sub_DeleteBill()
|
{
|
|
try
|
{
|
if (AllowRow())
|
{
|
if (MessageBox.Show("确定要删除当前项目?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
|
{
|
//得到HInterID
|
long sHInterID;
|
sHInterID = DBUtility.ClsPub.isLong(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("HInterID")].Value);
|
oWeb.getRunProc("Delete from Sc_PackUnionBillSub where HInterID=" + sHInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oWeb.getRunProc("Delete from Sc_PackUnionBillMain where HInterID=" + sHInterID, ref DBUtility.ClsPub.sExeReturnInfo);
|
oWeb.getRunProc("insert into System_log values(GETDATE(),'" + DBUtility.ClsPub.CurUserName + "','" + DBUtility.ClsPub.CurUserName + "','删除单据:" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("生产订单号")].Value) + "' ,'生产包装单列表','','删除')", ref DBUtility.ClsPub.sExeReturnInfo);
|
MessageBox.Show("单据号:" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("生产订单号")].Value) + " 删除成功!", "提示");
|
}
|
}
|
Display();
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("单据号:" + DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("生产订单号")].Value) + " 删除失败!"+e.ToString(), "提示");
|
}
|
}
|
|
//选中行是否正常
|
private bool AllowRow()
|
{
|
if (grdMain.CurrentRow == null)
|
{
|
return false;
|
}
|
if (grdMain.CurrentRow.Index >= 0 && grdMain.CurrentRow.Index <= grdMain.RowCount - 1)
|
{
|
return true;
|
}
|
else
|
{
|
return false;
|
}
|
}
|
|
//打印
|
GridppReport Report;
|
private void btnFQBD_Click(object sender, EventArgs e)
|
{
|
string HLogoName = "";
|
string sOpenTmp="在线打包";
|
string HSourceBillNo2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("生产订单号")].Value);
|
DataSet DS;
|
DS = oWeb.getDataSetBySQL("exec h_p_FindCustTopFour '" + HSourceBillNo2 + "'", "h_p_FindCustTopFour", ref DBUtility.ClsPub.sExeReturnInfo);
|
if (DS == null || DS.Tables[0].Rows.Count == 0)
|
{
|
MessageBox.Show("获取打印模板失败!");
|
return;
|
}
|
else
|
{
|
string Cust = ClsPub.isStrNull(DS.Tables[0].Rows[0][0]);
|
HLogoName = "-" + Cust;
|
}
|
|
if (!Sub_SetReportList(sOpenTmp + HLogoName))
|
{
|
return;
|
}
|
Report.PrintPreview(false);
|
Thread.Sleep(500);
|
}
|
protected double AllQty = 0;
|
protected string str = "";
|
private bool Sub_SetReportList(string sOpenTmp)
|
{
|
//判断行数
|
for (int i = 0; i < grdMain.Rows.Count; i++)
|
{
|
grdMain.Rows[i].Cells[0].Value = "";
|
}
|
for (int i = 0; i < grdMain.SelectedRows.Count; i++)
|
{
|
grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[0].Value = "*";
|
AllQty += DBUtility.ClsPub.isDoule(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("数量")].Value);
|
//判断多行补打时包装单号是否唯一
|
string str2 = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.SelectedRows[i].Index].Cells[Fun_GetCol("包装单号")].Value);
|
if (i==0)
|
{
|
str = str2;
|
}
|
else if (i>0)
|
{
|
if (!str.Equals(str2))
|
{
|
str = "";
|
MessageBox.Show("包装单号不唯一,请重新选择!");
|
return false;
|
}
|
}
|
}
|
Report = new GridppReport();
|
Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf"); //here .
|
Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecordList);
|
Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTableList);
|
//Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
|
return true;
|
}
|
|
private void ReportBeforePostRecordList()
|
{
|
try
|
{
|
//Report.FieldByName("源单单号").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("包装单号")].Value);
|
//Report.FieldByName("制单人").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("制单人")].Value);
|
//Report.FieldByName("制单日期").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("制单日期")].Value);
|
Report.FieldByName("源单单号").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("生产订单号")].Value);
|
//Report.FieldByName("源单类型").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("源单类型")].Value);
|
Report.FieldByName("总重量").AsString = DBUtility.ClsPub.isStrNull(grdMain.Rows[grdMain.CurrentCell.RowIndex].Cells[Fun_GetCol("总重量")].Value);
|
AllQty = 0;
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表头:" + e.Message);
|
}
|
}
|
|
private void ReportFetchRecordByDataTableList()
|
{
|
try
|
{
|
DataTable ds = new DataTable();
|
SCM.Utility.FillRecordToReport(Report, grdMain, ds, Fun_GetCol("选择"));
|
}
|
catch (Exception e)
|
{
|
MessageBox.Show("打印失败!表体:" + e.Message);
|
}
|
}
|
|
private void label2_Click(object sender, EventArgs e)
|
{
|
|
}
|
|
private void button2_Click(object sender, EventArgs e)
|
{
|
//根据源单号,更新物流信息
|
oWeb.getRunProc("EXEC h_p_Sc_PackUnionBillMainForUpdate '" + DBUtility.ClsPub.isStrNull(txtHSourceBillNo.Text) + "'", ref DBUtility.ClsPub.sExeReturnInfo);
|
|
//刷新
|
Display();
|
}
|
|
private void cmdDataOut_Click(object sender, EventArgs e)
|
{
|
//DataGridViewToExcel2(grdMain, this.Text, this.Text);
|
BLL.ClsPub_BLL.DataGridViewToExcel2(grdMain, this.Text);
|
}
|
}
|
}
|