void grdRoom_UpdatingCell(object sender, UpdatingCellEventArgs e) { try { if (!Utility.isValidGrid(grdRoom)) { return; } if (e.InitialValue.ToString() != e.Value.ToString()) { NoitruDmucBuong _obj = NoitruDmucBuong.FetchByID(Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.IdBuong))); _obj.MaBuong = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.MaBuong.ToUpper() ? e.Value.ToString() : Utility.sDbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.MaBuong), ""); _obj.TenBuong = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.TenBuong.ToUpper() ? e.Value.ToString() : Utility.sDbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.TenBuong), ""); _obj.DonGia = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.DonGia.ToUpper() ? (int)e.Value : Utility.Int32Dbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.DonGia), 0); _obj.MotaThem = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.MotaThem.ToUpper() ? e.Value.ToString() : Utility.sDbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.MotaThem), ""); _obj.TrangThai = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.TrangThai.ToUpper() ? (byte)e.Value : Utility.ByteDbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.TrangThai), 1); _obj.SttHthi = e.Column.DataMember.ToUpper() == NoitruDmucBuong.Columns.SttHthi.ToUpper() ? (Int16)e.Value : Utility.Int16Dbnull(Utility.GetValueFromGridColumn(grdRoom, NoitruDmucBuong.Columns.SttHthi), 1); _obj.IsNew = false; _obj.MarkOld(); _obj.Save(); } } catch (Exception ex) { } }
/// <summary> /// hàm thực hiện viẹc thêmm ới thông tin /// </summary> private void InsertData() { try { objRoom = new NoitruDmucBuong(); objRoom.IdBuong = -1; objRoom.IdBuong = Utility.Int16Dbnull(txtID.Text); objRoom.MaBuong = Utility.DoTrim(txtMa.Text); objRoom.TenBuong = Utility.DoTrim(txtTEN.Text); objRoom.MotaThem = Utility.DoTrim(txt_Mo_Ta.Text); objRoom.TrangThai = Utility.Bool2byte(chkTrangThai.Checked); objRoom.IdKhoanoitru = Utility.Int16Dbnull(cboKhoaNoiTru.SelectedValue); objRoom.SttHthi = Utility.Int16Dbnull(txt_STT_HTHI.Text); objRoom.IsNew = true; objRoom.Save(); if (objRoom != null) { DataRow newDR = p_dtDataPhong.NewRow(); Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.Rows.Add(newDR); if (MyGetData != null) { MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); } Utility.SetMsg(lblMessage, "Bạn thực hiện thêm mới thành công", true); if (chkthemmoilientuc.Checked) { ClearControl(); } else { Close(); } } catch (Exception exception) { Utility.CatchException(exception); } }
/// <summary> /// hàm thưucj hiện việc cập nhập lại thông tin thành công /// </summary> private void UpdateData() { try { objRoom = new NoitruDmucBuongController().FetchByID(txtID.Text)[0]; objRoom.IdBuong = Utility.Int16Dbnull(txtID.Text); objRoom.MaBuong = txtMa.Text; objRoom.TenBuong = txtTEN.Text; txt_Mo_Ta.Text = objRoom.MotaThem; objRoom.TrangThai = Utility.Bool2byte(chkTrangThai.Checked); objRoom.IdKhoanoitru = Utility.Int16Dbnull(cboKhoaNoiTru.SelectedValue); objRoom.SttHthi = Utility.Int16Dbnull(txt_STT_HTHI.Text); objRoom.MotaThem = Utility.DoTrim(txt_Mo_Ta.Text); objRoom.IsNew = false; objRoom.MarkOld(); objRoom.Save(); if (MyGetData != null) { DataRow newDR = p_dtDataPhong.Select(NoitruDmucBuong.Columns.IdBuong + "=" + objRoom.IdBuong.ToString())[0]; Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.AcceptChanges(); MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); if (chkthemmoilientuc.Checked) { ClearControl(); } else { Close(); } Utility.SetMsg(lblMessage, "Bạn thực hiện sửa thông tin thành công", true); } catch (Exception ex) { Utility.CatchException(ex); } }
private void MultiInsert() { try { Int16 STTHthi = Utility.Int16Dbnull(txt_STT_HTHI.Text); for (int i = Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtCodefrom.Text), 0); i <= Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtCode2.Text), 0); i++) { objRoom = new NoitruDmucBuong(); objRoom.IdBuong = -1; objRoom.IdBuong = Utility.Int16Dbnull(txtID.Text); objRoom.MaBuong = Utility.DoTrim(txtMa.Text) + i.ToString(); objRoom.TenBuong = Utility.DoTrim(txtTEN.Text) + " " + i.ToString(); objRoom.MotaThem = Utility.DoTrim(txt_Mo_Ta.Text); objRoom.TrangThai = Utility.Bool2byte(chkTrangThai.Checked); objRoom.IdKhoanoitru = Utility.Int16Dbnull(cboKhoaNoiTru.SelectedValue); NoitruDmucBuong objcheck = new Select().From(NoitruDmucBuong.Schema).Where(NoitruDmucBuong.Columns.MaBuong).IsEqualTo(objRoom.MaBuong).ExecuteSingle <NoitruDmucBuong>(); if (objcheck != null) { if (chkAutoupdate.Checked) { objRoom.IdBuong = objcheck.IdBuong; objRoom.MarkOld(); objRoom.IsNew = true; } else { continue; } } { STTHthi += 1; objRoom.IsNew = true; } objRoom.SttHthi = STTHthi; objRoom.Save(); if (objRoom != null) { DataRow newDR = p_dtDataPhong.NewRow(); Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.Rows.Add(newDR); if (MyGetData != null) { MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); } } Utility.SetMsg(lblMessage, "Bạn thực hiện thêm mới thành công", true); if (chkthemmoilientuc.Checked) { ClearControl(); } else { Close(); } } catch (Exception exception) { Utility.CatchException(exception); } }
/// <summary> /// hàm thưucj hiện việc cập nhập lại thông tin thành công /// </summary> private void UpdateData() { try { objRoom = new NoitruDmucBuongController().FetchByID(txtID.Text)[0]; objRoom.IdBuong = Utility.Int16Dbnull(txtID.Text); objRoom.MaBuong = txtMa.Text; objRoom.TenBuong = txtTEN.Text; txt_Mo_Ta.Text = objRoom.MotaThem; objRoom.TrangThai = Utility.Bool2byte(chkTrangThai.Checked); objRoom.IdKhoanoitru = Utility.Int16Dbnull(cboKhoaNoiTru.SelectedValue); objRoom.SttHthi = Utility.Int16Dbnull(txt_STT_HTHI.Text); objRoom.MotaThem = Utility.DoTrim(txt_Mo_Ta.Text); objRoom.IsNew = false; objRoom.MarkOld(); objRoom.Save(); if (MyGetData != null) { DataRow newDR = p_dtDataPhong.Select(NoitruDmucBuong.Columns.IdBuong + "=" + objRoom.IdBuong.ToString())[0]; Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.AcceptChanges(); MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); if (chkthemmoilientuc.Checked) ClearControl(); else Close(); Utility.SetMsg(lblMessage, "Bạn thực hiện sửa thông tin thành công", true); } catch(Exception ex) { Utility.CatchException(ex); } }
private void MultiInsert() { try { Int16 STTHthi=Utility.Int16Dbnull(txt_STT_HTHI.Text); for (int i = Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtCodefrom.Text), 0); i <= Utility.Int32Dbnull(Utility.DecimaltoDbnull(txtCode2.Text), 0); i++) { objRoom = new NoitruDmucBuong(); objRoom.IdBuong = -1; objRoom.IdBuong = Utility.Int16Dbnull(txtID.Text); objRoom.MaBuong = Utility.DoTrim(txtMa.Text) + i.ToString(); objRoom.TenBuong = Utility.DoTrim(txtTEN.Text) + " " + i.ToString(); objRoom.MotaThem = Utility.DoTrim(txt_Mo_Ta.Text); objRoom.TrangThai = Utility.Bool2byte(chkTrangThai.Checked); objRoom.IdKhoanoitru = Utility.Int16Dbnull(cboKhoaNoiTru.SelectedValue); NoitruDmucBuong objcheck = new Select().From(NoitruDmucBuong.Schema).Where(NoitruDmucBuong.Columns.MaBuong).IsEqualTo(objRoom.MaBuong).ExecuteSingle<NoitruDmucBuong>(); if (objcheck != null) { if (chkAutoupdate.Checked) { objRoom.IdBuong = objcheck.IdBuong; objRoom.MarkOld(); objRoom.IsNew = true; } else { continue; } } { STTHthi += 1; objRoom.IsNew = true; } objRoom.SttHthi = STTHthi; objRoom.Save(); if (objRoom != null) { DataRow newDR = p_dtDataPhong.NewRow(); Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.Rows.Add(newDR); if (MyGetData != null) { MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); } } Utility.SetMsg(lblMessage, "Bạn thực hiện thêm mới thành công", true); if (chkthemmoilientuc.Checked) ClearControl(); else Close(); } catch (Exception exception) { Utility.CatchException(exception); } }
/// <summary> /// hàm thực hiện viẹc thêmm ới thông tin /// </summary> private void InsertData() { try { objRoom = new NoitruDmucBuong(); objRoom.IdBuong = -1; objRoom.IdBuong =Utility.Int16Dbnull( txtID.Text); objRoom.MaBuong = Utility.DoTrim(txtMa.Text); objRoom.TenBuong = Utility.DoTrim(txtTEN.Text); objRoom.MotaThem=Utility.DoTrim(txt_Mo_Ta.Text); objRoom.TrangThai =Utility.Bool2byte( chkTrangThai.Checked); objRoom.IdKhoanoitru =Utility.Int16Dbnull( cboKhoaNoiTru.SelectedValue); objRoom.SttHthi = Utility.Int16Dbnull(txt_STT_HTHI.Text); objRoom.IsNew = true; objRoom.Save(); if (objRoom != null) { DataRow newDR = p_dtDataPhong.NewRow(); Utility.FromObjectToDatarow(objRoom, ref newDR); newDR["ten_khoanoitru"] = cboKhoaNoiTru.Text; p_dtDataPhong.Rows.Add(newDR); if (MyGetData != null) { MyGetData(); } Utility.GonewRowJanus(grdList, NoitruDmucBuong.Columns.IdBuong, Utility.sDbnull(txtID.Text)); } Utility.SetMsg(lblMessage, "Bạn thực hiện thêm mới thành công", true); if (chkthemmoilientuc.Checked) ClearControl(); else Close(); } catch (Exception exception) { Utility.CatchException(exception); } }
public void Insert(string MaBuong,string TenBuong,short IdKhoanoitru,int DonGia,string MotaThem,byte? TrangThai,short? SttHthi) { NoitruDmucBuong item = new NoitruDmucBuong(); item.MaBuong = MaBuong; item.TenBuong = TenBuong; item.IdKhoanoitru = IdKhoanoitru; item.DonGia = DonGia; item.MotaThem = MotaThem; item.TrangThai = TrangThai; item.SttHthi = SttHthi; item.Save(UserName); }