zrg
2024-05-09 2a52411bca70c10b4a8fe08ce44c2b47ef8ecbf7
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace BaseSet
{
    public partial class Gy_ClassTimePrjGroup : Form
    {
        public Gy_ClassTimePrjGroup()
        {
            InitializeComponent();
 
        }
        public DBUtility.ClsPub.Enum_InputMode InputMode;  //¼Èë״̬±êÖ¾(0-·Ç¼Èë״̬ 1-Ôö¼Ó 2-ÐÞ¸Ä)
        public long HItemID;
        DAL.ClsGy_ClassTimePrjGroup_Ctl oUnGp = new DAL.ClsGy_ClassTimePrjGroup_Ctl();
        DAL.ClsGy_ClassTimePrjGroup_View oUnGpHlp = new DAL.ClsGy_ClassTimePrjGroup_View();
 
        private void Display()                    
        {
            
            if (HItemID == 0)
            {
                MessageBox.Show("ûÓÐÕÒµ½×飡", "Ìáʾ");
                return;
            }
            if( oUnGpHlp.GetInfoByID(HItemID))
            {
                DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();
                txtHName.Text = oUnGpHlp.omodel.HName;
                txtHNumber.Text = oUnGpHlp.omodel.HNumber;
                txtHRemark.Text = oUnGpHlp.omodel.HRemark;
                if (oDept.GetInfoByID(oUnGpHlp.omodel.HDeptID))
                {
                    txtHDeptID.Text = oDept.omodel.HName;
                    txtHDeptID.Tag = oDept.omodel.HItemID.ToString();
                }
                else
                {
                    txtHDeptID.Text = "";
                }
            }
            else
            {
                MessageBox.Show("ûÓÐÕÒµ½×飡", "Ìáʾ");
            }
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                txtHName.Text = "";
                txtHName.Focus();
            }
            else
            {   
                Display();
            }
        }
 
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void cmdOK_Click(object sender, EventArgs e)
        {
            oUnGp.oModel.HName = txtHName.Text.Trim();
            oUnGp.oModel.HNumber = txtHNumber.Text.Trim();
            oUnGp.oModel.HRemark = txtHRemark.Text.Trim();
            oUnGp.oModel.HDeptID = DBUtility.ClsPub.isLong(txtHDeptID.Tag);
            if (InputMode == DBUtility.ClsPub.Enum_InputMode.InputMode_AddNew)
            {
                if (!oUnGp.AddNew())
                {
                    MessageBox.Show("ÐÂÔöʧ°Ü£¡ÇëÓë¹ÜÀíÔ±ÁªÏµ£¡", "Ìáʾ");
                }
            }
            else
            {
                if (!oUnGp.ModifyByID(HItemID))
                {
                    MessageBox.Show("ÐÞ¸Äʧ°Ü£¡ÇëÓë¹ÜÀíÔ±ÁªÏµ£¡", "Ìáʾ");
                }
            }
            this.Close();
        }
 
        private void cmdHDeptID_Click(object sender, EventArgs e)
        {
            DAL.ClsGy_Department_View oDept = new DAL.ClsGy_Department_View();
            if (oDept.RefreshView())
            {
                txtHDeptID.Tag = oDept.oModel.HItemID.ToString();
                txtHDeptID.Text = oDept.oModel.HName;
            }
            else
            {
                txtHDeptID.Text = "";
            }
        }
 
        private void txtHDeptID_TextChanged(object sender, EventArgs e)
        {
            if (txtHDeptID.Text.Trim() =="")
            {
                txtHDeptID.Tag = "0";
            }
        }
    }
}