private void btn_luu_Click(object sender, EventArgs e) { TANG tg = new TANG(); if (btn_them.Enabled == true) { tg.MATANG = txt_matang.Text; tg.TENTANG = txt_tentang.Text; if (txt_matang.Text == null && txt_tentang.Text == string.Empty) { MessageBox.Show("không được để trống"); return; } //kiểm tra khóa chính if (tang.ktkc_Tang(tg.MATANG) == true) { MessageBox.Show("TRùng khóa chính"); return; } if (tang.themTang(tg) == true) { grv_Tang.DataSource = tang.loadBangTang(); MessageBox.Show("Thành công"); } else { MessageBox.Show("Thất bại"); } btn_sua.Enabled = btn_luu.Enabled = btn_them.Enabled = false; } if (btn_sua.Enabled == true) { try { if (txt_tentang.Text == string.Empty) { MessageBox.Show("Tên tầng không được để trống"); return; } tg.MATANG = txt_matang.Text; tg.TENTANG = txt_tentang.Text; if (tang.sua_Tang(tg) == true) { grv_Tang.DataSource = tang.loadBangTang(); MessageBox.Show("Thành công"); } } catch { MessageBox.Show("thất bại"); } } btn_sua.Enabled = btn_xoa.Enabled = btn_huy.Enabled = btn_luu.Enabled = txt_matang.Enabled = txt_tentang.Enabled = false; btn_them.Enabled = true; }
public ActionResult Suatang(TANG tg, int id1, int id2) { TANG tang = db.TANGs.Find(id1, id2); tang.Tang1 = tg.Tang1; tang.DienTich = tg.DienTich; tang.Gia = tg.Gia; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Suatang(int id1, int id2) { TANG tang = db.TANGs.Find(id1, id2); if (tang == null) { Response.StatusCode = 404; } return(View(tang)); }
public ActionResult Xacnhanxoa(int id1, int id2) { TANG tang = db.TANGs.Find(id1, id2); ViewBag.Tang1 = tang.Tang1; if (tang == null) { Response.StatusCode = 404; return(null); } db.TANGs.Remove(tang); db.SaveChanges(); return(RedirectToAction("Index")); }
private void txt_maphong_TextChanged(object sender, EventArgs e) { try { PHONG p = new PHONG(); LOAIPHONG lp = new LOAIPHONG(); TANG t = new TANG(); p = dal_phong.loadTenPhong(txt_maphong.Text); lp = dal_lp.loadTenLoaiPhong(p.MALOAI); t = dal_tang.loadTenTang(p.MATANG); txt_sltoida.Text = p.SOLUONG_TD.ToString(); txt_slhientai.Text = p.SOLUONG_HT.ToString(); txt_loaiphong.Text = lp.TENLOAI; txt_tang.Text = t.TENTANG; } catch { MessageBox.Show("Lỗi hệ thống"); } }
private void txt_phong_TextChanged(object sender, EventArgs e) { try { PHONG p = new PHONG(); LOAIPHONG lp = new LOAIPHONG(); TANG t = new TANG(); p = dal_phong.loadTenPhong(datphong.laymaphong(Ten)); lp = dal_lp.loadTenLoaiPhong(p.MALOAI); t = dal_tang.loadTenTang(p.MATANG); txt_soluongtd.Text = p.SOLUONG_TD.ToString(); txt_soluonght.Text = p.SOLUONG_HT.ToString(); txt_loaiphong.Text = lp.TENLOAI; txt_matang.Text = t.TENTANG; txt_tiencoc.Text = txt_gia.Text = String.Format("{0:#,##0.##}", lp.GIA); } catch { MessageBox.Show("Lỗi hệ thống"); } }
private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e) { TANG t = new TANG(); btn_xoa.Enabled = btn_sua.Enabled = btn_huy.Enabled = true; btn_them.Enabled = false; int position = gridView1.FocusedRowHandle; try { t.MATANG = gridView1.GetRowCellValue(position, "MATANG").ToString(); t.TENTANG = gridView1.GetRowCellValue(position, "TENTANG").ToString(); txt_matang.Text = t.MATANG.ToString(); txt_tentang.Text = t.TENTANG.ToString(); } catch { } }
private void cbo_maphong_Click(object sender, EventArgs e) { if (cbo_maphong.Text.Length > 0) { PHONG p = new PHONG(); TANG t = new TANG(); LOAIPHONG lp = new LOAIPHONG(); p = dal_phong.loadTenPhong(cbo_maphong.SelectedValue.ToString()); lp = dal_lp.loadTenLoaiPhong(p.MALOAI); t = dal_tang.loadTenTang(p.MATANG); //txt_tenphong.Text = p.TENPHONG.ToString(); cbo_tang.Text = string.Empty; cbo_tang.Text = t.TENTANG; txt_loaiphong.Text = lp.TENLOAI; txt_ma.Text = p.MAPHONG; txt_tienphong.Text = String.Format("{0:#,##0.##}", Convert.ToDouble(lp.GIA.ToString())); String kq = traphong.laySoDien(cbo_maphong.SelectedValue.ToString()); if (kq == "") { txt_sodiendau.Text = "0"; } else { txt_sodiendau.Text = kq; } String sn = traphong.laySoNuoc(cbo_maphong.SelectedValue.ToString()); if (sn == "") { txt_sonuocdau.Text = "0"; } else { txt_sonuocdau.Text = sn; } txt_mahd.Text = bll_sm.SinhMaHoaDon(); txt_sodiencuoi.Clear(); txt_sonuoccuoi.Clear(); txt_sonuoc.Clear(); txt_sodien.Clear(); txt_tongtien.Clear(); txt_tiendien.Clear(); txt_tiennuoc.Clear(); if (cbo_thang.Text.Length > 0) { DateTime thang = Convert.ToDateTime("05" + "/" + cbo_thang.Text + "/" + txt_nam.Text); if (kttinhtienthaothang(cbo_maphong.SelectedValue.ToString(), thang) == true) { btn_tinhtienphong.Enabled = false; } else { btn_tinhtienphong.Enabled = true; } } else { return; } grv_hoadon.DataSource = bLL_TienPhongHangThang.LoadDataHoaDontheomaphong(cbo_maphong.SelectedValue.ToString()); } else { return; } }
//Sửa public bool sua_Tang(TANG pTang) { return(tang.suaTang(pTang)); }
//Thêm public bool themTang(TANG pTang) { return(tang.them_Tang(pTang)); }
public ActionResult Themtang(TANG tang) { db.TANGs.Add(tang); db.SaveChanges(); return(RedirectToAction("Index")); }