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

            endBal = y.EndBal;
            return(y.Closed);
        }
Example #2
0
 public bool AppendItemOfBank(ItemOfBank item)
 {
     try
     {
         lock (_dataSet)
         {
             DataTable tb         = _dataSet.Tables[TABLE_ITEMOFBANKS];
             DataRow   r          = tb.NewRow();
             object[]  rItemArray = new object[r.ItemArray.Length];
             rItemArray[tb.Columns.IndexOf("nm")]         = item.Name;
             rItemArray[tb.Columns.IndexOf("id")]         = item.ID;
             rItemArray[tb.Columns.IndexOf("OfBankName")] = item.OfBankName;
             rItemArray[tb.Columns.IndexOf("Digest")]     = item.Description;
             rItemArray[tb.Columns.IndexOf("StartBal")]   = item.StartBal;
             r.ItemArray = rItemArray;
             tb.Rows.Add(r);
             tb.AcceptChanges();
             _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
         }
         return(true);
     }
     catch (Exception ex)
     {
         System.Windows.Forms.MessageBox.Show(ex.Message, "新增账户", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
         return(false);
     }
 }
Example #3
0
        public bool UpdateItemOfBank(string id, ItemOfBank item)
        {
            try
            {
                DataRow[] rs = GetDataRows(TABLE_ITEMOFBANKS, "id='" + id + "'", "id");

                lock (_dataSet)
                {
                    if (rs.Length > 0)
                    {
                        DataTable tb         = _dataSet.Tables[TABLE_ITEMOFBANKS];
                        DataRow   r          = rs[0];
                        object[]  rItemArray = new object[r.ItemArray.Length];
                        rItemArray[tb.Columns.IndexOf("nm")]         = item.Name;
                        rItemArray[tb.Columns.IndexOf("id")]         = item.ID;
                        rItemArray[tb.Columns.IndexOf("OfBankName")] = item.OfBankName;
                        rItemArray[tb.Columns.IndexOf("Digest")]     = item.Description;
                        rItemArray[tb.Columns.IndexOf("StartBal")]   = item.StartBal;
                        r.ItemArray = rItemArray;
                        tb.AcceptChanges();
                        _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "修改账户", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                return(false);
            }
        }
Example #4
0
        public bool UpdateEntry(Entry entry, ItemOfBank item)
        {
            DataRow[] rs = GetDataRows("id='" + item.ID + "' AND RecordDate" + "='" + entry.Date + "' AND entry=" + entry.ID, "id");

            lock (_dataSet)
            {
                if (rs.Length > 0)
                {
                    DataRow  r          = rs[0];
                    object[] rItemArray = new object[r.ItemArray.Length];
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("id")]         = item.ID;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("RecordDate")] = entry.Date;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("entry")]      = entry.ID;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Digest")]     = entry.Digest;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchType")]    = entry.VchType;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchNumber")]  = entry.VchNumber;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeType")] = entry.ChequeType;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeId")]   = entry.Cheque;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Side")]       = entry.Side;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Money")]      = entry.Money;
                    r.ItemArray = rItemArray;
                    _dataSet.Tables[TABLE_MAIN].AcceptChanges();
                    _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
                }
            }
            return(true);
        }
 void RenameByItemOfBank()
 {
     if (listView1.SelectedItems.Count > 0)
     {
         UIItemOfBankEditor ui   = new UIItemOfBankEditor();
         ListViewItem       item = listView1.SelectedItems[0];
         DataProvider       dp   = new DataProvider(_e.CurrentAccount.FullPath);
         ItemOfBank         it   = dp.GetItemOfBank(item.SubItems[1].Text);
         ui.CurrentItemOfBank = new ItemOfBank();
         it.CopyTo(ui.CurrentItemOfBank);
         ui.CurrentEnvironment = _e;
         if (ui.ShowDialog(this) == DialogResult.OK)
         {
             ui.CurrentItemOfBank.CopyTo(it);
             if (dp.UpdateItemOfBank(item.SubItems[1].Text, it))
             {
                 item.SubItems.Clear();
                 item.Text = it.Name;
                 item.SubItems.Add(it.ID);
                 item.SubItems.Add(it.OfBankName);
                 item.SubItems.Add(it.Description);
             }
         }
     }
 }
Example #6
0
        public ItemOfBank GetItemOfBank(string id)
        {
            DataRow[]  rows = GetDataRows(DataProvider.TABLE_ITEMOFBANKS, "id='" + id + "'", "nm");
            DataRow    row  = rows[0];
            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"]);
            return(item);
        }
 private void button1_Click(object sender, EventArgs e)
 {
     if (CurrentItemOfBank == null)
     {
         CurrentItemOfBank = new ItemOfBank();
     }
     CurrentItemOfBank.Name        = textBox1.Text;
     CurrentItemOfBank.ID          = textBox2.Text;
     CurrentItemOfBank.Description = textBox4.Text;
     CurrentItemOfBank.OfBankName  = comboBox1.Text;
     CurrentItemOfBank.StartBal    = double.Parse(cyEditor1.Text);
     this.DialogResult             = DialogResult.OK;
 }
