public static bool edit(NhaXuatBan nhaxuatban)
 {
     try
     {
         using(EntitiesDataContext db = new EntitiesDataContext())
         {
             NXB nxb;
             nxb = (from n in db.NXBs
                    where n.masonxb.Equals(nhaxuatban.MaSoNXB)
                    select n).SingleOrDefault();
             if (nxb == null) return false;
             nxb.ten = nhaxuatban.TenNXB;
             nxb.diachi = nhaxuatban.DiaChi;
             nxb.sodienthoai = nhaxuatban.SoDienThoai;
             nxb.sotaikhoan = nhaxuatban.SoTaiKhoan;
             nxb.trangthai = nhaxuatban.TrangThai;
             nxb.nganhang = nhaxuatban.NganHang;
             db.SubmitChanges();
             return true;
         }
     }catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
         return false;
     }
 }
        //Khi Chọn Thêm
        private void btnThem_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Bạn có muốn thêm nhà xuất bản", "Thông báo", MessageBoxButtons.YesNo);
            if (dialogResult == DialogResult.Yes)
            {
                if (!txbTenNXB.Text.Equals("") && !txbDiaChi.Text.Equals("") && !txbSoDienThoai.Text.Equals("") && !txbSoTaiKhoan.Text.Equals(""))
                {
                    NhaXuatBan nxb = new NhaXuatBan();
                    nxb.TenNXB = txbTenNXB.Text.ToString();
                    nxb.DiaChi = txbDiaChi.Text.ToString();
                    nxb.SoDienThoai = txbSoDienThoai.Text.ToString();
                    nxb.SoTaiKhoan = txbSoTaiKhoan.Text.ToString();
                    nxb.NganHang = txbNganHang.Text.ToString();

                    if (NhaXuatBanManager.add(nxb) != 0)
                        MessageBox.Show("Đã thêm nhà xuất bản thành công");
                    else
                        MessageBox.Show("Không thêm được");

                }
                else
                    MessageBox.Show("Bạn cần nhập đầy đủ thuông tin");
            }
            else if (dialogResult == DialogResult.No)
            {
                return;
            }
        }
 public ActionResult Create(NhaXuatBan model, FormCollection collection)
 {
     try
     {
         // TODO: Add insert logic here
         if (ModelState.IsValid)
         {
             var result = NhaXuatBanManager.add(model);
             if (result != 0)
             {
                 putSuccessMessage("Thêm thành công");
                 return RedirectToAction("Details", new { id = result });
             }
             else
             {
                 putErrorMessage("Thêm không thành công");
             }
         }
         else
         {
             putModelStateFailErrors(ModelState);
         }
         setAlertMessage();
         return View(model);
     }
     catch(Exception ex)
     {
         putErrorMessage(ex.Message);
         return RedirectToAction("Create");
     }
 }
 public void selectNXB(NhaXuatBan nxb)
 {
     if(nxb != null)
     {
         lbMaSoNXB.Text = nxb.MaSoNXB.ToString();
         lbTenNXB.Text = nxb.TenNXB;
         lbTienSachNXB.Text = String.Format(_cultureInfo, "{0:c}", nxb.TongTienNhapTheoThang);
         lbConNoNXB.Text = String.Format(_cultureInfo, "{0:c}", nxb.TongTienNoThang);
         lbDaChiNXB.Text = String.Format(_cultureInfo, "{0:c}", nxb.TongTienNhapTheoThang - nxb.TongTienNoThang);
     }
 }
 public void selectNXB(NhaXuatBan nxb)
 {
     if(nxb != null)
     {
         txbMaSoNXB.Text = nxb.MaSoNXB.ToString();
         txbTenNXB.Text = nxb.TenNXB;
         txbDiaChi.Text = nxb.DiaChi;
         txbSoDienThoai.Text = nxb.SoDienThoai;
         txbSoTaiKhoan.Text = nxb.SoTaiKhoan;
         txbNganHang.Text = nxb.NganHang;
     }
 }
 public static int add(NhaXuatBan nhaxuatban)
 {
     try
     {
         using(EntitiesDataContext db = new EntitiesDataContext())
         {
             var nxb = new NXB
             {
                 ten = nhaxuatban.TenNXB,
                 diachi = nhaxuatban.DiaChi,
                 sodienthoai = nhaxuatban.SoDienThoai,
                 sotaikhoan = nhaxuatban.SoTaiKhoan,
                 nganhang = nhaxuatban.NganHang
             };
             db.NXBs.InsertOnSubmit(nxb);
             db.SubmitChanges();
             return nxb.masonxb;
         }
     }catch(Exception ex)
     {
         Console.WriteLine(ex.Message);
         return 0;
     }
 }
 public PhieuNhap(PHIEUNHAP phieu, NXB nxb)
     : this(phieu)
 {
     NXB = new NhaXuatBan(nxb);
 }
 private void cmbNXB_SelectionChangeCommitted(object sender, EventArgs e)
 {
     _currentNXB = NhaXuatBanManager.find(int.Parse(cmbNXB.SelectedValue.ToString()));
     txbMaSoNXB.Text = _currentNXB.MaSoNXB + "";
     loadSach();
     cmbNXB.Enabled = false;
 }
 public frmThanhToanNXB(Form parent, NhaXuatBan nxb)
     : this(parent)
 {
     _currentNXB = nxb;
 }
 public HoaDonNXB(HOADONNXB hoadon, NXB nxb)
     : this(hoadon)
 {
     NXB = new NhaXuatBan(nxb);
 }
 public CongNoNXB(CONGNONXB congno, NXB nxb)
     : this(congno)
 {
     NXB = new NhaXuatBan(nxb);
 }
 public frmChiTietCongNoNXB(Form parent,NhaXuatBan nxb)
     : this(parent)
 {
     this._nxb = nxb;
 }
