duhe
2023-06-13 bff338f3b532b0bf2a8f3f2d6b662adb9a222f13
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using gregn6Lib;
using SQLHelper;
 
 
namespace CostM
{
    public partial class CB_WorkTimePeriodImport : Form
    {
        public CB_WorkTimePeriodImport()
        {
            InitializeComponent();
        }
 
        const string ViewName = "h_v_CB_WorkTimePeriodImport";
        const string ModCaption = "ʵ¼Ê¹¤Ê±ÒýÈë";
        public const string ModName = "1205";
        public const string ModRightName = "CB_WorkTimePeriod";
        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 const string ModRightNameMoney = ModRightName + "_Money";
        public const string ModRightNameQty = ModRightName + "_Qty";
        public Int32 iTopRow = 0;//»­ºáÏß
        int _ScrollValue = 0;//ˢР»ØÎ»
        private void bclk_Click(object sender, EventArgs e)
        {
            //±£´æÁпí
            DBUtility.Xt_BaseBillFun.SaveGrid(grdMain, this.Name);
        }
 
        private void mrlk_Click(object sender, EventArgs e)
        {
            DBUtility.Xt_BaseBillFun.DefaultGridView(grdMain, this.Name);
        }
 
        private void dc_Click(object sender, EventArgs e)
        {
            BLL.ClsPub_BLL.DataToExcel(grdMain);
        }
 
 
        #region  //´òÓ¡ÉèÖÃ
        GridppReport Report;
        private void set_Click(object sender, EventArgs e)
        {
            //Ñ¡Ôñ´òÓ¡Ä£°å
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog(); 
        }
 
        private void dy_Click(object sender, EventArgs e)
        {
            //Ñ¡Ôñ´òÓ¡Ä£°å
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //
                Sub_SetReport(oFrm.sOpenTmp);
                Report.Print(true);
            }
        }
 
        private void yl_Click(object sender, EventArgs e)
        {
            //Ñ¡Ôñ´òÓ¡Ä£°å
            BLL.Gy_OpenTmp oFrm = new BLL.Gy_OpenTmp();
            oFrm.sBillName = ModName;
            oFrm.sBillModel = ModCaption;
            oFrm.ShowDialog();
            if (oFrm.OKTag == Pub_Class.ClsPub.Enum_OKTag.OKTag_OK)
            {
                //
                Sub_SetReport(oFrm.sOpenTmp);
                Report.PrintPreview(true);
            }
        }
 
