|
|
@@ -4,6 +4,7 @@ using System.ComponentModel;
|
|
|
using System.Data;
|
|
|
using System.Drawing;
|
|
|
using System.Linq;
|
|
|
+using System.Runtime.InteropServices;
|
|
|
using System.Text;
|
|
|
using System.Windows.Forms;
|
|
|
using UAS_MES.DataOperate;
|
|
|
@@ -14,6 +15,23 @@ namespace UAS_MES.Make
|
|
|
{
|
|
|
public partial class Make_NewMatainInf : Form
|
|
|
{
|
|
|
+ //所有用到了headBar的部分都需要这段代码
|
|
|
+ [DllImport("user32.dll")]
|
|
|
+ public static extern bool ReleaseCapture();
|
|
|
+
|
|
|
+ [DllImport("user32.dll")]
|
|
|
+ public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
|
|
|
+
|
|
|
+ [DllImport("user32.dll", EntryPoint = "GetWindowLong", CharSet = CharSet.Auto)]
|
|
|
+ public static extern int GetWindowLong(HandleRef hWnd, int nIndex);
|
|
|
+
|
|
|
+ [DllImport("user32.dll", EntryPoint = "SetWindowLong", CharSet = CharSet.Auto)]
|
|
|
+ public static extern IntPtr SetWindowLong(HandleRef hWnd, int nIndex, int dwNewLong);
|
|
|
+
|
|
|
+ public const int WM_SYSCOMMAND = 0x0112;
|
|
|
+ public const int SC_MOVE = 0xF010;
|
|
|
+ public const int HTCAPTION = 0x0002;
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 序列号
|
|
|
/// </summary>
|
|
|
@@ -125,12 +143,12 @@ namespace UAS_MES.Make
|
|
|
return CheckedNum;
|
|
|
}
|
|
|
|
|
|
- private string GetListViewSelectedItemText(ListView lsv)
|
|
|
+ private string GetListViewSelectedItemText(ListView lsv, int ItemIndex)
|
|
|
{
|
|
|
for (int i = lsv.Items.Count - 1; i >= 0; i--)
|
|
|
{
|
|
|
if (lsv.Items[i].Selected)
|
|
|
- return lsv.Items[i].SubItems[0].Text;
|
|
|
+ return lsv.Items[i].SubItems[ItemIndex].Text;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
@@ -159,23 +177,29 @@ namespace UAS_MES.Make
|
|
|
if (ErrorMessage == "")
|
|
|
{
|
|
|
ErrorMessage = "";
|
|
|
- string mbccomponent = GetListViewSelectedItemText(mbc_component_lsv);
|
|
|
- string nrgcode = GetListViewSelectedItemText(nrg_name_lsv);
|
|
|
- string nrcode = GetListViewSelectedItemText(nr_name_lsv);
|
|
|
- string mbrdutycode = GetListViewSelectedItemText(mbr_dutycode_lsv);
|
|
|
- string mbrsolutioncode = GetListViewSelectedItemText(mbr_solutioncode_lsv);
|
|
|
+ string mbccomponent = GetListViewSelectedItemText(mbc_component_lsv, 0);
|
|
|
+ string nrgcode = GetListViewSelectedItemText(nrg_name_lsv, 0);
|
|
|
+ string nrcode = GetListViewSelectedItemText(nr_name_lsv, 0);
|
|
|
+ string nrname = GetListViewSelectedItemText(nr_name_lsv, 1);
|
|
|
+ string mbrdutycode = GetListViewSelectedItemText(mbr_dutycode_lsv, 0);
|
|
|
+ string mbrsolutioncode = GetListViewSelectedItemText(mbr_solutioncode_lsv, 0);
|
|
|
dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + sncode + "' and ms_status=3", "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
string macode = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
string mbr_id = dh.GetSEQ("makebadreason_seq");
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
|
|
|
- sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
|
|
|
- sql.Append("mbr_inman) select '" + mbid + "','" + mbr_id + "','" + nrcode + "',");
|
|
|
- sql.Append("'" + mbrsolutioncode + "','" + mbrdutycode + "','" + nrgcode + "','" + bccode + "',");
|
|
|
- sql.Append("'" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "' from dual");
|
|
|
- dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
+ if (!dh.CheckExist("makebadreason", "mbr_badcode='" + bccode + "' and mbr_sncode='" + sncode + "' and mbr_brcode='" + nrcode + "'"))
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
|
|
|
+ sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
|
|
|
+ sql.Append("mbr_inman) select '" + mbid + "','" + mbr_id + "','" + nrcode + "',");
|
|
|
+ sql.Append("'" + mbrsolutioncode + "','" + mbrdutycode + "','" + nrgcode + "','" + bccode + "',");
|
|
|
+ sql.Append("'" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "' from dual");
|
|
|
+ dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
+ MessageBox.Show("不良原因保存成功");
|
|
|
+ }
|
|
|
+ else MessageBox.Show("不良代码【" + bc_name.Text + "】已存在不良原因【" + nrname+"】");
|
|
|
if (mbccomponent != "" || mbccomponent != null)
|
|
|
{
|
|
|
if (!dh.CheckExist("makebadrscom", "mbc_sncode='" + sncode + "' and mbc_component='" + mbccomponent + "'"))
|
|
|
@@ -187,18 +211,15 @@ namespace UAS_MES.Make
|
|
|
sql.Append("'" + bccode + "','" + nrcode + "','" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "')");
|
|
|
dh.ExecuteSql(sql.GetString(), "insert");
|
|
|
}
|
|
|
- else ErrorMessage += "序列号" + sncode + "已存在不良组件" + mbccomponent;
|
|
|
+ else ErrorMessage += "序列号【" + sncode + "】已存在不良组件【" + mbccomponent+"】";
|
|
|
}
|
|
|
if (ErrorMessage != "")
|
|
|
MessageBox.Show(ErrorMessage);
|
|
|
- else
|
|
|
- Close();
|
|
|
+ Close();
|
|
|
}
|
|
|
- else
|
|
|
- MessageBox.Show("序列号错误,不存在或者不处于维修状态");
|
|
|
+ else MessageBox.Show("序列号错误,不存在或者不处于维修状态");
|
|
|
}
|
|
|
- else
|
|
|
- MessageBox.Show(ErrorMessage + "未勾选");
|
|
|
+ else MessageBox.Show(ErrorMessage + "未勾选");
|
|
|
}
|
|
|
|
|
|
private void ListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
|
|
|
@@ -224,5 +245,11 @@ namespace UAS_MES.Make
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
AddDataToListView(nr_name_lsv, dt);
|
|
|
}
|
|
|
+
|
|
|
+ private void headBar1_MouseDown(object sender, MouseEventArgs e)
|
|
|
+ {
|
|
|
+ ReleaseCapture();
|
|
|
+ SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
|
|
|
+ }
|
|
|
}
|
|
|
}
|