예제 #1
0
        private void MenuOpen_Click(object sender, EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Stream fileStream = openFileDialog.OpenFile();
                    MyIncome.Clear();
                    MyPayments.Clear();

                    if (fileStream != null)
                    {
                        BinaryReader br = new BinaryReader(fileStream);
                        FileName = openFileDialog.FileName;
                        int count = br.ReadInt32();
                        for (int i = 0; i < count; i++)
                        {
                            My_Income MyIn = new My_Income();
                            MyIn.date   = UnixTimestampToDateTime(br.ReadInt64());
                            MyIn.income = br.ReadDouble();
                            MyIncome.Add(MyIn);
                        }

                        /*count = br.ReadInt32();
                         * for (int i = 0; i < count; i++)
                         * {
                         *  My_Payments MyPay = new My_Payments();
                         *  MyPay.date = UnixTimestampToDateTime(br.ReadInt64());
                         *  MyPay.amount = br.ReadDouble();
                         *  MyPayments.Add(MyPay);
                         * }*/
                        br.Close();

                        BindingSource IncomeSource = new BindingSource(MyIncome, null);
                        IncomeGridView.DataSource = IncomeSource;
                        BindingSource PaymentsSource = new BindingSource(MyPayments, null);
                        PayGridView.DataSource = PaymentsSource;
                    }
                    fileStream.Close();
                    StatusLabel.Text = "База загружена";
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = "Ошибка";
                    MessageBox.Show("Error: Could not read file from disk. Original error: " + ex.Message);
                }
            }
            else
            {
                StatusLabel.Text = "Загрузка отменена";
            }
        }
예제 #2
0
 static private int IncomeCompareTime(My_Income in1, My_Income in2)
 {
     return(in1.date.CompareTo(in2.date));
 }