Beispiel #13
0
 public CongNoNXB(CONGNONXB congno, NXB nxb)
     : this(congno)
 {
     NXB = new NhaXuatBan(nxb);
 }
 public frmThongKeNguonChi(Form parent, NhaXuatBan nxb)
     : this(parent)
 {
     _CurrentNXB = nxb;
 }
Beispiel #15
0
 public Sach(SACH sach, NXB nxb)
     : this(sach)
 {
     NXB = new NhaXuatBan(nxb);
 }
 // GET: NhaXuatBan/Create
 public ActionResult Create()
 {
     var model = new NhaXuatBan();
     setAlertMessage();
     return View(model);
 }
 public ActionResult Edit(NhaXuatBan model, FormCollection collection)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (NhaXuatBanManager.edit(model))
             {
                 putSuccessMessage("Cập nhật thành công");
                 return RedirectToAction("Details", new { id = model.MaSoNXB });
             }
             else
             {
                 putErrorMessage("Cập nhật không thành công");
             }
         }
         else
         {
             putModelStateFailErrors(ModelState);
         }
         return RedirectToAction("Edit", new { id = model.MaSoNXB });
     }
     catch (Exception ex)
     {
         putErrorMessage(ex.Message);
         return RedirectToAction("Edit", new { id = model.MaSoNXB });
     }
 }
Beispiel #18
0
 public Sach(SACH sach,NXB nxb)
     : this(sach)
 {
     NXB = new NhaXuatBan(nxb);
 }
 private void gdvDMNXB_SelectionChanged(object sender, EventArgs e)
 {
     int index = ((DataGridView)sender).CurrentRow.Index;
     _currentNXB = (((DataGridView)sender).DataSource as List<NhaXuatBan>)[index];
     selectNXB(_currentNXB);
 }
 public HoaDonNXB(HOADONNXB hoadon, NXB nxb)
     : this(hoadon)
 {
     NXB = new NhaXuatBan(nxb);
 }
 public PhieuNhap(PHIEUNHAP phieu, NXB nxb)
     : this(phieu)
 {
     NXB = new NhaXuatBan(nxb);
 }
 private void gdvNXB_SelectionChanged(object sender, EventArgs e)
 {
     int index = gdvNXB.CurrentRow.Index;
     _CurrentNXB = (gdvNXB.DataSource as List<NhaXuatBan>)[index];
 }