using System; using System.Collections.Generic; 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_NEW.DataOperate; using UAS_MES_NEW.Entity; using UAS_MES_NEW.PublicMethod; namespace UAS_MES_NEW.Make { public partial class Make_StepReportDetail : CustomControl.BaseForm.BaseForm { //所有用到了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; DataHelper dh; LogStringBuilder sql = new LogStringBuilder(); string msid; double badqty; string macode; public Make_StepReportDetail(string msid, double badqty, string macode) { dh = SystemInf.dh; InitializeComponent(); this.msid = msid; this.badqty = badqty; this.macode = macode; } private void Warehouse_ProdDetail_Load(object sender, EventArgs e) { ngsum.Text = badqty.ToString(); ma_code.Text = macode; stepcode.Text = User.CurrentStepCode; comBoxWithFocus1.Items.Add("1234"); FillDataGridView(); } private void headBar1_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); } private void BatchProductDGV_CellContentClick66(object sender, DataGridViewCellEventArgs e) { if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow") { if (e.RowIndex >= 0) { string id = BatchProductDGV.Rows[e.RowIndex].Cells["msd_id"].Value.ToString(); if (id != "0") { dh.ExecuteSql("update MES_STEPREPORTdet set msd_status =-1 where msd_id='" + id + "'", "delete"); LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工序不良报工", "删除记录" + id, "", ""); FillDataGridView(); } } } } private void FillDataGridView() { sql.Clear(); sql.Append("select msd_id,msd_msid,msd_badname,msd_qty,msd_indate,msd_status,msd_stepcode from MES_STEPREPORTdet "); sql.Append("where msd_msid = '" + msid + "' and msd_stepcode = '" + User.CurrentStepCode + "' and msd_status = 0"); DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select"); BaseUtil.FillDgvWithDataTable(BatchProductDGV, dt); } private void button1_Click(object sender, EventArgs e) { } private void BatchProductDGV_CellFormatting12(object sender, DataGridViewCellFormattingEventArgs e) { if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow") { if (BatchProductDGV.Rows[e.RowIndex].Cells["msd_id"].Value.ToString() == "0") e.Value = Properties.Resources.WhiteImage; else e.Value = Properties.Resources.bindingNavigatorDeleteItem_Image; } } //try //{ // if (comBoxWithFocus1.Text == "" || ngqty.Text == "") // { // MessageBox.Show("必填项为空"); // return; // } // double ng = double.Parse(ngqty.Text); // double nowng = double.Parse(dh.getFieldDataByCondition("MES_STEPREPORTdet", "nvl(sum(msd_qty),0)", " msd_msid = '" + msid + "' and msd_stepcode = '" + User.CurrentStepCode + "' and msd_status = 0 ").ToString()); // if (nowng + double.Parse(ngqty.Text) > badqty) // { // MessageBox.Show("已录入不良" + nowng + "+待录入不良" + ng + "大于不良总数" + badqty + ""); // return; // } // else // { // string msdid = dh.GetSEQ("MES_STEPREPORTDET_seq"); // sql.Clear(); // sql.Append("insert into MES_STEPREPORTdet (MSD_ID,MSD_MSID,MSD_BADNAME ,MSD_QTY,"); // sql.Append("MSD_INDATE,MSD_STATUS,MSD_STEPCODE"); // sql.Append(") values(" + msdid + "," + msd_id + ",'" + comBoxWithFocus1.Text + "',"); // sql.Append("'" + ng + "',sysdate,'0','" + User.CurrentStepCode + "')"); // dh.ExecuteSql(sql.GetString(), "insert"); // LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "工序不良报工", "现象:" + comBoxWithFocus1.Text + ",数量:" + ng + "", "", ""); // FillDataGridView(); // comBoxWithFocus1.Text = ""; // ngqty.Text = ""; // } //} //catch (Exception ex) //{ // Console.WriteLine(ex.Message); //} } }