示例#1
0
 public void UpdateControls()
 {
     if (IsAdd == false)
         doRootNote = note.Copy();
     AppCtrl.SetInfoBox(Info, note.NGUOI_TAO, note.NGAY_TAO, note.PHONG_BAN, note.CONG_TY,
     note.NGUOI_CAP_NHAT, note.NGAY_CAP_NHAT);
     HelpPhieu.InitBtnPhieu(this, IsAdd, null, null, null, btnSave, btnDelete, btnClose);
     GhiChu.Text = note.NOI_DUNG;
 }
示例#2
0
 void frm_AfterChangeNote(DONote note, SateChange state)
 {
     DataTable dt = gridControlNote.DataSource as DataTable;
     if (dt == null) return;
     if (state == SateChange.ADD)
     {
         DataRow r = dt.NewRow();
         r[NOTES.NOTE_ID] = note.NOTE_ID;
         r[NOTES.NOI_DUNG] = note.NOI_DUNG;
         dt.Rows.InsertAt(r, 0);
     }
     else if (state == SateChange.UPDATE)
     {
         DataRow[] rows = dt.Select(NOTES.NOTE_ID + "=" + note.NOTE_ID);
         foreach (DataRow r in rows)
         {
             r[NOTES.NOTE_ID] = note.NOTE_ID;
             r[NOTES.NOI_DUNG] = note.NOI_DUNG;
         }
     }
     else
     {
         DataRow[] rows = dt.Select(NOTES.NOTE_ID + "=" + note.NOTE_ID);
         foreach (DataRow r in rows)
         {
             dt.Rows.Remove(r);
         }
     }
     gridViewNote.RefreshData();
 }
示例#3
0
        private bool? Save()
        {
            if (GetValidData())
            {
                if (DANote.I.Update(note))
                {

                    doRootNote = note.Copy();
                    if (AfterChangeNote != null)
                    {
                        AfterChangeNote(note, IsAdd == true ? SateChange.ADD : SateChange.UPDATE);
                    }
                    this.IsAdd = false;
                    AppCtrl.SetInfoBox(Info, note.NGUOI_CAP_NHAT, note.NGAY_CAP_NHAT, note.PHONG_BAN, note.CONG_TY,
                    note.NGUOI_CAP_NHAT, note.NGAY_CAP_NHAT);
                    Info.Enabled = true;

                    HelpMsgBox.ShowNotificationMessage("Lưu note thành công!");
                    return true;
                }
                else
                {
                    HelpMsgBox.ShowErrorMessage("Lưu note thất bại!");
                    return false;
                }
            }
            return false;
        }
示例#4
0
        private bool InitDOData(object id)
        {
            if (id is DONote)
            {
                this.note = id as DONote;
                return true;
            }
            if (!((id is Int64) || (id is string))) return false;
            this.note = DANote.I.LoadAll(HelpNumber.ParseInt64(id));

            return true;
        }
示例#5
0
        public bool Compare(DONote OrtherMuonTra)
        {
            try
            {
                FieldInfo[] infos = typeof(DONote).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)
            {
                PLException.AddException(ex);
            }
            return false;
        }
示例#6
0
 public DONote Copy()
 {
     DONote pm = new DONote();
     try
     {
         FieldInfo[] infos = typeof(DONote).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 (Exception ex)
     {
         PLException.AddException(ex);
     }
     return pm;
 }