yangle
2023-03-03 c2a9a460e38c7c196fe98a94e29e6330eac3626f
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Pub_Class;
 
namespace OAM
{
    public partial class frmGGView1 : Form
    {
        public frmGGView1()
        {
            InitializeComponent();
        }
 
        public const int HFileNameCol = 0;//huan
        public const int HFilePathCol = 1;
        public const int HUpManCol = 2;
        public const int HItemIDCol = 3;
        public long ID;
        public long MainID;
 
        public const string ModName = "4508";                   //µ¥¾ÝÀàÐÍ
        public const string ModCaption = "»áÒé֪ͨ";          //µ¥¾ÝÃû³Æ
        public const string ModRightName = "frmGGView1";
        public const string ModRightNameEdit = ModRightName + "_Edit";
        public const string ModRightNameCheck = ModRightName + "_Check";
        public const string ModRightNameClose = ModRightName + "_Close";
        public const string ModRightNameDelete = ModRightName + "_Delete";
        public bool BillChange;                                 //µ¥¾ÝÐÞ¸Ä״̬
        //
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;     //µ¥¾Ý״̬£¨ÐÂÔö£¬Ð޸ģ¬ä¯ÀÀ£¬¸üе¥¼Û£¬±ä¸ü£©
        public Int64 KeyID;                                     //µ¥¾ÝÖ÷ÄÚÂë
        public bool grdStatus;                                 //Íø¸ñ״̬£¨²»¿É±à¼­£¬¿É±à¼­£©
        //-------------------------------------------------------------------------
 
 
        #region ¹Ì¶¨´úÂë
 
       
        //´°Ìå¼ÓÔØ
        private void frmGGView1_Load(object sender, EventArgs e)
        {
            initGridFJ();
            dtpDate.Value = DateTime.Today;
            dtpHEDate.Value = DateTime.Today;
            dtpsdate.Value = DateTime.Today;
            this.Text = ModCaption;     //ÃüÃû´°Ìå±êÌâ
            this.lblCaption.Text = ModCaption;//ÃüÃûµ¥¾Ý±êÌâ
            DBUtility.ClsPub.GetGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath);
        }
        private void initGridFJ()//huan
        {
            grdFJ.ColumnCount = 4;                       //×ÜÁÐÊý
            DBUtility.Xt_BaseBillFun.initGridFst(grdFJ, this.Name + "grdFJ");
            grdFJ.ReadOnly = true;
            grdFJ.RowCount = 0;
            //= 
            grdFJ.Columns[HFileNameCol].HeaderText = "ÎļþÃû³Æ";
            grdFJ.Columns[HFilePathCol].HeaderText = "Îļþ·¾¶";
            grdFJ.Columns[HUpManCol].HeaderText = "ÉÏ´«ÈË";
            DBUtility.ClsPub.GetGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath);
        }
        //Ö÷½çÃæÉ¾³ý°´Å¥
        private void Command1_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            if (txtOperator.Text == DBUtility.ClsPub.CurUserName)
            {
                DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´Ëµ¥¾ÝÂð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                if (dr == DialogResult.Yes)
                {
                    if (!DBUtility.ClsPub.Security_Log("OA_Manager", 1, true, DBUtility.ClsPub.CurUserName))
                    {
                        return;
                    }
                    oCn.RunProc("delete from oa_gg1sub where Mainid=" + ID);
                    oCn.RunProc("delete from oa_gg1 where id=" + ID);
                    MessageBox.Show("ɾ³ý³É¹¦£¡");
 
                    DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); 
                    this.Close();
                }
                else
                {
                }
            }
            else
            {
 
                MessageBox.Show("¶Ô²»Æð!Ö»Óз¢ËÍÈ˲ÅÄÜɾ³ý£¡");
            }
           
          
        }
 
        //Ìí¼Ó°´Å¥
        private void cmdAdd_Click_1(object sender, EventArgs e)
        {
            OpenFileDialog oDlg = new OpenFileDialog();
            oDlg.Filter = "ËùÓÐÎļþ|*.*";
            if (oDlg.ShowDialog() == DialogResult.OK)
            {
                if (oDlg.FileName != "")
                {
                    grdFJ.Rows.Add();
                    grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFileNameCol].Value = oDlg.SafeFileName;
                    grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFilePathCol].Value = oDlg.FileName;
                    grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HUpManCol].Value = DBUtility.ClsPub.CurUserName;
                    //Ö±½ÓÉÏ´« 
                    BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl();
                    if (oFile.LoadUpFile(ID, 1, DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFilePathCol].Value), 0,
                        DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.Rows.Count - 1].Cells[HFileNameCol].Value), DBUtility.ClsPub.CurUserName) == false)
                    {
                        MessageBox.Show("ÉÏ´«Îļþʱʧ°Ü!");
                    }
                    //
                }
            }
        }
 
        //ɾ³ý°´Å¥
        private void cmdDel_Click_1(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
            if (grdFJ.CurrentRow == null)
            {
 
                return;
            }
            if (DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HUpManCol].Value) != DBUtility.ClsPub.CurUserName)
            {
                MessageBox.Show("Ö»ÄÜɾ³ý×Ô¼ºÉÏ´«µÄ¸½¼þ£¡");
                return;
            }
            DialogResult dr = MessageBox.Show("È·¶¨ÒªÉ¾³ý´Ëµ¥¾ÝÂð£¿", "Ìáʾ", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (dr == DialogResult.Yes)
            {
                //if (!DBUtility.ClsPub.Security_Log("OA_Manager", 1, true, DBUtility.ClsPub.CurUserName))
                //{
                //    return;
                //}
                //ɾ³ý¸½¼þ
                BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl();
                SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3();
                if (oFile.DeleteFile(DBUtility.ClsPub.isLong(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HItemIDCol].Value), ref DBUtility.ClsPub.sExeReturnInfo, oCNK3) == false)
                {
                    MessageBox.Show("ɾ³ýÎļþʱʧ°Ü!");
                }
                //
                grdFJ.Rows.RemoveAt(grdFJ.CurrentRow.Index);
            }
            else
            {
            }
          
        }
 
 
        //´°ÌåÐ¶ÔØ
        private void frmGGView1_FormClosing(object sender, FormClosingEventArgs e)
        {
            BillStatus = DBUtility.ClsPub.Enum_BillStatus.BillStatus_AddNew;
        }
 
 
        #endregion
 
 
        #region  ¶ÁдÀà
        //ÏÔʾµ¥¾Ý
        public void Sub_ShowBill()
        {
            
 
        }
 
        #endregion 
 
        private void cmdCancel_Click(object sender, EventArgs e)
        {
            DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); 
            this.Close();
        }
 
 
        private string GetReadEmp(long MID, string sBill)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds;
            string GetReadEmp="";
            Ds = oCn.RunProcReturn("select roperator from oa_readnum where MainID=" + MID + " and sBill='" + sBill + "'", "oa_readnum");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                GetReadEmp = "";
            }
            else
            {
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    GetReadEmp = GetReadEmp + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i][0]) + ",";
                }
            }
            if (GetReadEmp != "")
            {
                GetReadEmp = GetReadEmp.Remove(GetReadEmp.Length - 1, 1);
            }
            return GetReadEmp;
        }
 
        private long GetReadNum(long MID, string sBill)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds;
            long GetReadNum=0;
            Ds = oCn.RunProcReturn("select count(*)as Num from oa_readnum where MainID=" + MID + " and sBill='" + sBill + "'", "oa_readnum");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                GetReadNum =0;
            }
            else
            {
                GetReadNum = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0][0]);
            }
            return GetReadNum;
        }
 
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            Display();
        }
 
        public void  Display()
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds;
            DataSet Ds2;
            Ds = oCn.RunProcReturn("Select * from oa_gg1 where id=" + ID, "oa_gg1", ref DBUtility.ClsPub.sExeReturnInfo);
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("ÏÔʾʧ°Ü£¡Ô­Òò£º" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            txtManager.Text = Ds.Tables[0].Rows[0]["manager"].ToString();
            dtpDate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["workdate"].ToString()).ToShortDateString();
            dtpTime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["workdate"].ToString()).ToShortTimeString();
            dtpHEDate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["hedate"].ToString()).ToShortDateString();
            dtpHETime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["hedate"].ToString()).ToShortTimeString();
            dtpsdate.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["sDate"].ToString()).ToShortDateString();
            dtpsTime.Text = DBUtility.ClsPub.isDate(Ds.Tables[0].Rows[0]["sDate"].ToString()).ToShortTimeString();
 
            txtContext.Text = Ds.Tables[0].Rows[0]["context"].ToString();
            txtAddr.Text = Ds.Tables[0].Rows[0]["addr"].ToString();
            txtHNoteMan.Text = Ds.Tables[0].Rows[0]["hnoteman"].ToString();
            txtHSummary.Text = Ds.Tables[0].Rows[0]["HSummary"].ToString();
            txtRemark.Text = Ds.Tables[0].Rows[0]["remark"].ToString();
            txtOperator.Text = Ds.Tables[0].Rows[0]["operator"].ToString();
            txtDesc.Text = Ds.Tables[0].Rows[0]["Description"].ToString();
            if (Ds.Tables[0].Rows[0]["maker"].ToString() == DBUtility.ClsPub.CurUserName)
            {
                cmdSave.Visible = true;
            }
            else
            {
                cmdSave.Visible = false;
            }
            MainID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[0]["MainID"].ToString());
 
 
            oCn.RunProc("update oa_gg1sub set isread=1 where mainid=" + MainID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'");
            Ds2 = oCn.RunProcReturn("select * from oa_ReadNum where sbill='oa_gg1' and  MainID=" + MainID + " and roperator='" + DBUtility.ClsPub.CurUserName + "'", "oa_ReadNum");
        
            if (Ds != null && Ds2.Tables[0].Rows.Count == 0)
            {
                oCn.RunProc("insert into oa_ReadNum (MainID,sBill,rOPerator) values (" + MainID + ",'oa_gg1','" + DBUtility.ClsPub.CurUserName + "') ");
            }
            lblNum.Text = GetReadNum(MainID, "oa_gg1").ToString();
            txtEmp.Text = GetReadEmp(MainID, "oa_gg1");
            //¸½¼þ   huan
            DisplayFJ();
            //DBUtility.ClsPub.GetGridView(grdMain, this.Name, DBUtility.ClsPub.AppPath);
            DBUtility.ClsPub.GetGridView(grdFJ, this.Name + "grdFJ", DBUtility.ClsPub.AppPath);
            //
        }
        private void DisplayFJ()//huan
        {
            SQLHelper.ClsCNK3 oCn = new SQLHelper.ClsCNK3();
            DataSet Ds;
            Ds = oCn.RunProcReturn("Select FItemID,fupman,ffilename,fpath from OA_Accessories where FFileID=" + ID, "OA_Accessories");
            if (Ds == null || Ds.Tables[0].Rows.Count == 0)
            {
                return;
            }
            for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
            {
                grdFJ.Rows.Add();
                grdFJ.Rows[i].Cells[HFileNameCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FFileName"]);
                grdFJ.Rows[i].Cells[HFilePathCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FPath"]);
                grdFJ.Rows[i].Cells[HUpManCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FUpMan"]);
                grdFJ.Rows[i].Cells[HItemIDCol].Value = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["FItemID"]);
            }
        }
 
 
        private void cmdSave_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            oCn.RunProc("update oa_gg1 set operator='" + txtOperator.Text+"'"+
                                            ",context='" + txtContext.Text + "'" +
                                            ",HSummary='" + txtHSummary.Text + "'" +
                                            ",addr='" + txtAddr.Text + "'" +
                                            ",Description='" + txtDesc.Text + "'" +
                                            ",remark='" + txtRemark.Text + "'" +
                                            ",makedate=getdate()" +
                                            ",workdate='" + dtpDate.Text + " " + dtpTime.Text + "'" +
                                            " where id=" + ID);
            MessageBox.Show("±£´æ³É¹¦");
            DBUtility.ClsPub.SaveGridView(grdFJ, this.Name, DBUtility.ClsPub.AppPath); 
            this.Close();
        }
 
      
        private void grdFJ_DoubleClick(object sender, EventArgs e)
        {
 
            if (grdFJ.CurrentRow == null)
            {
                return;
            }
            //ÏÂÔØ¸½¼þµ½±¾µØ£¬²¢Ö´ÐÐ
            BLL.ClsXt_FileCtrl oFile = new BLL.ClsXt_FileCtrl();
            SQLHelper.ClsCNK3 oCNK3 = new SQLHelper.ClsCNK3();
            if (oFile.WriteFile("FFile"
                , DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HFileNameCol].Value)
                , DBUtility.ClsPub.isLong(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HItemIDCol].Value), oCNK3) == false)
            {
                MessageBox.Show("¶ÁÈ¡Îļþʱʧ°Ü!");
            }
            System.Diagnostics.Process.Start(DBUtility.ClsPub.AppPath + @"\a\" + DBUtility.ClsPub.isStrNull(grdFJ.Rows[grdFJ.CurrentRow.Index].Cells[HFileNameCol].Value));
        
        }
    }
}