public TargetHistoryCollection FetchAll() { TargetHistoryCollection coll = new TargetHistoryCollection(); Query qry = new Query(TargetHistory.Schema); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
//end return html /// <summary> /// ********************* customer target grid update append updated field(s) to history table /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void dxgrdTarget_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e) { if (e.AffectedRecords != 0) { //for batch save TargetHistoryCollection _t = new TargetHistoryCollection(); string _user = Page.Session["user"] != null ? (string)((UserClass)Page.Session["user"]).UserName : ""; //to enumerate through values string _key = e.Keys[0].ToString(); //this should be TargetID System.Collections.Specialized.OrderedDictionary _list = new System.Collections.Specialized.OrderedDictionary(); _list = (System.Collections.Specialized.OrderedDictionary)e.OldValues; int _ix = 0; //loop through each entry in dictionary foreach (System.Collections.DictionaryEntry _entry in _list) { string[] _args = new string[3]; _args[0] = _entry.Key != null?_entry.Key.ToString() : ""; if (_args[0] != "UpdateUser" && _args[0] != "UpdateDate" && _args[0] != "InsertDate") //we don't need to log changes to these { _args[1] = e.OldValues[_ix] != null ? e.OldValues[_ix].ToString() : ""; _args[2] = e.NewValues[_ix] != null ? e.NewValues[_ix].ToString() : ""; if (_args[2] != _args[1]) { TargetHistory _item = new TargetHistory(); _item.IDtarget = wwi_func.vint(_key); _item.FieldName = wwi_func.uncamel(_args[0]); //field name _item.ChangedFrom = _args[1]; _item.ChangedTo = _args[2]; _item.LogDate = DateTime.Now.Date; _item.LogUser = _user; //append to history _t.Add(_item); } } _t.SaveAll(); _ix++; } //end loop } //end if affected records }
public TargetHistoryCollection FetchByQuery(Query qry) { TargetHistoryCollection coll = new TargetHistoryCollection(); coll.LoadAndCloseReader(qry.ExecuteReader()); return coll; }
public TargetHistoryCollection FetchByID(object HistoryID) { TargetHistoryCollection coll = new TargetHistoryCollection().Where("historyID", HistoryID).Load(); return coll; }
public TargetHistoryCollection FetchByTargetID(object TargetID) { TargetHistoryCollection coll = new TargetHistoryCollection().Where("IDtarget", TargetID).Load(); return coll; }
//end return html /// <summary> /// ********************* customer target grid update append updated field(s) to history table /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void dxgrdTarget_RowUpdated(object sender, DevExpress.Web.Data.ASPxDataUpdatedEventArgs e) { if(e.AffectedRecords != 0) { //for batch save TargetHistoryCollection _t = new TargetHistoryCollection(); string _user = Page.Session["user"] != null ? (string)((UserClass)Page.Session["user"]).UserName : ""; //to enumerate through values string _key = e.Keys[0].ToString(); //this should be TargetID System.Collections.Specialized.OrderedDictionary _list = new System.Collections.Specialized.OrderedDictionary(); _list = (System.Collections.Specialized.OrderedDictionary)e.OldValues; int _ix = 0; //loop through each entry in dictionary foreach (System.Collections.DictionaryEntry _entry in _list) { string[] _args = new string[3]; _args[0] = _entry.Key != null ? _entry.Key.ToString() : ""; if (_args[0] != "UpdateUser" && _args[0] != "UpdateDate" && _args[0] != "InsertDate") //we don't need to log changes to these { _args[1] = e.OldValues[_ix] != null ? e.OldValues[_ix].ToString() : ""; _args[2] = e.NewValues[_ix] != null ? e.NewValues[_ix].ToString() : ""; if (_args[2] != _args[1]) { TargetHistory _item = new TargetHistory(); _item.IDtarget = wwi_func.vint(_key); _item.FieldName = wwi_func.uncamel(_args[0]); //field name _item.ChangedFrom = _args[1]; _item.ChangedTo = _args[2]; _item.LogDate = DateTime.Now.Date; _item.LogUser = _user; //append to history _t.Add(_item); } } _t.SaveAll(); _ix++; }//end loop } //end if affected records }