public bool Compare(DOMuonTra OrtherMuonTra) { try { FieldInfo[] infos = typeof(DOMuonTra).GetFields(); foreach (FieldInfo info in infos) { if (info.Name == "NGUOI_CAP_NHAT" || info.Name == "NGAY_CAP_NHAT") continue; object a = info.GetValue(this); object b = info.GetValue(OrtherMuonTra); if ((a == null && b != null) || a != null && b == null) return false; else if (a == null && b == null) continue; if (info.FieldType == typeof(DataSet)) { DataSet dsA = a as DataSet; DataSet dsB = b as DataSet; if (dsA.Tables.Count != dsB.Tables.Count) return false; foreach (DataTable dtA in dsA.Tables) { if (dsB.Tables.Contains(dtA.TableName) == false) return false; DataTable dtB = dsB.Tables[dtA.TableName]; if (dtA.Columns.Count == 0 && dtB.Columns.Count == 0) continue; if (dtA.Columns.Count != dtB.Columns.Count) return false; if (dtA.Rows.Count == 0 && dtB.Rows.Count == 0) continue; if (dtA.Rows.Count != dtB.Rows.Count) return false; foreach (DataColumn colA in dtA.Columns) { if (dtB.Columns.Contains(colA.ColumnName) == false) return false; DataView viewA = dtA.DefaultView; DataView viewB = dtB.DefaultView; viewA.Sort = colA.ColumnName; viewB.Sort = colA.ColumnName; for (int i = 0; i < viewA.Count; i++) { if (viewA[i][colA.ColumnName].Equals(viewB[i][colA.ColumnName]) == false) return false; } } } } else { if (a.Equals(b) == false) return false; } } return true; } catch(Exception ex) { } return false; }
public DOMuonTra Copy() { DOMuonTra pm = new DOMuonTra(); try { FieldInfo[] infos = typeof(DOMuonTra).GetFields(); foreach (FieldInfo info in infos) { if (info.FieldType == typeof(DataSet)) { object ds = info.GetValue(this); if (ds == null) continue; info.SetValue(pm, ((DataSet)ds).Copy()); } else { info.SetValue(pm, info.GetValue(this)); } } } catch { } return pm; }
private void Init(object id, bool? IsAdd) { this.IsAdd = IsAdd; InitializeComponent(); InitTree(); InitControl(); InitValidation(); if (InitDOData(id)) { if (IsAdd == false) this.rootMuonTra = MuonTra.Copy(); UpdateControl(); UpdateTree(); } }
private bool InitDOData(object id) { if (id is DOMuonTra) { this.MuonTra = id as DOMuonTra; return true; } if (!((id is Int64) || (id is string))) return false; this.MuonTra = DAMuonTra.I.LoadAll(HelpNumber.ParseInt64(id)); if (id.ToString() == "-2") { } else { } return true; }
private void btnSave_Click(object sender, EventArgs e) { if (Save()) { if (IsAdd == false) { NoConfirm = true; HelpXtraForm.CloseFormNoConfirm(this); } else { HelpMsgBox.ShowNotificationMessage("Lưu phiếu mượn/trả thành công!"); this.IsAdd = false; this.MuonTra.DSDetail.AcceptChanges(); GridDataset = this.MuonTra.DSDetail.Copy(); this.TreeDes.DataSource = GridDataset.Tables[0]; this.rootMuonTra = MuonTra.Copy(); TreeDes.ExpandAll(); TreeDes.BestFitColumns(); } } }