zrg
2024-03-04 c07bb60b39a9fbf5c41a724c7060f45c821f93ff
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
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_SingleBalBill_YR : Form
    {
        public Pay_SingleBalBill_YR()
        {
            InitializeComponent();
        }
 
        public DAL.ClsPay_SingleBalBill BillNew = new DAL.ClsPay_SingleBalBill();   //¶ÔÓ¦µ¥¾ÝÀà
        private void Pay_SingleBalBill_YR_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 button1_Click(object sender, EventArgs e)
        {
            SQLHelper.ClsCN oCn=new SQLHelper.ClsCN();
            DataSet Ds;
            Ds = oCn.RunProcReturn("select * from xt_AccountPeriod where HYear="+cmbHYear.Text+" and HPeriod="+cmbHPeriod.Text+" and HEndFlag=0", "xt_AccountPeriod",ref DBUtility.ClsPub.sErrInfo);
            if (Ds == null)
            {
                MessageBox.Show("»ñÈ¡»á¼ÆÆÚ¼ä³ö´í£º"+DBUtility.ClsPub.sErrInfo);
                return;
            }
            if (Ds.Tables[0].Rows.Count == 0)
            {
                MessageBox.Show("±¾»á¼ÆÆÚ¼äÒѽáÕË£¬²»ÔÊÐíÒýÈ룡"  );
                return;
            }
 
            Ds = oCn.RunProcReturn("select * from Pay_SingleBalBillMain  where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text, "Pay_SingleBalBillMain", 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_SingleBalBillMain  where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text);
                }
                else
                {
                    return;
                }
            }
            Ds = oCn.RunProcReturn("exec h_p_Pay_SingleBalBill_YR " + cmbHYear.Text + "," + cmbHPeriod.Text, "h_p_Pay_SingleBalBill_YR");
            for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
            {
                if (DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]) == 0)
                {
                    MessageBox.Show("ÎïÁÏ´úÂ룺" + Ds.Tables[0].Rows[i]["HMaterNumber"].ToString() + "£¬¹¤Ðò£º" + Ds.Tables[0].Rows[i]["HProcName"].ToString() + " ¹¤¼ÛΪ0£¬²»ÔÊÐíÒýÈ룡");
                    return;
                }
            }
            bool bResult;
            for (int i = 0; i < Ds.Tables[0].Rows.Count; i++)
            {
                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 = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]);
                BillNew.omodel.HPayType = 0;
                BillNew.omodel.HExplanation = "";
                BillNew.omodel.HInnerBillNo = "";
                BillNew.omodel.HSaveFlag = true;
                //Ã÷ϸÀำֵ
                BillNew.DetailColl = new List<Model.ClsPay_SingleBalBillSub>();
 
                Model.ClsPay_SingleBalBillSub oSub = new Model.ClsPay_SingleBalBillSub();
                //¹Ì¶¨¸³Öµ========================================
                oSub.HEntryID = 1;
                oSub.HRemark = "";
                oSub.HSourceInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HInterID"]);
                oSub.HSourceEntryID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEntryID"]);
                oSub.HSourceBillType = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillType"]);
                oSub.HSourceBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HBillNo"]);
                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.HSourceID = 0;
                oSub.HEmpID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HEmpID"]);
                oSub.HTimes = 0;
                oSub.HQty = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HQty"]);
                oSub.HPrice = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HPrice"]);
                oSub.HPriceRate = 1;
 
                oSub.HSubsidyTotal = 0;
                oSub.HDeuctTotal = 0;
                //
                oSub.HSubsidyID = 0;
                oSub.HDeuctID = 0;
 
                oSub.HMoney = DBUtility.ClsPub.isDoule(Ds.Tables[0].Rows[i]["HMoney"]);
                oSub.HICMOInterID = DBUtility.ClsPub.isLong(Ds.Tables[0].Rows[i]["HICMOInterID"]);
                oSub.HICMOBillNo = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[i]["HICMOBillNo"]);
                oSub.HProcReportInterID = 0;
                oSub.HProcReportEntryID = 0;
                oSub.HProcReportBillNo = "";
                oSub.HProcPlanInterID = 0;
                oSub.HProcPlanEntryID = 0;
                oSub.HProcPlanBillNo = "";
                oSub.HPackQty = 0;
                oSub.HPackPrice = 0;
                oSub.HPackMoney = 0;
                oSub.HPackMaterID = 0;
                oSub.HSubsidyQty = 0;
                oSub.HSubsidyMoney = 0;
                oSub.HSqty = 0;
                BillNew.DetailColl.Add(oSub);
 
                bResult = BillNew.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                if(bResult==false)
                {
                    MessageBox.Show("±£´æÊ§°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                    oCn.RunProc("delete Pay_SingleBalBillMain  where HSaveFlag=1 and HYear=" + cmbHYear.Text + " and HPeriod=" + cmbHPeriod.Text);
                    return;
                }
            }
            MessageBox.Show("ÒýÈëÍê±Ï£¡");
            this.Close();
        }
 
        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}