Ejemplo n.º 1
0
        public ItemOfBankCollection GetItemOfBankList()
        {
            ItemOfBankCollection items = new ItemOfBankCollection();

            DataRow[] rows = GetDataRows(DataProvider.TABLE_ITEMOFBANKS, "", "nm");
            foreach (DataRow row in rows)
            {
                ItemOfBank item = new ItemOfBank();
                item.Name        = row["nm"].ToString();
                item.ID          = row["id"].ToString();
                item.OfBankName  = row["OfBankName"].ToString();
                item.Description = row["Digest"].ToString();
                item.StartBal    = row["StartBal"].ToString() == "" ? 0 : ((double)row["StartBal"]);
                items.Add(item);
            }
            return(items);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 这里未使用余额表中的记录
        /// </summary>
        /// <param name="d"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public double GetStartBal(DateTime d, ItemOfBank item)
        {
            string filterExpress = "";

            if (item == null)
            {
                filterExpress = "RecordDate" + "<'" + Core.General.FromDateTime(d) + "'";
            }
            else
            {
                filterExpress = "id='" + item.ID + "' AND RecordDate" + "<'" + Core.General.FromDateTime(d) + "'";
            }
            int    startYear = int.Parse(GetConfig(CONFIG_STARTDATE));
            double bal       = 0;

            if (item == null)
            {
                ItemOfBankCollection items = GetItemOfBankList();
                foreach (ItemOfBank it in items)
                {
                    bal += it.StartBal;
                }
            }
            else
            {
                bal = item.StartBal;
            }
            DataRow[] drs = GetDataRows(filterExpress, "RecordDate");
            if (drs != null)
            {
                foreach (DataRow dr in drs)
                {
                    if (((int)dr["Side"]) == 1)
                    {
                        bal = bal + (double)dr["money"];
                    }
                    else
                    {
                        bal = bal - (double)dr["money"];
                    }
                }
            }
            return(bal);
        }
Ejemplo n.º 3
0
        void InitStyleByItemOfBank()
        {
            ColumnHeader[] ch = new ColumnHeader[4];
            int            i  = 0;

            ch[i]       = new ColumnHeader();
            ch[i].Width = 120;
            ch[i].Text  = "名称";
            i++;
            ch[i]       = new ColumnHeader();
            ch[i].Width = 150;
            ch[i].Text  = "账号";
            i++;
            ch[i]       = new ColumnHeader();
            ch[i].Width = 120;
            ch[i].Text  = "银行名称";
            i++;
            ch[i]       = new ColumnHeader();
            ch[i].Width = 300;
            ch[i].Text  = "描述";
            i++;
            this.listView1.Columns.AddRange(ch);
            DataProvider         dp    = new DataProvider(_e.CurrentAccount.FullPath);
            ItemOfBankCollection items = dp.GetItemOfBankList();

            foreach (ItemOfBank it in items)
            {
                ListViewItem item = new ListViewItem();
                item.Text     = it.Name;
                item.ImageKey = "itemOfBank";
                item.SubItems.Add(it.ID);
                item.SubItems.Add(it.OfBankName);
                item.SubItems.Add(it.Description);
                listView1.Items.Add(item);
            }
        }
Ejemplo n.º 4
0
        public bool SetYearClosed(int year)
        {
            ItemOfBankCollection items = GetItemOfBankList();
            DateTime             start = Core.General.FromString(GetConfig(CONFIG_STARTDATE) + "0101");

            foreach (ItemOfBank item in items)
            {
                YearClosed yc = new YearClosed();
                yc.Year         = year;
                yc.ItemOfBankID = item.ID;
                yc.CloseDate    = DateTime.Today;
                yc.Closed       = true;
                if (year > start.Year)
                {
                    YearClosed pre = GetYearClosed(year - 1, item);
                    yc.StartBal = pre.EndBal;
                }
                else
                {
                    yc.StartBal = item.StartBal;
                }
                ///
                ///开始计算余额01-01~12-31
                ///
                string filterExpress = "";
                filterExpress = "id='" + item.ID + "' AND (RecordDate >='" + year + "0101' AND RecordDate <='" + year + "1231')";
                double    bal = yc.StartBal;
                DataRow[] drs = GetDataRows(filterExpress, "RecordDate");
                if (drs != null)
                {
                    foreach (DataRow dr in drs)
                    {
                        if (((int)dr["Side"]) == 1)
                        {
                            bal = bal + (double)dr["money"];
                        }
                        else
                        {
                            bal = bal - (double)dr["money"];
                        }
                    }
                }
                yc.EndBal = bal;
                ///
                ///写余额
                ///
                DataRow[] rs = GetDataRows(TABLE_ACCOUNTYEARCLOSED, "Item='" + item.ID + "' AND FYear=" + yc.Year, "");
                try
                {
                    lock (_dataSet)
                    {
                        DataRow r;
                        if (rs.Length > 0)
                        {
                            r = rs[0];
                        }
                        else
                        {
                            r = _dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].NewRow();
                        }
                        object[] rItemArray = new object[r.ItemArray.Length];
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("item")]       = yc.ItemOfBankID;
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("FYear")]      = yc.Year;
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("StartBal")]   = yc.StartBal;
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("EndBal")]     = yc.EndBal;
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("ClosedDate")] = Core.General.FromDateTime(yc.CloseDate);
                        rItemArray[_dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Columns.IndexOf("Closed")]     = yc.Closed ? 1 : 0;
                        r.ItemArray = rItemArray;
                        if (rs.Length <= 0)
                        {
                            _dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].Rows.Add(r);
                        }
                        _dataSet.Tables[TABLE_ACCOUNTYEARCLOSED].AcceptChanges();
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message, "结账错误", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                    return(false);
                }
            }
            _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
            return(true);
        }