public bool del(BIEUMAU_M04 bm) { BIEUMAU_M04 _bm = db.BIEUMAU_M04s.Where(m => m.ID == bm.ID).FirstOrDefault(); if (_bm != null) { _bm.TT_XOA = true; return(true); } return(false); }
public bool editInfo_m04(BIEUMAU_M04 bm) { BIEUMAU_M04 _bm = db.BIEUMAU_M04s.OrderByDescending(i => i.ID).First(); if (_bm != null) { try { _bm = bm; return(true); } catch (Exception e) { return(false); } } return(false); }
private void M04_btn_Luu_Click(object sender, EventArgs e) { lstTxt = new List <TextBox>(); lstTxt.Add(M04_NSD_txt_diaChi); lstTxt.Add(M04_NSD_txt_hoTen); lstTxt.Add(M04_NSD_txt_so); lstTxt.Add(M04_txt_cua); lstTxt.Add(M04_txt_diaChiDat); lstTxt.Add(M04_txt_dtDat); lstTxt.Add(M04_txt_hoTenNguoiVD); lstTxt.Add(M04_txt_kinhGui); lstTxt.Add(M04_txt_ndQuyenSD); lstTxt.Add(M04_txt_nguonGocSD); lstTxt.Add(M04_txt_nhuCauGhiNo); lstTxt.Add(M04_txt_quyenSo); lstTxt.Add(M04_txt_sdHanChe); lstTxt.Add(M04_txt_suDungChung); lstTxt.Add(M04_txt_suDungMD); lstTxt.Add(M04_txt_suDungRieng); lstTxt.Add(M04_txt_thuaDatSo); lstTxt.Add(M04_txt_toBanDoSo); List <TextBox> lstTxt2 = new List <TextBox>(); lstTxt2.Add(M04_txt_CLN_loaicay); lstTxt2.Add(M04_txt_CLN_soHuuChung); lstTxt2.Add(M04_txt_CLN_soHuuRieng); lstTxt2.Add(M04_txt_NO_dtSan); lstTxt2.Add(M04_txt_NO_dtXD); lstTxt2.Add(M04_txt_NO_ketCau); lstTxt2.Add(M04_txt_NO_loaiNhaO); lstTxt2.Add(M04_txt_NO_soHuuChung); lstTxt2.Add(M04_txt_NO_soHuuRieng); lstTxt2.Add(M04_txt_NO_soTang); lstTxt2.Add(M04_txt_RSX_dienTich); lstTxt2.Add(M04_txt_RSX_loaiCay); lstTxt2.Add(M04_txt_RSX_nguonVon); lstTxt2.Add(M04_txt_RSX_nhanChuyenQuyen); lstTxt2.Add(M04_txt_RSX_NNKTT); lstTxt2.Add(M04_txt_RSX_NNTT); lstTxt2.Add(M04_txt_RSX_soHuuChung); lstTxt2.Add(M04_txt_RSX_soHuuRieng); lstTxt2.Add(M04_txt_RSX_tuTrong); lstTxt2.Add(M04_txt_NO_thsd); lstTxt2.Add(M04_txt_CLN_thsd); lstTxt2.Add(M04_txt_RSX_thsd); lstTxt2.Add(M04_txt_CLN_dt); for (int i = 0; i < lstTxt.Count; i++) { if (string.IsNullOrEmpty(lstTxt[i].Text) || lstTxt[i].Text == placeholder) { MessageBox.Show("Phải điền đấy đầy đủ thông tin!"); return; } } for (int j = 0; j < lstTxt2.Count; j++) { if (lstTxt2[j].Text == "" || lstTxt2[j].Text == placeholder) { lstTxt2[j].Text = 0.ToString(); } } BIEUMAU_M04 _bm = new BIEUMAU_M04(); _bm.DENGHIKHAC = M04_txt_deNghiKhac.Text; _bm.DIACHI_NVD = M04_NSD_txt_diaChi.Text; _bm.DIACHI_THUADAT = M04_txt_diaChiDat.Text; _bm.DTSAN_NO = float.Parse(M04_txt_NO_dtSan.Text); _bm.DTXAYDUNG_NO = float.Parse(M04_txt_NO_dtXD.Text); _bm.DT_CLN = float.Parse(M04_txt_CLN_dt.Text); _bm.DT_RSX = float.Parse(M04_txt_RSX_dienTich.Text); _bm.DT_TD = float.Parse(M04_txt_dtDat.Text); _bm.GIAYTOKEMTHEO = Mau04_txt_giayTokemTheo.Text; _bm.HOTEN_NVD = M04_NSD_txt_hoTen.Text; _bm.ID_LOAIBIEUMAU = 4; _bm.KETCAU_NO = M04_txt_NO_ketCau.Text; _bm.KINHGUI = M04_txt_kinhGui.Text; _bm.CUA_TD = M04_txt_cua.Text; _bm.QUYENSUDUNGHANCHESO = int.Parse(M04_txt_sdHanChe.Text); _bm.NDQUYENSD_TD = M04_txt_ndQuyenSD.Text; _bm.LOAICAY_CLN = M04_txt_CLN_loaicay.Text; _bm.LOAICAY_RSX = M04_txt_RSX_loaiCay.Text; _bm.LOAINHAO_NO = M04_txt_NO_loaiNhaO.Text; _bm.TUTHOIDIEM_TD = DateTime.Parse(M04_dtp_tuThoiDiem.Value.ToString("MM/dd/yyyy")); _bm.NGAYVIETDON = DateTime.Parse(M04_dtp_NgayVD.Value.ToString("MM/dd/yyyy")); _bm.NHU_CAU_GHI_NO = M04_txt_nhuCauGhiNo.Text; _bm.QUYENSO = int.Parse(M04_txt_quyenSo.Text); _bm.SDCHUNG_RSX = float.Parse(M04_txt_RSX_soHuuChung.Text); _bm.SDRIENG_RSX = float.Parse(M04_txt_RSX_soHuuRieng.Text); _bm.SHCHUNG_CLN = float.Parse(M04_txt_CLN_soHuuChung.Text); _bm.SHRIENG_CLN = float.Parse(M04_txt_CLN_soHuuRieng.Text); _bm.SHCHUNG_NO = float.Parse(M04_txt_NO_soHuuChung.Text); _bm.SHRIENG_NO = float.Parse(M04_txt_NO_soHuuRieng.Text); _bm.SHRIENG_TD = float.Parse(M04_txt_suDungRieng.Text); _bm.SHCHUNG_TD = float.Parse(M04_txt_suDungChung.Text); _bm.SO = M04_NSD_txt_so.Text; _bm.SOTANG_NO = int.Parse(M04_txt_NO_soTang.Text); _bm.THOIHANDENGHISD_TD = M04_txt_tgdenghiSDD.Text; _bm.THOIHANSDDEN_CLN = M04_txt_CLN_thsd.Text; _bm.THOIHANSDDEN_NO = M04_txt_NO_thsd.Text; _bm.THOIHANSDDEN_RSX = M04_txt_RSX_thsd.Text; _bm.THUADATSO = int.Parse(M04_txt_thuaDatSo.Text); _bm.TOBANDOSO = M04_txt_toBanDoSo.Text; _bm.TT_XOA = false; _bm.TT_XUAT = false; _bm.MUCDICHSD = M04_txt_suDungMD.Text; _bm.NGUONGOC_TD = M04_txt_nguonGocSD.Text; if (dal.saveInfo_M04(_bm)) { MessageBox.Show("Lưu thành công!"); } else { MessageBox.Show("Lưu thất bại, vui lòng thử lại!"); } }
public bool saveInfo_M04(BIEUMAU_M04 bm) { BIEUMAU_M04 _bm = new BIEUMAU_M04(); try { if (bm.DTSAN_NO != 0) { _bm.DTSAN_NO = bm.DTSAN_NO; } if (bm.DTXAYDUNG_NO != 0) { _bm.DTXAYDUNG_NO = bm.DTXAYDUNG_NO; } if (bm.DT_CLN != 0) { _bm.DT_CLN = bm.DT_CLN; } if (bm.DT_RSX != 0) { _bm.DT_RSX = bm.DT_RSX; } if (bm.SDCHUNG_RSX != 0) { _bm.SDCHUNG_RSX = bm.SDCHUNG_RSX; } if (bm.SDRIENG_RSX != 0) { _bm.SDRIENG_RSX = bm.SDRIENG_RSX; } if (bm.SHCHUNG_CLN != 0) { _bm.SHCHUNG_CLN = bm.SHCHUNG_CLN; } if (bm.SHCHUNG_NO != 0) { _bm.SHCHUNG_NO = bm.SHCHUNG_NO; } if (bm.SHRIENG_NO != 0) { _bm.SHRIENG_NO = bm.SHRIENG_NO; } if (bm.THOIHANSDDEN_CLN != "0") { _bm.THOIHANSDDEN_CLN = bm.THOIHANSDDEN_CLN; } if (bm.THOIHANSDDEN_NO != "0") { _bm.THOIHANSDDEN_NO = bm.THOIHANSDDEN_NO; } if (bm.THOIHANSDDEN_RSX != "0") { _bm.THOIHANSDDEN_RSX = bm.THOIHANSDDEN_RSX; } if (bm.KETCAU_NO != "0") { _bm.KETCAU_NO = bm.KETCAU_NO; } if (bm.LOAICAY_CLN != "0") { _bm.LOAICAY_CLN = bm.LOAICAY_CLN; } if (bm.LOAICAY_RSX != "0") { _bm.LOAICAY_RSX = bm.LOAICAY_RSX; } if (bm.LOAINHAO_NO != "0") { _bm.LOAINHAO_NO = bm.LOAINHAO_NO; } if (bm.SOTANG_NO != 0) { _bm.SOTANG_NO = bm.SOTANG_NO; } _bm.DT_TD = bm.DT_TD; _bm.SHRIENG_TD = bm.SHRIENG_TD; _bm.SHCHUNG_TD = bm.SHCHUNG_TD; _bm.DENGHIKHAC = bm.DENGHIKHAC; _bm.DIACHI_NVD = bm.DIACHI_NVD; _bm.DIACHI_THUADAT = bm.DIACHI_THUADAT; _bm.GIAYTOKEMTHEO = bm.GIAYTOKEMTHEO; _bm.HOTEN_NVD = bm.HOTEN_NVD; _bm.ID_LOAIBIEUMAU = bm.ID_LOAIBIEUMAU; _bm.KINHGUI = bm.KINHGUI; _bm.NGAYVIETDON = bm.NGAYVIETDON; _bm.NHU_CAU_GHI_NO = bm.NHU_CAU_GHI_NO; _bm.QUYENSO = bm.QUYENSO; _bm.SO = bm.SO; _bm.THOIHANDENGHISD_TD = bm.THOIHANDENGHISD_TD; _bm.THUADATSO = bm.THUADATSO; _bm.TOBANDOSO = bm.TOBANDOSO; _bm.TT_XOA = bm.TT_XOA; _bm.TT_XUAT = bm.TT_XUAT; _bm.MUCDICHSD = bm.MUCDICHSD; _bm.TUTHOIDIEM_TD = bm.TUTHOIDIEM_TD; _bm.NGUONGOC_TD = bm.NGUONGOC_TD; _bm.QUYENSUDUNGHANCHESO = bm.QUYENSUDUNGHANCHESO; _bm.CUA_TD = bm.CUA_TD; _bm.NDQUYENSD_TD = bm.NDQUYENSD_TD; db.BIEUMAU_M04s.InsertOnSubmit(_bm); db.SubmitChanges(); return(true); } catch (Exception e) { return(false); } }