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
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_WIPBalanceImport : Form
    {
        public CB_WIPBalanceImport()
        {
            InitializeComponent();
        }
 
        const string ViewName = "h_v_CB_WIPBalanceImport";
        const string ModCaption = "Ö±½Ó²ÄÁÏÔÚÖÆ»ã×ÜÒýÈë";
        public const string ModName = "1205";
        public const string ModRightName = "CB_WIPBalance";
        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)
        {
            DBUtility.Gy_BaseFun.DataToExcel(this.Text, 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 = "select * from h_v_CB_WIPBalanceImport where Äê="+cmbHYear.Text+" and ÔÂ="+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)
        {
            ClsCN oCn = new ClsCN();
            int HYear;
            int HPeriod;
            long HDeptID;
            long HMaterID;
            double HQty;
            double HPrice;
            double HMoney;
            string HRemark;
            for (int i = 0; i < grdMain.RowCount; i++)
            {
                HYear = Pub_Class.ClsPub.isInt(grdMain.Rows[i].Cells[Fun_GetCol("Äê")].Value);
                HPeriod = Pub_Class.ClsPub.isInt(grdMain.Rows[i].Cells[Fun_GetCol("ÔÂ")].Value);
                HDeptID = Pub_Class.ClsPub.isInt(grdMain.Rows[i].Cells[Fun_GetCol("HDeptID")].Value);
                HMaterID = Pub_Class.ClsPub.isInt(grdMain.Rows[i].Cells[Fun_GetCol("HMaterID")].Value);
                HQty = Pub_Class.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("MESÊýÁ¿")].Value);
                HPrice = Pub_Class.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("µ¥¼Û")].Value);
                HMoney = Pub_Class.ClsPub.isDoule(grdMain.Rows[i].Cells[Fun_GetCol("½ð¶î")].Value);
                HRemark = "";
                if (HMaterID==0)
                    continue;
                oCn.RunProc("insert into  CB_WIPBalance (HYear,HPeriod,HBillType,HDate" +
                                                                ",HDeptID,HMaterID,HQty,HPrice,HMoney,HRemark" +
                                                                ",HMaker,HMakeDate)" +
                                                                "values('" + HYear + "','" + HPeriod + "','1111',GETDATE()" +
                                                                "," + HDeptID + "," + HMaterID + "," + HQty + "," + HPrice + "," + HMoney + ",'" + HRemark + "'" +
                                                                ",'" + DBUtility.ClsPub.CurUserName + "',GETDATE())");
            }
            MessageBox.Show("±£´æÍê±Ï£¡");
        }
 
        private void tc_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void CB_WIPBalanceImport_Load(object sender, EventArgs e)
        {
            cmbHYear.Items.Clear();
            cmbHYear.Items.Add(DateTime.Today.Year - 4);
            cmbHYear.Items.Add(DateTime.Today.Year - 3);
            cmbHYear.Items.Add(DateTime.Today.Year - 2);
            cmbHYear.Items.Add(DateTime.Today.Year - 1);
            cmbHYear.Items.Add(DateTime.Today.Year);
            cmbHYear.SelectedIndex = 4;
            cmbHPeriod.Text = DateTime.Today.AddMonths(-1).Month.ToString();
        }
    }
}