1
wtt
4 天以前 b371b604a464e7249634bbdb45cda85dd5bd1f3a
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace PayM
{
    public partial class Pay_SumBalBill_JS : Form
    {
        public Pay_SumBalBill_JS()
        {
            InitializeComponent();
        }
 
        public DAL.ClsPay_SumBalBill BillNew = new DAL.ClsPay_SumBalBill();   //¶ÔÓ¦µ¥¾ÝÀà
        private void Pay_SumBalBill_JS_Load(object sender, EventArgs e)
        {
            cmbHYear.Items.Clear();
            //»ñÈ¡±¾ÆÚ³É±¾»á¼ÆÆÚ¼ä
            int CurYear = 0;
            int CurPeriod = 0;
            if (DBUtility.ClsPub.Sub_GetCurPeriod(ref  CurYear, ref  CurPeriod) == false)
            {
                MessageBox.Show("»ñÈ¡³É±¾»á¼ÆÆÚ¼äʧ°Ü!");
                return;
            }
            cmbHYear.Items.Add(CurYear);
            cmbHYear.Items.Add(CurYear - 1);
            cmbHYear.Items.Add(CurYear - 2);
            cmbHYear.Items.Add(CurYear - 3);
            cmbHYear.Items.Add("");
            cmbHYear.SelectedIndex = 0;
            cmbHPeriod.Text = CurPeriod.ToString();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
 
            bool bResult;
            SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
            DataSet Ds;
            //-------------ÅжÏÊÇ·ñÒѾ­½áÕË
            //
            string a = "";
            int sYear = 0;
            int sPeriod = 0;
            if (!DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DBUtility.ClsPub.isDate(cmbHYear.Text + "-" + cmbHPeriod.Text+"-01"), ref sYear, ref sPeriod, ref a))
            {
                MessageBox.Show(a + "£¬²»ÔÊÐí¼ÆË㣡", "Ìáʾ");
                return;
            }
            //
            //-----------ÅжÏËùÓе¥¾ÝÊÇ·ñÒѾ­ÉóºË
            Ds = oCn.RunProcReturn("exec h_p_Pay_SumBalBill_JSCheck " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SumBalBill_JSCheck", ref DBUtility.ClsPub.sErrInfo);
            if (Ds == null)
            {
                MessageBox.Show("ÅжÏËùÓе¥¾ÝÊÇ·ñÒѾ­ÉóºË³ö´í£º" + DBUtility.ClsPub.sErrInfo);
                return;
            }
            if (Ds.Tables[0].Rows.Count != 0)
            {
                string s = "";
                for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
                {
                    s = s + Ds.Tables[0].Rows[i][0].ToString()+"\r\n";
                }
                s = s + "´æÔÚ´íÎóÐÅÏ¢£¬²»ÔÊÐí¼ÆË㣡";
                MessageBox.Show(s);
                return;
            }
            //---------Åжϱ¾ÆÚ¼äÊÇ·ñÒѾ­¼ÆËã
            Ds = oCn.RunProcReturn("select * from Pay_SumBalBillMain  where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text, "Pay_SumBalBillMain", ref DBUtility.ClsPub.sErrInfo);
            if (Ds == null)
            {
                MessageBox.Show("ÅжÏÊÇ·ñÒÑÉú³É³ö´í£º" + DBUtility.ClsPub.sErrInfo);
                return;
            }
            if (Ds.Tables[0].Rows.Count != 0)
            {
                if (MessageBox.Show("±¾»á¼ÆÆÚ¼äÒÑÉú³É£¬ÊÇ·ñ¸²¸Ç£¿", "Ìáʾ", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    oCn.RunProc("delete Pay_SumBalBillMain  where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text);
                }
                else
                {
                    return;
                }
            }
            //---------------------¼ÆËã
            Ds = oCn.RunProcReturn("exec h_p_Pay_SumBalBill_JS " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SumBalBill_JS", ref DBUtility.ClsPub.sErrInfo);
            if (Ds == null)
            {
                MessageBox.Show("¼ÆËã³ö´í£º" + DBUtility.ClsPub.sErrInfo);
                return;
            }
            if (Ds.Tables[0].Rows.Count == 0)
            {
                return;
            }
            //-------------------------------------------
            long HGroupID = -1;
            for (int i = 0; i <= Ds.Tables[0].Rows.Count - 1; i++)
            {
                if (HGroupID != DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]))
                {
                    if (HGroupID != -1)
                    {
                        BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                    }
                    BillNew.omodel.HYear = DBUtility.ClsPub.isLong(cmbHYear.Text);
                    BillNew.omodel.HPeriod = DBUtility.ClsPub.isLong(cmbHPeriod.Text);
                    //¹Ì¶¨¸³Öµ=================================
                    BillNew.omodel.HBillNo = DBUtility.ClsPub.CreateBillCode(BillNew.BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//µÃµ½Ðµ¥ºÅ 
                    BillNew.omodel.HDate = DBUtility.ClsPub.isDate(cmbHYear.Text + "-" + cmbHPeriod.Text+"-01");
                    BillNew.omodel.HRemark = "";
                    //====================================================
                    BillNew.omodel.HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]);
                    BillNew.omodel.HDeptID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HDeptID"]);
                    BillNew.omodel.HEmpID = 0;
                    BillNew.omodel.HPayType = 0;
                    BillNew.omodel.HExplanation = "";
                    BillNew.omodel.HInnerBillNo = "";
                    BillNew.omodel.HSaveFlag = true;
                    //Ã÷ϸÀำֵ
                    BillNew.DetailColl = new List<Model.ClsPay_SumBalBillSub>();
 
                    HGroupID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HGroupID"]);
 
                }
                Model.ClsPay_SumBalBillSub oSub = new Model.ClsPay_SumBalBillSub();
                //¹Ì¶¨¸³Öµ========================================
                oSub.HEntryID = i + 1;
                oSub.HRemark ="";
                oSub.HSourceInterID = 0;
                oSub.HSourceEntryID = 0;
                oSub.HSourceBillType = "";
                oSub.HSourceBillNo = "";
                oSub.HRelationQty = 0;
                oSub.HRelationMoney = 0;
                oSub.HCloseMan = "";
                oSub.HEntryCloseDate = DBUtility.ClsPub.isDate("1900-01-01");
                oSub.HCloseType = false;
                //=============================
                oSub.HMaterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HMaterID"]);
                oSub.HProcID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HProcID"]);
                oSub.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]);
                oSub.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HQty"]);
                oSub.HTimes = 0;
                oSub.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]);
                oSub.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HMoney"]);
                oSub.HReportQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HReportQty"]);
                oSub.HSumReportQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSumReportQty"]);
                oSub.HSumStockQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HSumStockQty"]);
                oSub.HEmpRate = DBUtility.ClsPub.isSingle(Ds.Tables[0].Rows[i]["HEmpRate"]);
 
 
                oSub.HICMOInterID = 0;
                oSub.HProcReportInterID = 0;
                oSub.HProcReportEntryID = 0;
                oSub.HProcPlanEntryID = 0;
                oSub.HProcPlanInterID = 0;
                oSub.HICMOBillNo = "";
                oSub.HProcReportBillNo = "";
                oSub.HProcPlanBillNo = "";
                BillNew.DetailColl.Add(oSub);
 
                if (i == Ds.Tables[0].Rows.Count-1)
                {
                    BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                }
            }
            //bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
            //if (bResult == false)
            //{
            //    MessageBox.Show("±£´æÊ§°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ"); 
            //    return;
            //}
            MessageBox.Show("¼ÆËãÍê±Ï£¡");
            this.Close();
        }
    }
}