Example #8
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);
        }
Example #9
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);
        }
Example #10
0
        /// <summary>
        /// 增加一个新的分录,返回该分录的id
        /// </summary>
        /// <param name="entry"></param>
        /// <returns></returns>
        public int StorgeEntry(Entry entry, ItemOfBank item)
        {
            DataRow[] rs = GetDataRows("id='" + item.ID + "' AND RecordDate" + "='" + entry.Date + "'", "entry" + " DESC");
            int       id = 0;

            if (rs.Length > 0)
            {
                id = int.Parse(rs[0].ItemArray[2].ToString()) + 1;
            }
            else
            {
                id = 1;
            }
            try
            {
                lock (_dataSet)
                {
                    DataRow  r          = _dataSet.Tables[TABLE_MAIN].NewRow();
                    object[] rItemArray = new object[r.ItemArray.Length];
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("id")]         = item.ID;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("RecordDate")] = entry.Date;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("entry")]      = id;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Digest")]     = entry.Digest;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchType")]    = entry.VchType;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchNumber")]  = entry.VchNumber;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeType")] = entry.ChequeType;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeId")]   = entry.Cheque;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Side")]       = entry.Side;
                    rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Money")]      = entry.Money;
                    r.ItemArray = rItemArray;
                    _dataSet.Tables[TABLE_MAIN].Rows.Add(r);
                    _dataSet.Tables[TABLE_MAIN].AcceptChanges();
                    _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
                }
                return(id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(0);
            }
        }
Example #11
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);
        }
        void AppendByItemOfBank()
        {
            UIItemOfBankEditor ui = new UIItemOfBankEditor();

            ui.CurrentEnvironment = _e;
            if (ui.ShowDialog(this) == DialogResult.OK)
            {
                ItemOfBank it = new ItemOfBank();
                ui.CurrentItemOfBank.CopyTo(it);
                DataProvider dp = new DataProvider(_e.CurrentAccount.FullPath);
                if (dp.AppendItemOfBank(it))
                {
                    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);
                }
            }
        }
Example #13
0
        /// <summary>
        /// 插入分录,以entry.ID的绝对值,所有ID>=abs(entry.ID)的都+1,该分录仍是加在文件最后.
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="item"></param>
        /// <returns></returns>
        public bool InsertEntry(Entry entry, ItemOfBank item)
        {
            int id = Math.Abs(entry.ID);

            DataRow[] rs = GetDataRows("id='" + item.ID + "' AND RecordDate='" + entry.Date + "' AND entry>=" + id, "entry DESC");

            lock (_dataSet)
            {
                //现存的分录号都加1;
                foreach (DataRow row in rs)
                {
                    object[] rowArray = new object[row.ItemArray.Length];
                    row.ItemArray.CopyTo(rowArray, 0);
                    rowArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("entry")] = ((int)row["entry"]) + 1;
                    row.ItemArray = rowArray;
                }
                //增加新的分录
                DataRow  r          = _dataSet.Tables[TABLE_MAIN].NewRow();
                object[] rItemArray = new object[r.ItemArray.Length];
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("id")]         = item.ID;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("RecordDate")] = entry.Date;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("entry")]      = id;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Digest")]     = entry.Digest;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchType")]    = entry.VchType;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("VchNumber")]  = entry.VchNumber;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeType")] = entry.ChequeType;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("ChequeId")]   = entry.Cheque;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Side")]       = entry.Side;
                rItemArray[_dataSet.Tables[TABLE_MAIN].Columns.IndexOf("Money")]      = entry.Money;
                r.ItemArray = rItemArray;
                _dataSet.Tables[TABLE_MAIN].Rows.Add(r);
                _dataSet.Tables[TABLE_MAIN].AcceptChanges();
                _dataSet.WriteXml(_fileName, XmlWriteMode.WriteSchema);
                entry.ID = id;
            }
            return(true);
        }
Example #14
0
        public bool IsClosed(int year, ItemOfBank item)
        {
            double endBal = 0;

            return(IsClosed(year, ref endBal, item));
        }
Example #15
0
 public bool RemoveEntry(Entry entry, ItemOfBank item)
 {
     return(DeleteRecord("id='" + item.ID + "' AND RecordDate" + "='" + entry.Date + "' AND entry=" + entry.ID));
 }