Files
lserp_cs_6.0/插件库/Lskj.MesWorkreport/FrmMesWorkreport.cs
T
cyf ab56a9bcf7 基线 SVN r240
SVN-Revision: r240
2025-02-06 06:46:06 +00:00

1347 lines
63 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Lskj.Control;
using Lskj.Model;
using Lskj.Core;
using System.Data.SqlClient;
using Lskj.Business.Impl;
using System.Threading;
using Lskj.Util;
using Lskj.Data;
using Lskj.Control.Model;
using System.IO;
namespace Lskj.MesWorkreport
{
public partial class FrmMesWorkreport : BaseForm
{
#region 私有变量
/// <summary>
/// 工单号
/// </summary>
private String gdbillid;
private DataTable dtCurrent;
private DataTable dtSelect;
private int EmployeeId;
private int jdkztig;
private int jtkckztig;
private int jtjgkztig;
private string Gatch_id;
private string Gsellorid;
private string Gproductid;
private string Gjtid;
private string Gmpsid;
private string Gddtype;
private string bz;
private string Gconame;
private string Gsellname;
private string GsellAccount;
private string Gddjqdate;
private double planamount;
private string ProductBc;
private string ProductDate;
NumericKeyboard keyBorder;
/// <summary>
/// 报工数
/// </summary>
private string allWorkReport;
/// <summary>
/// 让步放行数
/// </summary>
private string rbfxAmount;
/// <summary>
/// 报废数量
/// </summary>
private string bfAmount;
/// <summary>
/// 流转码
/// </summary>
private string LZM = string.Empty;
/// <summary>
/// 成品码
/// </summary>
private string CPM = "√";
/// <summary>
/// 覆面报工
/// </summary>
private string FMBG = string.Empty;
/// <summary>
/// 合并上次流转
/// </summary>
private string HBLZ = string.Empty;
/// <summary>
/// 是否执行打印
/// </summary>
private string IsPrint = string.Empty;
/// <summary>
/// 次标签打印
/// </summary>
private string IsSecondaryLabel = string.Empty;
/// <summary>
/// 换钢板
/// </summary>
private string HGB = string.Empty;
private string HGBvalue = "0";
/// <summary>
/// 背板
/// </summary>
private string BB = string.Empty;
private string BBvalue = "0";
/// <summary>
/// 手抬
/// </summary>
private string ST = string.Empty;
private string STvalue = "0";
/// <summary>
/// 打水
/// </summary>
private string DS = string.Empty;
private string DSvalue = "0";
/// <summary>
/// 同步对花
/// </summary>
private string TBDH = string.Empty;
private string TBDHvalue = "0";
//操作人员名称
private string scopname;
private string planListid;
//获取按钮是否点击
private bool isbtnClick;
#endregion
#region 公有变量
/// <summary>
/// 报工模型
/// </summary>
public DynamicWorkReportModel SysModel;
#endregion
public FrmMesWorkreport()
{
InitializeComponent();
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
}
/// <summary>
/// <para>说明:窗口加载</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期:2020-11-24 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
protected override void OnLoad(EventArgs e)
{
this.lbl_isPrint.Text = Util.IniHelper.Read("Lskj.MesWorkreport" + this.lbl_isPrint.Name);
planListid = SysModel.planlistid;
scopname = ERPInfo.Instance.UserName;
EmployeeId = Convert.ToInt32(SqlHelper.ExecuteDataTable(string.Format("select employeeid from P_EmployeeTab where EmployeeName='{0}'", ERPInfo.Instance.UserName)).Rows[0]["employeeid"]);
if (scopname.Substring(0, 2) == "领班")
{
MessageBox.Show("领班不能操作此功能");
return;
}
if (DBConfig.Instance.CreateConnection())
{
RefreshDataTable();
string sqlValue;
//详细信息
try
{
sqlValue = string.Format("select c.ClassName,planamount,crm_lco_buytime,isnull(LoginAccount,'') as LoginAccount,sellopname,Clientname,Mix_bak,sellid,a.orderid,a.Productid,LineNum,scjtid,mpsid,spec+'_'+model as spec from mrp_mpsPlanListTab a join p_ProductTab b on a.Productid=b.ProductId left join (select className,planlistid,sum(joinamount) as joinamount from Mrp_WorkOrderTab group by planlistid,ClassName) c on a.id=c.planlistid join (select crm_lco_buytime,crm_lco_id,c.Mix_bak from Crm_BillcoMaintab A JOIN Crm_BillcoListtab b on a.crm_mco_billdocument_id=b.crm_Lco_billdocument_id join P_BaseMixInfoTab c on a.crm_mco_inoutspecies=c.ID ) d on a.orderid=d.crm_lco_id left join P_EmployeeTab e on a.sellopname=e.employeename where a.id={0}", planListid);
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
if (dt.Rows.Count > 0)
{
this.lab_LineNum.Text = dt.Rows[0]["lineNum"] + "";
this.lab_Spec.Text = dt.Rows[0]["spec"] + "";
bz = this.lab_ProductBz.Text = dt.Rows[0]["className"] + "";
Gatch_id = dt.Rows[0]["sellid"] + "";
Gsellorid = dt.Rows[0]["orderid"] + "";
Gproductid = dt.Rows[0]["Productid"] + "";
Gjtid = dt.Rows[0]["scjtid"] + "";
Gmpsid = dt.Rows[0]["mpsid"] + "";
Gddtype = dt.Rows[0]["Mix_bak"] + "";
Gconame = dt.Rows[0]["Clientname"] + "";
Gsellname = dt.Rows[0]["sellopname"] + "";
GsellAccount = dt.Rows[0]["LoginAccount"] + "";
Gddjqdate = dt.Rows[0]["crm_lco_buytime"] + "";
planamount = Convert.ToDouble(dt.Rows[0]["planamount"]);
}
sqlValue = string.Format("select loginClass,convert(varchar(10),scdate,120) as scdate,convert(varchar(10),getdate(),120) as scdate1 from P_EmployeeTab where employeeid={0}", EmployeeId);
DataTable dt1 = SqlHelper.ExecuteDataTable(sqlValue);
if (dt1.Rows.Count > 0)
{
if (!string.IsNullOrEmpty(dt1.Rows[0]["scdate"].ToString()))
{
ProductDate = this.lab_ProductDate.Text = dt1.Rows[0]["scdate"] + "";
}
else
{
ProductDate = this.lab_ProductDate.Text = dt1.Rows[0]["scdate1"] + "";
}
ProductBc = this.lab_ProductBc.Text = dt1.Rows[0]["loginClass"] + "";
}
string tigSqlValue = string.Format(" select jdkztig,jtkckztig,jtjgkztig from Mps_MachineSetTab where id='{0}'", Gjtid);
DataTable dt2 = SqlHelper.ExecuteDataTable(tigSqlValue);
if (dt2.Rows.Count > 0)
{
jdkztig = Convert.ToInt32(dt2.Rows[0]["jdkztig"]);
jtkckztig = Convert.ToInt32(dt2.Rows[0]["jtkckztig"]);
jtjgkztig = Convert.ToInt32(dt2.Rows[0]["jtjgkztig"]);
}
if (jtjgkztig == 1)
{
sqlValue = string.Format("select * from MRP_JtJgTab where jtid='{0}' and jgwc=0 and operatorid<>'{1}' and logindate<(select top 1 logindate from MRP_JtJgTab where jtid='{0}' and jgwc=0 and operatorid='{1}' order by id desc)", Gjtid, EmployeeId);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageBox.Show("上一班还未结工完成,不能操作操作此功能");
return;
}
}
sqlValue = string.Format("select 1 from Mrp_ProductJsAffirmTab where jtid='{0}' and JsTig in (2,3) and JGTig=0", Gjtid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageBox.Show("发现有已结余材料未处理,不能操作操作此功能");
return;
}
if (DelphiHelper.Delphi_Init(new StringBuilder(DBConfig.Instance.GetDelphiConnection())) == 0)
{
MessageUtil.Show(ResourceKeys.UnConnectServer + "[By Delphi]");
return;
}
this.SetDelphiDllParams(); // 设置调用delphi参数
btn_Design.Visible = ERPInfo.Instance.UserName.Equals("管理员");
this.btnOk.Enabled = false;
this.lbl_CPBQ.Enabled = false;
LoadingScrapTeason();
LoadingHotPressingTime();
this.bfAmountEdit.TextChanged += BfAmountEdit_TextChanged;
this.bfAmountEdit.TextChanged += btnOkState;
this.all_WorkReport.TextChanged += btnOkState;
this.lbl_Rbfx.TextChanged += btnOkState;
}
catch (Exception ex)
{
//MessageBox.Show(ee.Message);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
finally
{
Lskj.Control.Model.AutoSizeChange.ControllInitializeSize(this);
}
}
}
#region 事件相关
/// <summary>
/// <para>说明:增加</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnAddClick(object sender, EventArgs e)
{
try
{
if (dtSelect != null && dtSelect.Rows.Count > 0)
{
DataRow row = dtSelect.Rows[0];
string sqlValue = string.Format("insert MRP_ClassNameTab(xz,memployeeid,ScAccount,ScOpname) select {0},{1},'{2}','{3}' ", 0, EmployeeId, row["LoginAccount"] + "", row["EmployeeName"] + "");
if (SqlHelper.ExecuteNonQuery(sqlValue) > 0)
{
RefreshDataTable();
}
}
else
{
MessageUtil.Show(string.Format("员工工号{0}不存在", this.txtLoginAccount.Text));
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:删除</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnDelClick(object sender, EventArgs e)
{
try
{
int rowHandle = this.gv_topleft.FocusedRowHandle;
DataRow dr = this.gv_topleft.GetDataRow(rowHandle);
DataRow itemRow = gv_topleft.GetFocusedDataRow();
if (itemRow["ScAccount"] + "" == "0001")
{
MessageBox.Show("当前操作用户不能删除!");
}
else
{
string sqlValue = string.Format(" delete MRP_ClassNameTab where id='{0}' ", itemRow["id"]);
if (SqlHelper.ExecuteNonQuery(sqlValue) > 0)
{
MessageBox.Show("删除成功!");
}
}
RefreshDataTable();
}
catch (Exception ex)
{
//MessageUtil.Show(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:编辑框输入事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnTextChanged(object sender, EventArgs e)
{
try
{
string sqlValue = string.Format("select LoginAccount,EmployeeName from P_EmployeeTab where LoginAccount='{0}' ", this.txtLoginAccount.Text);
this.gc_bottomleft.DataSource = dtSelect = SqlHelper.ExecuteDataTable(sqlValue);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:刷新表格数据</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void RefreshDataTable()
{
string sqlValue1 = string.Format("select id,xz,memployeeid,ScAccount,ScOpname from MRP_ClassNameTab where memployeeid ={0}", EmployeeId);
this.gc_topleft.DataSource = SqlHelper.ExecuteDataTable(sqlValue1);
}
/// <summary>
/// <para>说明:报工方式选择事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnCheckClick(object sender, EventArgs e)
{
try
{
Label lbl = sender as Label;
//FMBG = lbl_FMBG.Text = "";
//HBLZ = lbl_SCLZ.Text = "";
switch (lbl.Name)
{
case "lbl_CPM":
if (string.IsNullOrEmpty(lbl_CPM.Text) && !string.IsNullOrEmpty(this.all_WorkReport.Text))
{
CPM = lbl_CPM.Text = "√";
//LZM = lbl_LZM.Text = "";
//IsSecondaryLabel = lbl_CPBQ.Text = "";
}
else
{
MessageUtil.Show("总报工数不能为空");
CPM = lbl_CPM.Text = "";
}
break;
case "lbl_LZM":
if (string.IsNullOrEmpty(lbl_LZM.Text))
{
LZM = lbl_LZM.Text = "√";
//CPM = lbl_CPM.Text = "";
//IsSecondaryLabel = lbl_CPBQ.Text = "";
}
else
{
LZM = lbl_LZM.Text = "";
}
break;
case "lbl_FMBG":
if (string.IsNullOrEmpty(lbl_FMBG.Text))
{
FMBG = lbl_FMBG.Text = "√";
}
else
{
FMBG = lbl_FMBG.Text = "";
}
break;
case "lbl_SCLZ":
if (string.IsNullOrEmpty(lbl_SCLZ.Text))
{
HBLZ = lbl_SCLZ.Text = "√";
}
else
{
HBLZ = lbl_SCLZ.Text = "";
}
break;
case "lbl_isPrint":
if (string.IsNullOrEmpty(lbl_isPrint.Text))
{
IsPrint = lbl_isPrint.Text = "√";
}
else
{
IsPrint = lbl_isPrint.Text = "";
}
Util.IniHelper.Write("Lskj.MesWorkreport" + this.lbl_isPrint.Name, this.lbl_isPrint.Text);
break;
case "lbl_CPBQ":
if (string.IsNullOrEmpty(lbl_CPBQ.Text) && !string.IsNullOrEmpty(this.bfAmountEdit.Text) && !string.IsNullOrEmpty(this.cb_ScrapReason.Text))
{
IsSecondaryLabel = lbl_CPBQ.Text = "√";
//LZM = lbl_LZM.Text = "";
//CPM = lbl_CPM.Text = "";
}
else
{
MessageUtil.Show("报废数量或报废原因不能为空");
IsSecondaryLabel = lbl_CPBQ.Text = "";
}
break;
case "lbl_hgb_tig":
if (string.IsNullOrEmpty(lbl_hgb_tig.Text))
{
HGB = lbl_hgb_tig.Text = "√";
HGBvalue = "1";
}
else
{
HGB = lbl_hgb_tig.Text = "";
HGBvalue = "0";
}
break;
case "lbl_bb_tig":
if (string.IsNullOrEmpty(lbl_bb_tig.Text))
{
BB = lbl_bb_tig.Text = "√";
BBvalue = "1";
}
else
{
BB = lbl_bb_tig.Text = "";
BBvalue = "0";
}
break;
case "lbl_st_tig":
if (string.IsNullOrEmpty(lbl_st_tig.Text))
{
ST = lbl_st_tig.Text = "√";
STvalue = "1";
}
else
{
ST = lbl_st_tig.Text = "";
STvalue = "0";
}
break;
case "lbl_ds_tig":
if (string.IsNullOrEmpty(lbl_ds_tig.Text))
{
DS = lbl_ds_tig.Text = "√";
DSvalue = "1";
}
else
{
DS = lbl_ds_tig.Text = "";
DSvalue = "0";
}
break;
case "lbl_tbdh_tig":
if (string.IsNullOrEmpty(lbl_tbdh_tig.Text))
{
TBDH = lbl_tbdh_tig.Text = "√";
TBDHvalue = "1";
}
else
{
TBDH = lbl_tbdh_tig.Text = "";
TBDHvalue = "0";
}
break;
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
/// <summary>
/// <para>说明:设置delphi参数</para>
/// <para>创建人:龚宇超</para>
/// <para>创建日期:2018-03-12 </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
void SetDelphiDllParams()
{
try
{
StringBuilder sb1 = new StringBuilder();
sb1.Append(ERPInfo.Instance.UserName);
StringBuilder sb2 = new StringBuilder();
sb2.Append(ERPInfo.Instance.WindowName);
StringBuilder sb3 = new StringBuilder();
sb3.Append(ERPInfo.Instance.SkinName);
//给delphi库设置参数(用户id、子系统id、操作员名称、计算机名称)
DelphiHelper.Delphi_SetParams(Convert.ToInt32(ERPInfo.Instance.UserId), Convert.ToInt32(ERPInfo.Instance.SubSysId), sb1, sb2, sb3);
}
catch (Exception ex)
{
MessageUtil.Show(ex);
LogHelper.Instance.WriteError(ex);
}
}
#region 报工按钮事件
/// <summary>
/// <para>说明:取消按钮点击事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
/// <summary>
/// <para>说明:确定报工按钮点击事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void btnOk_Click(object sender, EventArgs e)
{
try
{
//string file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WhetherOrNotToPrint.txt");
// if (File.Exists(file)) { }
//string file = null;
//File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "WhetherOrNotToPrint.txt"), file);
rbfxAmount = this.lbl_Rbfx.Text;
allWorkReport = this.all_WorkReport.Text;
bfAmount = this.bfAmountEdit.Text;
if (CPM == "" && LZM == "" && FMBG == "" && IsSecondaryLabel == "")
{
MessageUtil.Show("请选择一种报工方式!");
return;
}
else
{
this.btnOk.Enabled = false;
Thread thread = new Thread(WorkReport);
thread.Start();
}
}
catch (Exception ex)
{
//MessageUtil.Show(ex);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
#endregion
/// <summary>
/// <para>说明:执行报工操作</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
public void WorkReport()
{
if (!string.IsNullOrEmpty(this.bfAmountEdit.Text) && string.IsNullOrEmpty(this.cb_ScrapReason.Text))
{
MessageUtil.Show("报废原因不能为空!");
this.btnOk.Enabled = true;
return;
}
if (string.IsNullOrEmpty(this.bfAmountEdit.Text) && !string.IsNullOrEmpty(this.cb_ScrapReason.Text))
{
MessageUtil.Show("报废数量不能为空!");
this.btnOk.Enabled = true;
return;
}
bool isCPBQSave = false;
if (!string.IsNullOrEmpty(this.bfAmountEdit.Text) && !string.IsNullOrEmpty(this.cb_ScrapReason.Text))
{
isCPBQSave = true;
}
if (lbl_isPrint.Text != "" && lbl_CPBQ.Text.Equals("√") && !isCPBQSave)
{
MessageUtil.Show("报废数量或报废原因为空,不能打印次品码");
this.btnOk.Enabled = true;
return;
}
bool isCPBQPrint = false;
if (lbl_isPrint.Text != "" && isCPBQSave && lbl_CPBQ.Text.Equals("√"))
{
isCPBQPrint = true;
}
bool isCPMSave = false;
if (!string.IsNullOrEmpty(all_WorkReport.Text))
{
isCPMSave = true;
}
if (lbl_isPrint.Text != "" && lbl_CPM.Text.Equals("√") && !isCPMSave)
{
MessageUtil.Show("总报工数为空,不能打印成品码");
this.btnOk.Enabled = true;
return;
}
bool isCPMPrint = false;
if (isCPMSave && !string.IsNullOrEmpty(lbl_CPM.Text))
{
isCPMPrint = true;
}
string yearname, monthname, dayname, lcbillid = "", Gdbillid = "";
string CPGdbillid = "";
string stramount = "";
int dmamount = 0, fmamount = 0;
double bgamount;
string sczname = string.Empty, RbfxAmount = string.Empty, Tmqz = string.Empty;
string sqlValue = string.Empty;
if (string.IsNullOrEmpty(rbfxAmount))// 让步放行数
{
RbfxAmount = "0";
}
else
{
RbfxAmount = rbfxAmount;
}
if (string.IsNullOrEmpty(allWorkReport))// 总报工数
{
allWorkReport = "0";
}
else
{
allWorkReport = allWorkReport;
}
if (string.IsNullOrEmpty(bfAmount))// 报废数量
{
bfAmount = "0";
}
else
{
bfAmount = bfAmount;
}
if (isCPMSave)//成品码保存
{
try
{
if (CPM != "")// 成品码
{
Tmqz = "3";
stramount = "," + allWorkReport + "," + allWorkReport + ",0,0," + RbfxAmount + ", ";
}
if (LZM != "")
{
Tmqz = "L";
stramount = "," + allWorkReport + ",0," + allWorkReport + ",0," + RbfxAmount + ", ";
}
// yearname = DateTime.Now.Year.ToString().Substring(0, 2);
// monthname = DateTime.Now.Month.ToString();
// dayname = DateTime.Now.Day.ToString();
// if (monthname.Length == 1)
// {
// monthname = "0" + monthname;
// }
// if (dayname.Length == 1)
// {
// dayname = "0" + dayname;
// }
// lcbillid = Tmqz + "3" + yearname + monthname + dayname;
// sqlValue = string.Format(@"select cast(right(max(billdocument_id),4) as int)+1 as billdocument_id
//from (
//select billdocument_id from Mrp_WorkOrderTab where left(billdocument_id,8)='{0}' and CHARINDEX('_',billdocument_id)<=0
//union all
//select gdbillid from Mrp_WorkOrderDelLogTab where left(gdbillid,8)='{0}' and CHARINDEX('_',gdbillid)<=0
//) a", lcbillid);
// //if (!string.IsNullOrEmpty(bfAmount))
// //{
// // sqlValue = string.Format("select max(cast(SUBSTRING(billdocument_id, len(billdocument_id) - 7, 4) as int) + 1) as billdocument_id from(select billdocument_id from Mrp_WorkOrderTab where left(billdocument_id, 9) = '{0}' union all select gdbillid from Mrp_WorkOrderDelLogTab where left(gdbillid, 9) = '{0}') a", lcbillid);
// //}
// DataTable dDt = SqlHelper.ExecuteDataTable(sqlValue);
// //生成随机工单号
// if (string.IsNullOrEmpty(dDt.Rows[0]["billdocument_id"].ToString()))
// {
// Gdbillid = lcbillid + "0001";
// }
// else
// {
// Gdbillid = lcbillid + ("000" + SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["billdocument_id"].ToString()).Substring(("000" + SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["billdocument_id"].ToString()).Length - 4, 4);
// }
Gdbillid = SqlHelper.ExecuteScalar("exec P_create_billdocumentPr 'Mrp_WorkOrderTab',''") + "";
//判断是否有流转码,有的先合并流转码
sqlValue = string.Format("select sum(isnull(lztmamount,0)) as lztmamount from Mrp_WorkOrderTab where planlistid='{0}' and isnull(lztmamount,0)<>0", planListid);
if (!string.IsNullOrEmpty(SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["lztmamount"] + "") && HBLZ == "" && CPM != "")
{
MessageUtil.Show("已经有流转条码存在,请先合并流转条码");
this.btnOk.Enabled = true;
return;
}
if (SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["lztmamount"] + "" != "" && LZM != "")
{
int lztmamount = Convert.ToInt32(SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["lztmamount"]);
sqlValue = string.Format("select MAX(amountdwzs) amountdwzs from Crm_BillcoPackedStandardTab where Sellid='{0}' and DbType='生产'", Gsellorid);
if ((lztmamount + Convert.ToInt32(allWorkReport)) > Convert.ToInt32(SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["amountdwzs"]))
{
MessageUtil.Show("流转码的数量不符合打包要求");
this.btnOk.Enabled = true;
return;
}
}
//获取剩余覆面报工数量
sqlValue = string.Format("select sum(joinamountfm) as joinamountfm from Mrp_WorkOrderTab where planlistid='{0}' and isnull(fgdbillid,'')=''", planListid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["joinamountfm"] + "" != "")
{
fmamount = Convert.ToInt32(SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["joinamountfm"]);
}
//增加了如果有单面,流转转成品就能直接转换
if (fmamount > 0 && FMBG == "" && CPM != "" && HBLZ == "")
{
MessageUtil.Show("已经有覆面报工存在,请选择合并覆面报工");
this.btnOk.Enabled = true;
return;
}
}
catch (Exception e)
{
//MessageUtil.Show(e.Message);
string Message = ErrorMessage.PromptErrorMessage(e);
MessageUtil.Show(Message, e.Message);
this.btnOk.Enabled = true;
}
try
{
//if (string.IsNullOrEmpty(allWorkReport))
//{
// MessageUtil.Show("报工数量不能为空!");
// this.btnOk.Enabled = true;
// return;
//}
//else
//{
if (Convert.ToInt32(allWorkReport) != 0)
{
if (jdkztig == 1)
{
sqlValue = string.Format(" select * from Mrp_ProductJsAffirmTab where jtid={0} and JsTig=1 and jsWc=0", Gjtid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageUtil.Show("此机台有结料申请未确认,请仓库在手机端进行退料确认操作");
this.btnOk.Enabled = true;
return;
}
}
sqlValue = string.Format(" select top 1 modid from wms_productBarCode a join (select b.productid from mrp_mpsPlanListTab a join mps_PlanBomBaseTab b on a.id=b.planlistid where a.id='{0}' group by b.productid) b on a.objectId=b.productid where modid=11002 and Amount<0 and ISNULL(YsTig,0)=0 and wmsfttig+wmsfttigsq+dcjfttig=0 and LLType=1 and Jtid='{1}'", planListid, Gjtid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageUtil.Show("机台有材料未验收不能报工!");
this.btnOk.Enabled = true;
return;
}
if (jtkckztig == 1)
{
sqlValue = string.Format("select * from (select productid,SUM(DwAmount*'{0}') as xqamount from mps_PlanBomBaseTab where planlistid='{1}' group by productid) a left join (select productid,jyamount from wms_JtProductWjsView where jtid='{2}' ) b on a.productid=b.productid where xqamount>ISNULL(jyamount,0);", allWorkReport, planListid, Gjtid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageUtil.Show("机台所需材料库存不足,请先核对机台库存");
this.btnOk.Enabled = true;
return;
}
sqlValue = string.Format("select SbBillid from (select productid, sum(dwamount) as dwamount from mps_PlanBomBaseTabGb where planlistid='{0}' group by productid ) a left join ( select SbBillid,count(1) as jtgbamount from P_FixedAssetsMlTab a join Mps_MachineSetTab b on a.wz=b.jtbillno where zttig=1 and b.id='{1}' group by SbBillid ) b on a.productid=b.SbBillid where isnull(jtgbamount,0)=0 ;", planListid, Gjtid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count > 0)
{
MessageUtil.Show("机台钢板数量不正确,请先确定机台钢板");
this.btnOk.Enabled = true;
return;
}
}
}
//}
if (CPM + LZM != "")
{
sqlValue = string.Format("select isnull(sum(isnull(joinamount,0))+sum(isnull(joinamountdm,0)),0) as joinamount from Mrp_WorkOrderTab where planlistid='{0}' and left(billdocument_id,4)<>'SCBL'", planListid);
bgamount = Convert.ToDouble(SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["joinamount"]);
bgamount = bgamount + Convert.ToDouble(allWorkReport);
if (bgamount > planamount)
{
MessageUtil.Show("报工数量大于计划数量,不能保存");
this.btnOk.Enabled = true;
return;
}
}
if (HBLZ != "")// 合并上次流转
{
sqlValue = string.Format("select 1 from Mrp_WorkOrderTab where planlistid='{0}' and isnull(lztmamount,0)<>0 ", planListid);
if (SqlHelper.ExecuteDataTable(sqlValue).Rows.Count == 0)
{
MessageUtil.Show("未发现有流转条码存在,不能选择合并流转条码");
this.btnOk.Enabled = true;
return;
}
}
if (FMBG != "")// 覆面报工
{
if (fmamount <= 0)
{
MessageUtil.Show("未发现有单面报工存在,不能选择合并覆面报工");
this.btnOk.Enabled = true;
return;
}
}
sqlValue = string.Format("select STUFF((SELECT ','+ScOpname FROM MRP_ClassNameTab where memployeeid='{0}' FOR XML PATH('')),1,1,'') as SczName ", EmployeeId);
sczname = SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["SczName"] + "";
}
catch (Exception e)
{
//MessageUtil.Show(e.Message);
string Message = ErrorMessage.PromptErrorMessage(e);
MessageUtil.Show(Message, e.Message);
this.btnOk.Enabled = true;
}
try
{
//sqlValue = string.Format("insert Mrp_WorkOrderTab(billdocument_id,TmQz,planlistid,Sellorid,Mpsid,ScBatch_id,productid,wpid,Jtid,ClassBc,ClassName,sczname,joindate,joinamount,CpTmAmount,LzTmAmount,joinamountdm, RbfxAmount,operatorname,operatordate,DdType,PrCoName,SellorName,SellAccount,Ddbuytime) select '{0}','{1}',{2},{3},{4},'{5}','{6}',2,{7},'{8}','{9}','{10}','{11}',{12},{13},{14},{15},{16},'{17}',GETDATE(),'{18}','{19}','{20}','{21}','{22}'", Gdbillid, Tmqz, planListid, Gsellorid, Gmpsid, Gatch_id, Gproductid, Gjtid, this.lab_ProductBc.Text, this.lab_ProductBz.Text, sczname, this.lab_ProductDate.Text,
// stramount,scopname, Gddtype, Gconame, Gsellname, GsellAccount, Gddjqdate);
//报工数大于0才执行
if (Convert.ToInt32(allWorkReport) > 0)
{
string Rysj = this.HotPressingTime.EditValue + "";
sqlValue = string.Format("insert Mrp_WorkOrderTab(billdocument_id,TmQz,planlistid,Sellorid,Mpsid,ScBatch_id,productid,wpid,Jtid,ClassBc,ClassName,sczname,joindate,joinamount,CpTmAmount,LzTmAmount,joinamountdm, RbfxAmount,operatorname,operatordate,DdType,PrCoName,SellorName,SellAccount,Ddbuytime,hgb_tig,bb_tig,st_tig,ds_tig,tbdh_tig,rysj_tig) select '{0}','{1}',{2},{3},{4},'{5}','{6}',2,{7},'{8}','{9}','{10}','{11}'{12}'{13}',GETDATE(),'{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}';"
, Gdbillid, Tmqz, planListid, Gsellorid, Gmpsid, Gatch_id, Gproductid, Gjtid, ProductBc, bz, sczname, ProductDate, stramount, scopname, Gddtype, Gconame, Gsellname, GsellAccount, Gddjqdate, HGBvalue, BBvalue, STvalue, DSvalue, TBDHvalue, Rysj);
//SqlHelper.ExecuteNonQuery(sqlValue);
//hgb_tig,bb_tig,st_tig,ds_tig
//this.lbl_hgb_tig.c
}
sqlValue += string.Format("insert Mrp_DayAttendanceTab(scdate,Gdbillid,wpid,ClassName,ScName) SELECT getdate(),'{0}',2,'{1}',scopname from MRP_ClassNameTab where memployeeid='{2}';", Gdbillid, bz, EmployeeId);
SqlHelper.ExecuteNonQuery(sqlValue);
if (CPM != "" && HBLZ != "")
{
sqlValue = string.Format("update Mrp_WorkOrderTab set cptmamount=cptmamount+b.lztmamount,BBtig=-1 from Mrp_WorkOrderTab a join (select planlistid ,sum(lztmamount) as lztmamount from Mrp_WorkOrderTab where planlistid='{0}' and isnull(lztmamount,0)<>0 group by planlistid ) b on a.planlistid=b.planlistid where billdocument_id='{1}';", planListid, Gdbillid);
//SqlHelper.ExecuteNonQuery(sqlValue);
sqlValue += string.Format("update Mrp_WorkOrderTab set lztmamount=0,fgdbillid='{0}' where planlistid='{1}' and isnull(lztmamount,0)<>0;", Gdbillid, planListid);
SqlHelper.ExecuteNonQuery(sqlValue);
}
if (CPM != "" && FMBG != "")
{
sqlValue = string.Format("update Mrp_WorkOrderTab set cptmamount=cptmamount+'{0}',BBtig=-1 where billdocument_id='{1}';", fmamount, Gdbillid);
//SqlHelper.ExecuteNonQuery(sqlValue);
sqlValue += string.Format("update Mrp_WorkOrderTab set fgdbillid='{0}' where planlistid='{1}' and isnull(joinamountfm,0)<>0 and isnull(fgdbillid,'')='';", Gdbillid, planListid);
SqlHelper.ExecuteNonQuery(sqlValue);
}
sqlValue = string.Format("insert wms_BillOutExpendTab(GdBillid,jtid,productid,clplanid,sellid,planid,planlistid,scbatch_id,ysamount,amount,operatorname,operatordate) select '{0}','{1}',a.Productid,0,a.sellorid,a.Planid,a.planlistid,scrm_lco_tm,sum(joinamount*DwAmount),sum(joinamount*DwAmount),'{2}',GETDATE() from mps_PlanBomBaseTab a join Mrp_WorkOrderTab b on a.planlistid=b.planlistid where b.Billdocument_id='{0}' group by a.Productid,a.sellorid,a.Planid,a.planlistid,scrm_lco_tm", Gdbillid, Gjtid, scopname);
SqlHelper.ExecuteNonQuery(sqlValue);
sqlValue = string.Format("insert wms_BillSbExpendTab(GdBillid,jtid,Cpproductid,productid,clplanid,sellid,planid,planlistid,scbatch_id,ysamount,amount,operatorname,operatordate,ClTm)"
+ " select GdBillid,jtid,cpproductid,productid,clplanid,sellorid,planid,planlistid,scrm_lco_tm, case when strcount<dwamount then ysamount else ysamount/dwamount*(dwamount/strcount) end as ysamount,"
+ " case when strcount<dwamount then amount else amount/dwamount*(dwamount/strcount) end as amount,operatorname,operatordate,nbBill"
+ " from (select '{0}' as GdBillid,'{1}' as jtid,cpproductid,a.Productid,0 as clplanid,a.sellorid,a.Planid,a.planlistid,scrm_lco_tm,sum(joinamount*DwAmount) as ysamount,"
+ " sum(joinamount*DwAmount) as amount,sum(dwamount) as dwamount,'{2}' as operatorname,'{3}' as operatordate from mps_PlanBomBaseTabGb a "
+ " left join Mrp_WorkOrderTab b on a.planlistid=b.planlistid where b.Billdocument_id='{0}' group by cpproductid, a.Productid,a.sellorid,a.Planid,a.planlistid,scrm_lco_tm ) a"
+ " left join ( select SbBillid,nbBill,OriginBill from P_FixedAssetsMlTab a join Mps_MachineSetTab b on a.wz=b.jtBillNo where zttig=1 and b.id='{1}') b on a.productid=b.SbBillid"
+ " left join ( select SbBillid,COUNT(1) as strcount from P_FixedAssetsMlTab a join Mps_MachineSetTab b on a.wz=b.jtBillNo where zttig=1 and b.id='{1}' group by SbBillid) d on a.productid=d.SbBillid",
Gdbillid, Gjtid, scopname, ProductDate);
SqlHelper.ExecuteNonQuery(sqlValue);
//执行存储过程
string tipMsg = string.Empty;
if ((ExecPro(Gdbillid, EmployeeId, 1, 20190102, out tipMsg)) == 1)
{
this.btnOk.Visible = false;
if (lbl_isPrint.Text != "")
{
if (isCPMPrint)
{
string sql = string.Format("select * from Mrp_WorkOrderView WHERE billdocument_id='{0}'", Gdbillid);
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyPath + "Lib\\" + "P_PubPrint.lsp", "P_PubPrint.lsp", "天叶成品报工标签.rmf", sql, sql, Convert.ToInt32(3), sql);
}
}
}
else
{
MessageUtil.Show(tipMsg);
}
}
catch (Exception ex)
{
//MessageUtil.Show(ex.Message);
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
this.btnOk.Enabled = true;
}
}
if (isCPBQSave)
{
try
{
if (!string.IsNullOrEmpty(bfAmount))
{
CPGdbillid = SqlHelper.ExecuteScalar("exec P_create_billdocumentPr 'Mrp_WorkOrderTab1',''") + "";
string NTmqz = "99";
string BfReason = this.cb_ScrapReason.EditValue + "";
string Rysj = this.HotPressingTime.EditValue + "";
string Nstramount = "," + bfAmount + "," + bfAmount + "," + allWorkReport + ",0," + RbfxAmount + ", ";
string bfSqlValue = string.Format("insert Mrp_WorkOrderTab(billdocument_id,TmQz,planlistid,Sellorid,Mpsid,ScBatch_id,productid,wpid,Jtid,ClassBc,ClassName,sczname,joindate,joinamount,CpTmAmount,LzTmAmount,joinamountdm, RbfxAmount,operatorname,operatordate,DdType,PrCoName,SellorName,SellAccount,Ddbuytime,bfAmount,CpBadCauseid,hgb_tig,bb_tig,st_tig,ds_tig,tbdh_tig,rysj_tig) select '{0}','{1}',{2},{3},{4},'{5}','{6}',2,{7},'{8}','{9}','{10}','{11}'{12}'{13}',GETDATE(),'{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}';"
, CPGdbillid, NTmqz, planListid, Gsellorid, Gmpsid, Gatch_id, Gproductid, Gjtid, ProductBc, bz, sczname, ProductDate, Nstramount, scopname, Gddtype, Gconame, Gsellname, GsellAccount, Gddjqdate, bfAmount, BfReason, HGBvalue, BBvalue, STvalue, DSvalue, TBDHvalue, Rysj);
SqlHelper.ExecuteNonQuery(bfSqlValue);
//执行存储过程
string tipMsg = string.Empty;
if ((ExecPro(CPGdbillid, EmployeeId, 1, 20190102, out tipMsg)) == 1)
{
this.btnOk.Visible = false;
if (lbl_isPrint.Text != "")
{
if (isCPBQPrint)
{
//打印次品条码
string sql = string.Format("select * from Mrp_WorkOrderView WHERE billdocument_id='{0}'", CPGdbillid);
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyPath + "Lib\\" + "P_PubPrint.lsp", "P_PubPrint.lsp", "天叶成品报废报工标签.rmf", sql, sql, Convert.ToInt32(3), sql);
}
}
}
else
{
MessageUtil.Show(tipMsg);
this.btnOk.Enabled = true;
}
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
this.btnOk.Enabled = true;
}
}
this.Close();
}
/// <summary>
/// 报工存储过程
/// </summary>
/// <param name="GdBillid">传入单据号, 修改/删除,新增传入</param>
/// <param name="Operatorid">,QS=确色拉样,QSLD=确色拉大,JTLD=机台拉大</param>
/// <param name="Fbilltagid">1新增,2为修改,3为删除</param>
/// <param name="operateway">单据类型,约定 传入 p_systembilltype中billSeq值</param>
/// <param name="msg"></param>
/// <returns></returns>
public static int ExecPro(string Gdbillid, int Operatorid, int Fbilltagid, int operateway, out string tipMsg)
{
SqlParameter pMsg = new SqlParameter("@msg", SqlDbType.VarChar, 2000);
pMsg.Direction = ParameterDirection.Output;
SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4);
returnValue.Direction = ParameterDirection.ReturnValue;
SqlParameter[] param =
{
new SqlParameter("@billdocument_id",SqlDbType.VarChar,50),
new SqlParameter("@Operatorid",SqlDbType.Int),
new SqlParameter("@Fbilltagid",SqlDbType.Int),
new SqlParameter("@operateway",SqlDbType.Int),
pMsg,
returnValue
};
param[0].Value = Gdbillid;
param[1].Value = Operatorid;
param[2].Value = Fbilltagid;
param[3].Value = operateway;
BaseImpl.ExecProcedure("[p_Bill_AutoCreateBillPr]", param);
tipMsg = pMsg.Value + "";
return Convert.ToInt32(returnValue.Value.ToString());
}
/// <summary>
/// <para>说明:编辑框点击弹出数字键盘事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnMouseDown(object sender, MouseEventArgs e)
{
try
{
TextBox tBox = sender as TextBox;
int x = 0; int y = 0;
if (keyBorder != null)
{
keyBorder.Dispose();
}
keyBorder = new NumericKeyboard();
switch (tBox.Name)
{
case "all_WorkReport":
keyBorder.parentTextBox = this.all_WorkReport;
x = tBox.Location.X - 55;
y = tBox.Location.Y;
break;
case "lbl_Rbfx":
keyBorder.parentTextBox = this.lbl_Rbfx;
x = tBox.Location.X - 135;
y = tBox.Location.Y;
break;
case "bfAmountEdit":
keyBorder.parentTextBox = this.bfAmountEdit;
x = tBox.Location.X - 55;
y = tBox.Location.Y;
break;
}
keyBorder.Location = new Point(x, y);
keyBorder.OBtnClick += new EventHandler(OnBtnClick);
panelControl1.Controls.Add(keyBorder);
keyBorder.BringToFront();
keyBorder.Show();
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:数字按钮点击事件</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnBtnClick(object sender, EventArgs e)
{
try
{
Label lbl = sender as Label;
NumericKeyboard numericKeyboard = lbl.Parent as NumericKeyboard;
TextBox textBox = numericKeyboard.parentTextBox;
string strkey = lbl.Text;
if (strkey == "退格")
{
string strNew = textBox.Text;
if (strNew.Length >= 1)
{
strNew = strNew.Substring(0, strNew.Length - 1);
textBox.Text = strNew;
textBox.SelectionStart = textBox.Text.Length;
}
textBox.Focus();
}
else if (strkey == "清除")
{
textBox.Clear();
}
else
{
textBox.AppendText(strkey);
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// <para>说明:隐藏数字键盘</para>
/// <para>创建人:钱雄</para>
/// <para>创建日期: </para>
/// <para>修改人:</para>
/// <para>修改日期:</para>
/// <para>修改备注:</para>
/// <para>版本:1.0</para>
/// </summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
private void OnFormClick(object sender, EventArgs e)
{
try
{
if (keyBorder != null)
{
keyBorder.Dispose();
}
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// 管理员转设计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btn_Design_Click(object sender, EventArgs e)
{
try
{
string yearname, monthname, dayname, lcbillid = "", Gdbillid = "";
string stramount = "";
int dmamount = 0, fmamount = 0;
double bgamount;
string sczname = string.Empty, RbfxAmount = string.Empty, Tmqz = string.Empty;
string sqlValue = string.Empty;
if (CPM != "")// 成品码
{
Tmqz = "3";
stramount = "," + allWorkReport + "," + allWorkReport + ",0,0," + RbfxAmount + ", ";
}
if (LZM != "")
{
Tmqz = "L";
stramount = "," + allWorkReport + ",0," + allWorkReport + ",0," + RbfxAmount + ", ";
}
//yearname = DateTime.Now.Year.ToString().Substring(0, 2);
//monthname = DateTime.Now.Month.ToString();
//dayname = DateTime.Now.Day.ToString();
//if (monthname.Length == 1)
//{
// monthname = "0" + monthname;
//}
//if (dayname.Length == 1)
//{
// dayname = "0" + dayname;
//}
//lcbillid = Tmqz + "3" + yearname + monthname + dayname;
//sqlValue = string.Format("select cast(right(max(billdocument_id),4) as int)+1 as billdocument_id from (select billdocument_id from Mrp_WorkOrderTab where left(billdocument_id,8)='{0}' union all select gdbillid from Mrp_WorkOrderDelLogTab where left(gdbillid,8)='{0}') a", lcbillid);
//DataTable dDt = SqlHelper.ExecuteDataTable(sqlValue);
////生成随机工单号
//if (string.IsNullOrEmpty(dDt.Rows[0]["billdocument_id"].ToString()))
//{
// Gdbillid = lcbillid + "0001";
//}
//else
//{
// Gdbillid = lcbillid + ("000" + SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["billdocument_id"].ToString()).Substring(("000" + SqlHelper.ExecuteDataTable(sqlValue).Rows[0]["billdocument_id"].ToString()).Length - 4, 4);
//}
Gdbillid = SqlHelper.ExecuteScalar("exec P_create_billdocumentPr 'Mrp_WorkOrderTab',''") + "";
string sql = string.Format("select * from Mrp_WorkOrderView WHERE billdocument_id='{0}'", Gdbillid);
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyPath + "Lib\\" + "P_PubPrint.lsp", "P_PubPrint.lsp", "天叶成品报工标签.rmf", sql, sql, Convert.ToInt32(4), sql);
}
catch (Exception ex)
{
string Message = ErrorMessage.PromptErrorMessage(ex);
MessageUtil.Show(Message, ex.Message);
}
}
/// <summary>
/// 加载报废原因
/// </summary>
public void LoadingScrapTeason()
{
string sqlValue = "select id as dm,Mix_apellation as mc from P_BaseMixInfoTab where Tag='41010101'";
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
this.cb_ScrapReason.Properties.DataSource = dt;
this.cb_ScrapReason.Properties.DisplayMember = "mc";
this.cb_ScrapReason.Properties.ValueMember = "dm";
this.cb_ScrapReason.Properties.ShowHeader = false;
this.cb_ScrapReason.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;
this.cb_ScrapReason.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("mc"));
this.cb_ScrapReason.Height = this.bfAmountEdit.Height;
}
/// <summary>
/// 加载热压时间
/// </summary>
public void LoadingHotPressingTime()
{
string sqlValue = "select id as dm,Mix_apellation as mc from P_BaseMixInfoTab where Tag='4101041'";
DataTable dt = SqlHelper.ExecuteDataTable(sqlValue);
this.HotPressingTime.Properties.DataSource = dt;
this.HotPressingTime.Properties.DisplayMember = "mc";
this.HotPressingTime.Properties.ValueMember = "dm";
this.HotPressingTime.Properties.ShowHeader = false;
this.HotPressingTime.Properties.SearchMode = DevExpress.XtraEditors.Controls.SearchMode.AutoFilter;
this.HotPressingTime.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("mc"));
this.HotPressingTime.Height = this.bfAmountEdit.Height;
}
/// <summary>
/// 判断次标签是否可以勾选
/// </summary>
private void BfAmountEdit_TextChanged(object sender, EventArgs e)
{
try
{
int number = int.Parse(this.bfAmountEdit.Text + "");
if (number > 0)
{
this.lbl_CPBQ.Enabled = true;
}
else
{
this.lbl_CPBQ.Enabled = false;
this.lbl_CPBQ.Text = "";
}
}
catch
{
this.lbl_CPBQ.Enabled = false;
this.lbl_CPBQ.Text = "";
}
}
/// <summary>
/// 判断确定按钮是否可以点击
/// </summary>
public void btnOkState(object sender, EventArgs e)
{
try
{
if ((!string.IsNullOrEmpty(this.bfAmountEdit.Text) && int.Parse(this.bfAmountEdit.Text + "") > 0) || (!string.IsNullOrEmpty(this.all_WorkReport.Text) && int.Parse(this.all_WorkReport.Text + "") > 0) || (!string.IsNullOrEmpty(this.lbl_Rbfx.Text) && int.Parse(this.lbl_Rbfx.Text + "") > 0))
{
this.btnOk.Enabled = true;
}
else
{
this.btnOk.Enabled = false;
}
}
catch
{
this.btnOk.Enabled = false;
}
}
private void btn_CpDesign_Click(object sender, EventArgs e)
{
string CPGdbillid = "";
CPGdbillid = SqlHelper.ExecuteScalar("exec P_create_billdocumentPr 'Mrp_WorkOrderTab1',''") + "";
//打印次品条码
string sql = string.Format("select * from Mrp_WorkOrderView WHERE billdocument_id='{0}'", CPGdbillid);
DelphiHelper.LoadDelphiDll(PubUtil.AbsolutelyPath + "Lib\\" + "P_PubPrint.lsp", "P_PubPrint.lsp", "天叶成品报废报工标签.rmf", sql, sql, Convert.ToInt32(4), sql);
}
}
}