        private void Sub_SetReport(string sOpenTmp)
        {
            //ÅжÏÐÐÊý
            //
            Report = new GridppReport();
            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + sOpenTmp + ".grf");  //here .
            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
        }
 
        private void ReportFetchRecordByDataTable()
        {
            BLL.Utility.FillRecordToReport(Report, grdMain, grdPrint, 0);
        }
 
        #endregion
 
        private void yr_Click(object sender, EventArgs e)
        {
            ClsCN SubCn = new ClsCN();
            DataSet DSet;
            string sSql = "exec kfmic_caiwu_depttasktime " + cmbHYear.Text + " ," + cmbHPeriod.Text;
 
            DSet = SubCn.RunProcReturn(sSql, ViewName, ref DBUtility.ClsPub.sExeReturnInfo);
            //Éú³ÉÊ×ÐбêÌâ
            if (DSet == null)
            {
                MessageBox.Show("ûÓзµ»ØÈκνá¹û,Çë³¢ÊÔÔٴβéѯ£¡" + DBUtility.ClsPub.sExeReturnInfo);
                return;
            }
            //ÊͷŶ³½á
            DBUtility.Xt_BaseBillFun.CancelFrozenCol(grdMain);
            //ˢкó,»Ø¹öµ½Ô­Î»ÖÃ
            int selectRows = 0;
            if (grdMain.CurrentRow != null)
            {
                selectRows = DBUtility.ClsPub.isInt(grdMain.CurrentRow.Index);
            }
            //°ó¶¨
            grdMain.DataSource = DSet.Tables[0].DefaultView;
            //ˢкó,»Ø¹öµ½Ô­Î»ÖÃ
            if (grdMain.Rows.Count > _ScrollValue)
            {
                grdMain.FirstDisplayedScrollingRowIndex = _ScrollValue;
                //iTopRow = _ScrollValue;
            }
            if (grdMain.Rows.Count > 0 && grdMain.Rows.Count > selectRows)
            {
                grdMain.Rows[selectRows].Selected = true;
            }
            //ÉèÖúϼÆÁÐ
            //string sTotalCol = "";
            //sTotalCol = DBUtility.Gy_BaseFun.GetTotalCols(DSet);
            //string[] sT;
            //sT = sTotalCol.Split(Convert.ToChar(","));
            //oSumGrid.BuildTotalCols(sT);
            //  
            //¶³½á
            int FrCol = DBUtility.ClsPub.isInt(0);
            string s = "";
            DBUtility.Xt_BaseBillFun.DisplayGrid(grdMain, this.Name, s, FrCol);
            //»­Ïß
            GraphLine();
            //
            //Total();
        }
 
        private void GraphLine()
        {
            //int MainIDCol = Fun_GetCol("hmainid");
            //int SubIDCol = Fun_GetCol("hsubid");
            //string s = frmCondition.cmbHComplete.Text;
            //long n = 0;
            //DBUtility.Xt_BaseBillFun.GraphLine(grdMain, MainIDCol, SubIDCol, s, ref n);
            ////ÏÔʾ
            //lbldj.Text = "²éѯ³ö " + n.ToString() + " Õŵ¥¾Ý";
            //lbljl.Text = "¹²ÓР" + grdMain.RowCount.ToString() + " Ìõ¼Ç¼";
 
        }
 
 
        private Int32 Fun_GetCol(string sCol)
        {
            return DBUtility.Xt_BaseBillFun.Fun_GetCol(sCol, grdMain);
        }
 
        private void xz_Click(object sender, EventArgs e)
        {
            //»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
            if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
            {
                MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
                return;
            }
            //ÅжÏÊÇ·ñ±¾ÆÚ¼ä
            if (Pub_Class.ClsPub.isInt(cmbHYear.Text) != DBUtility.ClsPub.CBCurYear || Pub_Class.ClsPub.isInt(cmbHPeriod.Text) != DBUtility.ClsPub.CBCurPeriod)
            {
                MessageBox.Show("Ö»Äܱ£´æ±¾ÆÚÊý¾Ý£¡");
                return;
            }
            //
            ClsCN oCn = new ClsCN();
            DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
            int HYear;
            int HPeriod;
            long HMaterID;
            string HMaterNumber;
            double HRelWorkTimes;
            long HDeptID;
            string HMESDeptName;
            HYear = Pub_Class.ClsPub.isInt(cmbHYear.Text);
            HPeriod = Pub_Class.ClsPub.isInt(cmbHPeriod.Text);
            string HDeptName="";
            for (int j = 0; j < grdMain.RowCount; j++)
            {
                HDeptID = Pub_Class.ClsPub.isLong(grdMain.Rows[j].Cells[Fun_GetCol("HDeptID")].Value);
                if (HDeptID == 0)
                {
                    if (HDeptName.IndexOf(Pub_Class.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("MES²¿ÃÅ")].Value)) > -1)
                    {
                        continue;
                    }
                    else
                    {
                        HDeptName = HDeptName + "," + Pub_Class.ClsPub.isStrNull(grdMain.Rows[j].Cells[Fun_GetCol("MES²¿ÃÅ")].Value);
                    }
                }
            }
            if (HDeptName != "")
            {
                HDeptName = HDeptName.Remove(0, 1);
                if (MessageBox.Show("´æÔÚÎÞERP²¿ÃżÇ¼£¬ÊÇ·ñ¼ÌÐø±£´æ£¡\r\n MES²¿ÃÅ£º" + HDeptName, "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    AddNew();
                }
            }
            else
            {
                AddNew();
            }
        }
        private void AddNew()
        {
            ClsCN oCn = new ClsCN();
            DAL.ClsK3_Material_View oMater = new DAL.ClsK3_Material_View();
            int HYear;
            int HPeriod;
            long HMaterID;
            string HMaterNumber;
            double HRelWorkTimes;
            long HDeptID;
            string HMESDeptName;
            HYear = Pub_Class.ClsPub.isInt(cmbHYear.Text);
            HPeriod = Pub_Class.ClsPub.isInt(cmbHPeriod.Text);
 
            oCn.RunProc("delete CB_WorkTimePeriod where HYear=" + HYear + " and HPeriod=" + HPeriod);
            for (int i = 0; i < grdMain.RowCount; i++)
            {
                HDeptID = Pub_Class.ClsPub.isLong(grdMain.Rows[i].Cells[Fun_GetCol("HDeptID")].Value);
                HMaterNumber = Pub_Class.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("²úÆ·´úÂë")].Value);
                HMESDeptName = Pub_Class.ClsPub.isStrNull(grdMain.Rows[i].Cells[Fun_GetCol("MES²¿ÃÅ")].Value);
                if (oMater.GetInfoByNumber(HMaterNumber))
                {
                    HMaterID = oMater.omodel.HItemID;
                }
                else
                {
                    HMaterID = 0;
                }
                HRelWorkTimes = Pub_Class.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("ʵ¼Ê¹¤Ê±")].Value);
                if (HMaterID == 0)
                    continue;
                //if (HDeptID == 0)
                //    continue;
                oCn.RunProc("insert into  CB_WorkTimePeriod (HYear,HPeriod" +
                                                            ",HDeptID,HMaterID,HMaterNumber,HMESDeptName,HRelWorkTimes" +
                                                            ")" +
                                                            "values('" + HYear + "','" + HPeriod + "'" +
                                                            "," + HDeptID + "," + HMaterID + ",'" + HMaterNumber + "','" + HMESDeptName + "'," + HRelWorkTimes + ")");
            }
            MessageBox.Show("±£´æÍê±Ï£¡");
        }
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void CB_WorkTimePeriodImport_Load(object sender, EventArgs e)
        {
 
            cmbHYear.Items.Clear();
            //»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
            if (DBUtility.ClsPub.Sub_CBGetCurPeriod() == false)
            {
                MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
                return;
            }
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 1);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 2);
            cmbHYear.Items.Add(DBUtility.ClsPub.CBCurYear - 3);
            cmbHYear.SelectedIndex = 0;
            cmbHPeriod.Text = DBUtility.ClsPub.CBCurPeriod.ToString();
            initGrid();
        }
 
        //³õʼ»¯GRID
        private void initGrid()
        {
            DBUtility.Gy_BaseFun.initGrid(grdMain);
        }
    }
}