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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
 
namespace BaseSet
{
    public partial class Gy_DataIn_HouseNo1 :BLL.Gy_DataInTmp
    {
        public Gy_DataIn_HouseNo1()
        {
            InitializeComponent();
        }
 
        public int HRoomIDCol = 2;            //Òµ»§ÄÚÂë
        public int HBeginDateCol = 6;         //¿ªÊ¼ÈÕÆÚ
        public int HEndDateCol = 6;           //½áÊøÈÕÆÚ
        public int HItMoneyIDCol = 8;         //·ÑÓÃÏîÄ¿
        public int HQtyCol = 22;              //ÊýÁ¿
        public int HPriceCol = 12;            //µ¥¼Û
        public int HMoneyCol = 19;            //½ð¶î
        public int HBeginBalanceCol = 20;     //¿ªÊ¼ÊýÖµ
        public int HEndBalanceCol = 21;       //½áÊøÊýÖµ
        //
        public const int HBeginRow = 0;         //ÓÐЧÊý¾Ý£¬¿ªÊ¼ÐÐÊý
        //
        public DAL.ClsCB_ItemMoneyBill_Tmp oBill = new DAL.ClsCB_ItemMoneyBill_Tmp();
        public DAL.ClsGy_ItemMoney_View oItemMoney = new DAL.ClsGy_ItemMoney_View();
        public DAL.ClsGy_Room_View oRoom = new DAL.ClsGy_Room_View();
 
        /// <summary>
        ///  ³õʼ»¯½çÃæ
        /// </summary>
        public override void initData()
        {
            base.initData();
            base.sSheetName = "Sheet1"; 
            base.ModRightName = "Gy_DataIn_HouseNo1";
            base.ModRightNameCheck = base.ModRightName + base.ModRightNameCheck;
            base.ModRightNameClose = base.ModRightName + base.ModRightNameClose;
            base.ModRightNameDelete = base.ModRightName + base.ModRightNameDelete;
            base.ModRightNameEdit = base.ModRightName + base.ModRightNameEdit;
            base.ModRightNameMoney = base.ModRightName + base.ModRightNameMoney;
            base.ModRightNameQty = base.ModRightName + base.ModRightNameQty;
            base.ModCaption = "¿Õµ÷1ºÅÂ¥µ¼Èë";
            this.Text = base.ModCaption;
            lblCaption.Text = base.ModCaption;
            //
            DBUtility.Gy_BaseFun.SetComboxYear(cmbHYear);
            DBUtility.Gy_BaseFun.SetComboxPeriod(cmbHPeriod);
            //
        }
 
        public override void Sub_DataIn()
        {
            //base.Sub_DataIn();
            //
            bool b = false;
            //ɾ³ý Ïàͬ»á¼ÆÆÚ¼ä£¬Ïàͬ·ÑÓÃÏîÄ¿£¬µÄËùÓмǼ 
            if (oBill.DeleteBill(0, DBUtility.ClsPub.isLong(cmbHYear.Text), DBUtility.ClsPub.isLong(cmbHPeriod.Text), "air1", ref DBUtility.ClsPub.sExeReturnInfo))
            {
                b = true;
            }
            for (int i = HBeginRow; i <= grdMain.Rows.Count - 1; i++)
            {
                if (DBUtility.ClsPub.isStrNull(grdMain.Rows[i].Cells[HRoomIDCol].Value) != "")
                {
                    //дÈëÀà
                    if (WriteClass(i))
                    {
                        
                        //±£´æ¼Ç¼
                        if (!oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo))
                        {
                            MessageBox.Show("µ¼Èëʧ°Ü!Ô­Òò:" + DBUtility.ClsPub.sExeReturnInfo, "Ìáʾ");
                            return;
                        }
                    }
                }
            }
            MessageBox.Show("µ¼ÈëÍê±Ï");
            grdMain.DataSource = null;
        }
 
        //дÈëÀ࠴ӿؼþ
        private bool WriteClass(int row)
        {
            //ÅжÏÊÇ·ñÔÊÐí ±£´æ
            //µÃµ½Òµ»§ÄÚÂ룬·ÑÓÃÏîÄ¿ÄÚÂë
            string sDate;
            string sItemMoneyName = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HItMoneyIDCol].Value);
            string sHRoomName = "1." + DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HRoomIDCol].Value);
 
            //µÃµ½·ÑÓÃÏîÄ¿ÄÚÂë
            if (oItemMoney.GetInfoByName(sItemMoneyName))
            {
                oBill.omodel.HItMoneyID = oItemMoney.omodel.HItemID;
            }
            else
            {
                oBill.omodel.HItMoneyID = 0;
            }
 
            //µÃµ½Òµ»§ÄÚÂë
            if (oRoom.GetInfoByNumber(sHRoomName))
            {
                oBill.omodel.HRoomID = oRoom.omodel.HItemID;
            }
            else
            {
                oBill.omodel.HRoomID = 0;
                MessageBox.Show("µÚ" + row.ToString() + "ÐÐ," + sHRoomName + "ûÓÐÕÒµ½¶ÔÓ¦µÄÒµ»§£¡");
                return false;
            }
 
            sDate = DBUtility.ClsPub.isStrNull(grdMain.Rows[row].Cells[HBeginDateCol].Value);
            char c = Convert.ToChar("¡ª");
            string[] sr;
            sr = sDate.Split(c);
            //дÈëÐÅÏ¢
            oBill.omodel.HYear = DBUtility.ClsPub.isLong(cmbHYear.Text);
            oBill.omodel.HPeriod = DBUtility.ClsPub.isLong(cmbHPeriod.Text);
            oBill.omodel.HBeginDate = DBUtility.ClsPub.isDate(sr[0].ToString());
            oBill.omodel.HEndDate = DBUtility.ClsPub.isDate(sr[1].ToString());
            oBill.omodel.HDate = DBUtility.ClsPub.isDate(grdMain.Rows[row].Cells[HEndDateCol].Value);
            oBill.omodel.HQty = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HQtyCol].Value);
            oBill.omodel.HPrice = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HPriceCol].Value);
            oBill.omodel.HMoney = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HMoneyCol].Value);
            oBill.omodel.HWaster = 0;
            oBill.omodel.HBeginBalance = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HBeginBalanceCol].Value);
            oBill.omodel.HEndBalance = DBUtility.ClsPub.isDoule(grdMain.Rows[row].Cells[HEndBalanceCol].Value);
            oBill.omodel.HTimes = 0;
            oBill.omodel.HRelationQty = 0;
            oBill.omodel.HRelationMoney = 0;
            oBill.omodel.HRemark = "";
            oBill.omodel.HExplanation = "";
 
            oBill.omodel.HBillSubType = "air1";
            return true;
        }
 
 
 
    }
}