void FillData() { try { if (!Utility.isValidGrid(grdTamung)) { objTamung = null; dtpNgaythu.Value = globalVariables.SysDate; txtSotien.Text = "0"; txtLydo.SetCode("-1"); txtNguoithu.SetCode("-1"); } else { objTamung = NoitruTamung.FetchByID(Utility.Int32Dbnull(grdTamung.GetValue(NoitruTamung.Columns.Id))); if (objTamung == null) { dtpNgaythu.Value = globalVariables.SysDate; txtSotien.Text = "0"; txtLydo.SetCode("-1"); txtNguoithu.SetCode("-1"); } else { objTamung.IsNew = false; objTamung.MarkOld(); dtpNgaythu.Value = objTamung.NgayTamung.Value; txtSotien.Text = objTamung.SoTien.ToString(); txtLydo._Text = objTamung.MotaThem; txtNguoithu.SetId(objTamung.IdTnv); } } } catch (Exception ex) { } finally { ModifyCommand(); //SetControlStatus(); } }
public void Update(long Id,long IdBenhnhan,string MaLuotkham,decimal? SoTien,byte TrangThai,DateTime? NgayTamung,byte? KieuTamung,string MotaThem,int? IdTnv,string NguoiSua,DateTime? NgaySua,string NguoiTao,DateTime? NgayTao,short? IdKhoanoitru,int? IdBuonggiuong,int? IdBuong,int? IdGiuong) { NoitruTamung item = new NoitruTamung(); item.MarkOld(); item.IsLoaded = true; item.Id = Id; item.IdBenhnhan = IdBenhnhan; item.MaLuotkham = MaLuotkham; item.SoTien = SoTien; item.TrangThai = TrangThai; item.NgayTamung = NgayTamung; item.KieuTamung = KieuTamung; item.MotaThem = MotaThem; item.IdTnv = IdTnv; item.NguoiSua = NguoiSua; item.NgaySua = NgaySua; item.NguoiTao = NguoiTao; item.NgayTao = NgayTao; item.IdKhoanoitru = IdKhoanoitru; item.IdBuonggiuong = IdBuonggiuong; item.IdBuong = IdBuong; item.IdGiuong = IdGiuong; item.Save(UserName); }
void cmdGhi_Click(object sender, EventArgs e) { if (!isValidData()) { return; } try { if (m_enAct == action.Insert) { objTamung = new NoitruTamung(); objTamung.IdBenhnhan = objLuotkham.IdBenhnhan; objTamung.MaLuotkham = objLuotkham.MaLuotkham; objTamung.IdKhoanoitru = objLuotkham.IdKhoanoitru; objTamung.IdBuonggiuong = objLuotkham.IdRavien; objTamung.IdBuong = objLuotkham.IdBuong; objTamung.IdGiuong = objLuotkham.IdGiuong; objTamung.Noitru = (byte)(objLuotkham.TrangthaiNoitru <= 0 ? 0 : 1); objTamung.KieuTamung = 0; objTamung.MotaThem = txtLydo.Text; objTamung.IdTnv = Utility.Int32Dbnull(txtNguoithu.MyID, -1); objTamung.SoTien = Utility.DecimaltoDbnull(txtSotien.Text); objTamung.NgayTamung = dtpNgaythu.Value; objTamung.TrangThai = 0; objTamung.IsNew = true; if (noitru_TamungHoanung.NoptienTamung(objTamung)) { DataRow newDr = m_dtTamung.NewRow(); Utility.FromObjectToDatarow(objTamung, ref newDr); newDr["sngay_tamung"] = dtpNgaythu.Value.ToString("dd/MM/yyyy"); newDr["ten_khoanoitru"] = ""; newDr["ten_nhanvien"] = txtNguoithu.Text; m_dtTamung.Rows.Add(newDr); m_dtTamung.AcceptChanges(); Utility.GotoNewRowJanus(grdTamung, NoitruTamung.Columns.Id, objTamung.Id.ToString()); if (chkSaveAndPrint.Checked) { cmdIn_Click(cmdIn, e); } m_enAct = action.FirstOrFinished; } } else { objTamung.SoTien = Utility.DecimaltoDbnull(txtSotien.Text); objTamung.NgayTamung = dtpNgaythu.Value; objTamung.MotaThem = txtLydo.Text; objTamung.IdTnv = Utility.Int32Dbnull(txtNguoithu.MyID, -1); objTamung.IsNew = false; objTamung.MarkOld(); if (noitru_TamungHoanung.NoptienTamung(objTamung)) { DataRow _myDr = ((DataRowView)grdTamung.CurrentRow.DataRow).Row; _myDr[NoitruTamung.Columns.SoTien] = Utility.DecimaltoDbnull(txtSotien.Text); _myDr[NoitruTamung.Columns.NgayTamung] = dtpNgaythu.Value; _myDr[NoitruTamung.Columns.MotaThem] = txtLydo.Text; _myDr[NoitruTamung.Columns.IdTnv] = Utility.Int32Dbnull(txtNguoithu.MyID, -1); _myDr["sngay_tamung"] = dtpNgaythu.Value.ToString("dd/MM/yyyy"); _myDr["ten_khoanoitru"] = ""; _myDr["ten_nhanvien"] = txtNguoithu.Text; m_dtTamung.AcceptChanges(); m_enAct = action.FirstOrFinished; } } setTongtienStatus(); SetControlStatus(); if (_OnChangedData != null) { _OnChangedData(); } } catch (Exception ex) { } finally { } }