123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- 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_StepReportDetailFail : 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_StepReportDetailFail(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;
-
- 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["msf_id"].Value.ToString();
- if (id != "0")
- {
- dh.ExecuteSql("update MES_STEPREPORTFAIL set msf_status =-1 where msf_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 msf_id,msf_msid,msf_badname,msf_qty,msf_indate,msf_status,msf_stepcode from MES_STEPREPORTFAIL ");
- sql.Append("where msf_msid = '" + msid + "' and msf_stepcode = '" + User.CurrentStepCode + "' and msf_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["msf_id"].Value.ToString() == "0")
- e.Value = Properties.Resources.WhiteImage;
- else
- e.Value = Properties.Resources.bindingNavigatorDeleteItem_Image;
- }
- }
- private void button1_Click_1(object sender, EventArgs e)
- {
- }
- private void BatchProductDGV_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
- {
- bool mouseOver = e.CellBounds.Contains(this.PointToClient(Cursor.Position));
- if (e.ColumnIndex > 0)
- {
- if (BatchProductDGV.Columns[e.ColumnIndex].Name == "msf_qty")
- {
- SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
- e.Graphics.FillRectangle(mouseOver ? solidBrush : Brushes.LightSeaGreen, e.CellBounds);
- Rectangle border = e.CellBounds;
- border.Width -= 1;
- e.Graphics.DrawRectangle(Pens.White, border);
- e.PaintContent(e.CellBounds);
- e.Handled = true;
- }
- }
- }
- private void button1_Click_2(object sender, EventArgs e)
- {
- try
- {
- if (comBoxWithFocus1.Text == "" || ngqty.Text == "")
- {
- MessageBox.Show("必填项为空");
- return;
- }
- double ng = double.Parse(ngqty.Text);
- double nowng = double.Parse(dh.getFieldDataByCondition("MES_STEPREPORTFAIL", "nvl(sum(msf_qty),0)", " msf_msid = '" + msid + "' and msf_stepcode = '" + User.CurrentStepCode + "' and msf_status = 0 ").ToString());
- if (nowng + double.Parse(ngqty.Text) > badqty)
- {
- MessageBox.Show("已录入报废" + nowng + "+待录入报废" + ng + "大于报废总数" + badqty + "");
- return;
- }
- else
- {
- string msdid = dh.GetSEQ("MES_STEPREPORTFAIL_seq");
- sql.Clear();
- sql.Append("insert into MES_STEPREPORTFAIL (MSF_ID,MSF_MSID,MSF_BADNAME ,MSF_QTY,");
- sql.Append("MSF_INDATE,MSF_STATUS,MSF_STEPCODE,MSF_TYPE");
- sql.Append(") values(" + msdid + "," + msid + ",'" + comBoxWithFocus1.Text + "',");
- sql.Append("'" + ng + "',sysdate,'0','" + User.CurrentStepCode + "','"+ comBoxWithFocus2.Text+ "')");
- 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);
- }
- }
- private void comBoxWithFocus2_SelectedIndexChanged(object sender, EventArgs e)
- {
- sql.Clear();
- sql.Append("select BGD_BADCODE from badgroupdetail left join badgroup on bgd_bgid = bg_id where bg_code = '报废' and bgd_brcode = '"+ comBoxWithFocus2.Text+ "' ORDER BY BGD_ID ASC");
- DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
- comBoxWithFocus1.DisplayMember = "BGD_BADCODE";
- comBoxWithFocus1.ValueMember = "BGD_BADCODE";
- comBoxWithFocus1.DataSource = dt;
- comBoxWithFocus1.Text = "";
- }
- }
- }
|