jace.tang
2022-06-14 bd5297c64f39c360a7bf41435a88ae5e70840fc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace M423project
{
    public partial class FormCheck : Form
    {
        public static bool _pickNow;
        public static int _pickCount;
        public static int _lastProductQty;
        public static int _lastBreakProductQty;
        public static int _totalQty;
        public static int _finishedQty;
        public SpotCheckData _spotData;
        public static SpotCheckDetail _detail = new SpotCheckDetail();
 
        public FormCheck()
        {
            InitializeComponent();
            _spotData = new SpotCheckData();
            LoadInfo();
        }
 
        public void LoadInfo()
        {
            gridDetail.AutoGenerateColumns = false;
            grid.AutoGenerateColumns = false;
            gridDetail.DataSource = _spotData.GetTodayFinishedSpot();
            grid.DataSource = _spotData.GetTodayCheckPlan();
        }
 
        private void btnClose_Click(object sender, EventArgs e)
        {
            Close();
        }
 
        private void txtTime_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }
 
        private void txtQty_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar != 8 && !Char.IsDigit(e.KeyChar))
            {
                e.Handled = true;
            }
        }
 
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            try
            {
                if (_spotData.IsSpotCheck())
                {
                    MessageBox.Show("今日已有抽检计划");
                    return;
                }
                double timeHour = Convert.ToDouble(txtTime.Text);
                if (DateTime.Now.AddHours(timeHour).Day!=DateTime.Now.Day)
                {
                    MessageBox.Show("不允许跨天抽检");
                    return;
                }
                _totalQty = Convert.ToInt32(txtQty.Text);
                double timeSecond = timeHour * 60 * 60 * 0.8;
                _pickCount = Convert.ToInt32(timeSecond / 4 / _totalQty);
 
 
                SpotCheck spotCheck = new SpotCheck();
                spotCheck.TotalQty = _totalQty;
                spotCheck.FinishedQty = 0;
                _finishedQty = 0;
                spotCheck.PickCount = _pickCount;
                spotCheck.LastBreakProductQty = 0;
                spotCheck.LastProductQty = 0;
                _spotData.SaveSpotCheck(spotCheck);
            }
            catch (Exception)
            {
            }
 
            Close();
        }
 
        private void btnNow_Click(object sender, EventArgs e)
        {
            _pickNow = true;
            Close();
        }
    }
}