public bool Compare(DOPostMaster OtherBienMuc) { try { FieldInfo[] infos = typeof(DOPostMaster).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(OtherBienMuc); 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 { } return false; }
private void popupContainerEditPM_EditValueChanged(object sender, EventArgs e) { long ctpm_id = PostMaster._getSelectedID(); if (ctpm_id > -1 && ChuongTrinh.PostMasters.Count > 0) { foreach (DOPostMaster p in ChuongTrinh.PostMasters) { if (p.CTPM_ID == ctpm_id) { doPostMaster = p; } } } else { doPostMaster = DAPostMaster.I.LoadAll(ctpm_id); } LoaiLuuTru._setSelectedID(doPostMaster.LOAI_LUU_TRU); PopUp.EditValue = doPostMaster.POP_UP; AppCtrl.SetDecimal(TongTap, doPostMaster.TONG_TAP); }
public DOPostMaster Copy() { DOPostMaster pm = new DOPostMaster(); try { FieldInfo[] infos = typeof(DOPostMaster).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; }