コード例 #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!frmValidateSucceed())
            {
                return;
            }

            var librarian = new Librarian
            {
                Name    = txtName.Text,
                Phone   = txtPhone.Text,
                Address = txtAddress.Text,
                Photo   = LibraryModule.ImageToByteArray(picLibrarian.Image)
            };

            var id = LibrarianApi.AddNewLibrarian(librarian);

            if (id != 0)
            {
                pnIdGenerated.Visible = true;
                btnSave.Enabled       = false;
                btnReset.Enabled      = false;
                btnNew.Enabled        = true;
                txtName.Enabled       = false;
                txtPhone.Enabled      = false;
                txtAddress.Enabled    = false;
                picLibrarian.Enabled  = false;
            }
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: TVYDev/CSharpLibraryMS
        private void StylingForm()
        {
            FormBorderStyle = FormBorderStyle.None;

            Width  = Screen.PrimaryScreen.WorkingArea.Width;
            Height = Screen.PrimaryScreen.WorkingArea.Height;

            pnDisplay.BackColor = this.BackColor;

            LibraryModule.makePictureBoxRound(picAccount);
        }
コード例 #3
0
 private void frmClear()
 {
     txtName.Clear();
     txtPhone.Clear();
     txtAddress.Clear();
     picLibrarian.Image    = Properties.Resources.Cover;
     picLibrarian.Width    = picLibrarian.Height = 100;
     picLibrarian.Location = new Point(92, 145);
     picLibrarian.SizeMode = PictureBoxSizeMode.CenterImage;
     LibraryModule.makePictureBoxRound(picLibrarian);
     btnBrowse.Visible     = true;
     recRoundPic.Visible   = true;
     pnIdGenerated.Visible = false;
 }
コード例 #4
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            OpenFileDialog fileDialog = new OpenFileDialog();

            fileDialog.Filter = "JPEG|*.jpg;*.jpeg|PNG|*.png";
            fileDialog.ShowDialog();
            if (!string.IsNullOrEmpty(fileDialog.FileName))
            {
                picLibrarian.Image    = Image.FromFile(fileDialog.FileName);
                picLibrarian.Width    = picLibrarian.Height = 185;
                picLibrarian.Location = new Point(48, 119);
                picLibrarian.SizeMode = PictureBoxSizeMode.Zoom;
                LibraryModule.makePictureBoxRound(picLibrarian);
                btnBrowse.Visible   = false;
                recRoundPic.Visible = false;
            }
        }
コード例 #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!frmValidateSucceed())
            {
                return;
            }

            int coverId;

            if (picCover.Image != null)
            {
                coverId = CoverApi.AddNewCover(LibraryModule.ImageToByteArray(picCover.Image));
            }
            else
            {
                coverId = -1;
            }

            var book = new Book
            {
                Title       = txtTitle.Text,
                AuthorName  = txtAuthor.Text,
                Isbn        = txtIsbn.Text,
                YearEdition = Convert.ToInt32(txtYearEdition.Text),
                CoverId     = coverId
            };

            int qty = (int)numQty.Value;

            var ids = BookApi.AddNewBook(book, qty);

            if (ids.Count > 0)
            {
                pnIdGenerated.Visible  = true;
                btnSave.Enabled        = false;
                btnReset.Enabled       = false;
                btnNew.Enabled         = true;
                txtTitle.Enabled       = false;
                txtAuthor.Enabled      = false;
                txtIsbn.Enabled        = false;
                txtYearEdition.Enabled = false;
                numQty.Enabled         = false;
                picCover.Enabled       = false;
            }
        }