Esempio n. 1
0
        public bool IsClosed(int year, ref double endBal, ItemOfBank item)
        {
            YearClosed y = GetYearClosed(year, item);

            endBal = y.EndBal;
            return(y.Closed);
        }
Esempio n. 2
0
        void UnCloseYear()
        {
            int i = dataGridView1.SelectedCells[0].RowIndex;
            int y = 0;

            if (int.TryParse(dataGridView1[1, i].Value.ToString(), out y))
            {
                if (MessageBox.Show(this, "您确定要反结账到[" + y.ToString() + "]年吗?", "取消结账", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    for (int j = dataGridView1.Rows.Count - 1; j >= i; j--)
                    {
                        YearClosed yc = (dataGridView1.Rows[j].Tag as YearClosed);
                        if (yc.Closed)
                        {
                            if (_dp.DeleteRecord(DataProvider.TABLE_ACCOUNTYEARCLOSED, "FYear=" + yc.Year))
                            {
                                dataGridView1[2, j].Value = "";
                                dataGridView1[3, j].Value = "";
                                dataGridView1[0, j].Value = "";
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
 void InitYearClosedList()
 {
     for (int i = _e.CurrentAccount.StartYear; i <= DateTime.Today.Year; i++)
     {
         YearClosed yc = _dp.GetYearClosed(i);
         int        r  = dataGridView1.Rows.Add();
         dataGridView1[0, r].Value = yc.Closed  ? Core.Printer.PrintAssign.OK_FLAG : "";
         dataGridView1[1, r].Value = i.ToString();
         dataGridView1[2, r].Value = yc.Closed ? yc.CloseDate.ToLongDateString() : "";
         dataGridView1.Rows[r].Tag = yc;
     }
 }
Esempio n. 4
0
        void CloseYear()
        {
            int i = dataGridView1.SelectedCells[0].RowIndex;
            int y = 0;

            if (int.TryParse(dataGridView1[1, i].Value.ToString(), out y))
            {
                if (MessageBox.Show(this, "您确定要对[" + y.ToString() + "]年进行结账吗?", "结账", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    this.Cursor = Cursors.WaitCursor;
                    int startRow = 0;
                    for (int j = 0; j <= i; j++)
                    {
                        YearClosed yc = (dataGridView1.Rows[j].Tag  as YearClosed);
                        if (!yc.Closed)
                        {
                            startRow = j;
                            break;
                        }
                    }
                    for (int j = startRow; j <= i; j++)
                    {
                        YearClosed yc = (dataGridView1.Rows[j].Tag  as YearClosed);
                        dataGridView1[3, j].Value = "正在结账, 请稍等...";
                        bool b = _dp.SetYearClosed(yc.Year);
                        if (b)
                        {
                            yc.Closed = true;
                            dataGridView1[2, j].Value = DateTime.Today.ToLongDateString();
                            dataGridView1[3, j].Value = "";
                            dataGridView1[0, j].Value = Core.Printer.PrintAssign.OK_FLAG;
                        }
                        else
                        {
                            dataGridView1[3, j].Value = "结账失败!";
                            break;
                        }
                    }
                    this.Cursor = Cursors.Default;
                }
            }
        }
Esempio n. 5
0
        public YearClosed GetYearClosed(int year, ItemOfBank item)
        {
            YearClosed yc = new YearClosed();
            bool       b  = true;
            string     filterExpress;

            if (item != null)
            {
                filterExpress   = "item='" + item.ID + "' AND FYear=" + year;
                yc.ItemOfBankID = item.ID;
            }
            else
            {
                filterExpress   = "FYear=" + year;
                yc.ItemOfBankID = "";
            }
            yc.Year = year;
            DataRow[] drs = GetDataRows(TABLE_ACCOUNTYEARCLOSED, filterExpress, "");
            if (drs.Length > 0)
            {
                foreach (DataRow dr in drs)
                {
                    if (((int)dr["closed"]) == 0)
                    {
                        b = false;
                    }
                    yc.EndBal   += (double)dr["endbal"];
                    yc.StartBal += (double)dr["StartBal"];;
                    yc.CloseDate = Core.General.FromString(dr["closedDate"].ToString());
                }
            }
            else
            {
                b            = false;
                yc.CloseDate = Core.General.FromString("19721102");
            }
            yc.Closed = b;
            return(yc);
        }
Esempio n. 6
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);
        }