Beispiel #1
0
        protected override void WndProc(ref Message m)
        {
            try
            {
                switch (m.Msg)
                {
                case WM_COPYDATA:
                    DBUtils.DBBook dBBook = new DBUtils.DBBook();
                    dBBook.bookDataGridViewConnect(dataGridView1);
                    label5.Text = dBBook.getBookCount().ToString();
                    //COPYDATASTRUCT cds = (COPYDATASTRUCT)m.GetLParam(typeof(COPYDATASTRUCT));
                    //byte[] buff = System.Text.Encoding.Default.GetBytes(cds.lpData);

                    //COPYDATASTRUCT cs = new COPYDATASTRUCT();
                    //cs.dwData = new IntPtr(0);
                    //cs.cbData = buff.Length;
                    //cs.lpData = cds.lpData;

                    // 다시 보낼 Form2의 windows 헨들을 가져 온다.
                    //IntPtr hwnd = FindWindow(null, "Form2");
                    //SendMessage(hwnd, WM_COPYDATA, IntPtr.Zero, ref cs);
                    break;

                case WM_USERDATA:
                    DBUtils.DBUser dBUser = new DBUtils.DBUser();
                    dBUser.userDataGridViewConnect(dataGridView2);
                    int userCount = dBUser.getUserCount();
                    label6.Text = userCount.ToString();
                    break;

                default:
                    base.WndProc(ref m);
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        public Form1()
        {
            InitializeComponent();
            Text = "도서관 관리";

            DBUtils.DBUser dBUser = new DBUtils.DBUser();
            DBUtils.DBBook dBBook = new DBUtils.DBBook();

            // 라벨 설정
            //label5.Text = DataManager.Books.Count.ToString();
            label5.Text = dBBook.getBookCount().ToString();
            label6.Text = dBUser.getUserCount().ToString();
            label7.Text = DataManager.Books.Where((x) => x.isBorrowed).Count().ToString();
            label8.Text = DataManager.Books.Where((x) =>
            {
                return(x.isBorrowed && x.BorrowedAt.AddDays(7) > DateTime.Now);
            }).Count().ToString();

            // 데이터 그리드 설정
            //dataGridView1.DataSource = DataManager.Books;
            dBBook.bookDataGridViewConnect(dataGridView1);
            dataGridView1.ReadOnly = true;

            //dataGridView2.DataSource = DataManager.Users;
            dBUser.userDataGridViewConnect(dataGridView2);
            dataGridView2.ReadOnly = true;

            dataGridView1.CurrentCellChanged += DataGridView1_CurrentCellChanged;
            dataGridView2.CurrentCellChanged += DataGridView2_CurrentCellChanged;

            // 버튼 이벤트 설정
            //button1.Click += Button1_Click;
            button1.Click += borrowButtonClick;
            //button2.Click += Button2_Click;
            button2.Click += returnBook;

            // 대여 및 반납기록 클릭 이벤트
            대여및반납기록ToolStripMenuItem.Click += ShowHistoryForm;
        }