示例#1
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            try
            {
                if (id != -1)
                {
                    var dausach = _context.DauSach.Where(i => i.ID.Equals(id)).FirstOrDefault();
                    dausach.Ten          = txt_name.Text;
                    dausach.TheLoaiID    = Convert.ToInt32(cbb_category.SelectedValue);
                    dausach.TacGiaID     = Convert.ToInt32(cbb_author.SelectedValue);
                    dausach.TomTat       = txt_summary.Text;
                    dausach.TaiBan       = Convert.ToInt32(txt_republish.Text);
                    dausach.NhaSanXuatID = Convert.ToInt32(cbb_producer.SelectedValue);
                    dausach.TinhTrang    = Convert.ToByte(cbb_state.SelectedValue);

                    _context.SaveChanges();


                    this.Close();
                    form_qlds = new QuanLyDauSach();
                    form_qlds.Refresh();
                    form_qlds.Refresh_DataGridView();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#2
0
        private void btn_add_Click(object sender, EventArgs e)
        {
            try
            {
                var dausach = new DauSach();
                dausach.Ten          = txt_name.Text;
                dausach.TheLoaiID    = Convert.ToInt32(cbb_category.SelectedValue);
                dausach.TacGiaID     = Convert.ToInt32(cbb_author.SelectedValue);
                dausach.TomTat       = txt_summary.Text;
                dausach.TaiBan       = Convert.ToInt32(txt_republish.Text);
                dausach.NhaSanXuatID = Convert.ToInt32(cbb_producer.SelectedValue);
                dausach.SoLuongTong  = Convert.ToInt32(txt_sumnumber.Text);
                dausach.TinhTrang    = Convert.ToByte(cbb_state.SelectedValue);

                _context.DauSach.Add(dausach);
                _context.SaveChanges();



                for (int i = 1; i <= Convert.ToInt32(txt_sumnumber.Text); i++)
                {
                    var cuonsach = new CuonSach();
                    cuonsach.MaVach    = "MV" + dausach.ID + i;
                    cuonsach.DauSachID = dausach.ID;
                    cuonsach.TinhTrang = 2;
                    _context.CuonSach.Add(cuonsach);
                }

                var phieunhap = new PhieuNhapDauSach();
                phieunhap.DauSachID       = dausach.ID;
                phieunhap.NgayNhap        = DateTime.Now;
                phieunhap.SoLuongCuonSach = dausach.SoLuongTong;

                _context.PhieuNhapDauSach.Add(phieunhap);

                _context.SaveChanges();


                txt_name.Text      = null;
                txt_republish.Text = null;
                txt_summary.Text   = null;
                txt_sumnumber.Text = null;
                form_qlds          = new QuanLyDauSach();
                form_qlds.Refresh();
                form_qlds.Refresh_DataGridView();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
示例#3
0
        private void btn_dausach_Click(object sender, EventArgs e)
        {
            QuanLyDauSach ql = new QuanLyDauSach();

            ql.Show();
        }