This commit is contained in:
303
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserFormSetting.cs
Normal file
303
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/UIUserFormSetting.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
///////////////////////////////////////////////////////////
|
||||
// UIUserFormSetting.cs
|
||||
// Implementation of Class UIUserFormSetting
|
||||
// CSLA type: Editable Child
|
||||
// Created on: 06-"Rocktober"-2004
|
||||
// Object design: John
|
||||
// Coded: John 06-"Rocktober"-2004
|
||||
///////////////////////////////////////////////////////////
|
||||
|
||||
using System;
|
||||
using System.Data;
|
||||
using CSLA.Data;
|
||||
using GZTW.Data;
|
||||
using CSLA;
|
||||
using System.Threading;
|
||||
using CSLA.Security;
|
||||
|
||||
|
||||
namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// Used by Windows forms user interface to
|
||||
/// hold settings pertaining to a forms last
|
||||
/// size and other pertinent display variables.
|
||||
///
|
||||
/// Used to ensure that the forms appear the same as the
|
||||
/// user last left them in.
|
||||
///
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class UIUserFormSetting : BusinessBase
|
||||
{
|
||||
|
||||
|
||||
#region Attributes
|
||||
|
||||
private Guid mUserID;
|
||||
private string mFormName;
|
||||
//private int mFormWidth;
|
||||
//private int mFormHeight;
|
||||
//private int mSplitPosition1;
|
||||
//private int mSplitPosition2;
|
||||
|
||||
//private int mLocationX;
|
||||
//private int mLocationY;
|
||||
|
||||
//Toolbar layout stuff
|
||||
//private int mToolBarManagerLayoutSize;
|
||||
//private byte[] mToolBarManagerLayoutContent;
|
||||
|
||||
private string mLayout;
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
/// <summary>
|
||||
/// Private constructor to prevent direct instantiation
|
||||
/// </summary>
|
||||
private UIUserFormSetting()
|
||||
{
|
||||
//Set as child object
|
||||
MarkAsChild();
|
||||
mUserID=CurrentUserID;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Business properties
|
||||
/// <summary>
|
||||
/// User ID number
|
||||
/// </summary>
|
||||
public Guid UserID
|
||||
{
|
||||
get
|
||||
{
|
||||
return mUserID;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(mUserID!=value)
|
||||
{
|
||||
mUserID=value;
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string FormName
|
||||
{
|
||||
get
|
||||
{
|
||||
return mFormName;
|
||||
}
|
||||
set
|
||||
{
|
||||
if(mFormName!=value)
|
||||
{
|
||||
mFormName=value;
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar layout as xml fragment
|
||||
/// </summary>
|
||||
public string Layout
|
||||
{
|
||||
get
|
||||
{
|
||||
return mLayout;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (mLayout != value)
|
||||
{
|
||||
mLayout = value;
|
||||
MarkDirty();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Toolbar layout as dataset
|
||||
/// </summary>
|
||||
public DataSet LayoutDS
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(mLayout)) return new DataSet();
|
||||
System.IO.StringReader sr = new System.IO.StringReader(AyaBizUtils.EscapeXml(mLayout));//case 1724
|
||||
DataSet ds = new DataSet();
|
||||
ds.ReadXml(sr);
|
||||
return ds;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region System.Object overrides
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return "UIUserFormSetting"+ mFormName + mUserID.ToString() ;
|
||||
}
|
||||
|
||||
///
|
||||
/// <param name="obj"></param>
|
||||
public override bool Equals(Object obj)
|
||||
{
|
||||
if ( obj == null || GetType ( ) != obj.GetType ( ) ) return false;
|
||||
UIUserFormSetting c=(UIUserFormSetting)obj;
|
||||
return ((mUserID==c.mUserID) && (mFormName==c.mFormName));
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return ("UIUserFormSetting" + mFormName + mUserID).GetHashCode();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Static methods
|
||||
/// <summary>
|
||||
/// Get new object
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static UIUserFormSetting NewItem(string FormName)
|
||||
{
|
||||
UIUserFormSetting child=new UIUserFormSetting();
|
||||
child.FormName=FormName;
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GetItem
|
||||
/// </summary>
|
||||
/// <param name="dr"></param>
|
||||
/// <returns></returns>
|
||||
internal static UIUserFormSetting GetItem(SafeDataReader dr)
|
||||
{
|
||||
|
||||
UIUserFormSetting child = new UIUserFormSetting();
|
||||
child.Fetch(dr);
|
||||
return child;
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region DAL DATA ACCESS
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fetch
|
||||
/// </summary>
|
||||
/// <param name="dr"></param>
|
||||
private void Fetch(SafeDataReader dr)
|
||||
{
|
||||
|
||||
//UIUserFormSetting fields
|
||||
mFormName=dr.GetString("aFormName");
|
||||
//case 2102 added in schema 83
|
||||
if (AyaBizUtils.GlobalX.DBSchemaVersion > 82)
|
||||
{
|
||||
mLayout = dr.GetString("ALAYOUT");
|
||||
}
|
||||
|
||||
MarkOld();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update
|
||||
/// </summary>
|
||||
/// <param name="tr"></param>
|
||||
internal void Update(IDbTransaction tr)
|
||||
{
|
||||
//No need to update if there is nothing changed
|
||||
if(!this.IsDirty) return;
|
||||
|
||||
//No concurrency check here, maybe need it in future?
|
||||
//shouldn't if users don't log in more than once under
|
||||
//same account though.
|
||||
|
||||
// If not a new record, check if record was modified
|
||||
//by another user since original retrieval:
|
||||
// if(!IsNew)
|
||||
// DBUtil.CheckSafeToUpdate(this.mModified.Date,this.mID,"PartCategory");
|
||||
|
||||
#region Delete
|
||||
if(IsDeleted)
|
||||
{
|
||||
if(!IsNew)
|
||||
{
|
||||
//Delete object and child objects
|
||||
DBCommandWrapper cmDelete = DBUtil.GetCommandFromSQL("DELETE FROM aUIUserFormSetting WHERE aUserID=@UserID AND aFormName=@FormName");
|
||||
cmDelete.AddInParameter("@UserID",DbType.String,mUserID);
|
||||
cmDelete.AddInParameter("@FormName",DbType.String,mFormName);
|
||||
DBUtil.DB.ExecuteNonQuery(cmDelete, tr);
|
||||
//-----------------------------
|
||||
}
|
||||
MarkNew();
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Add / Update
|
||||
|
||||
|
||||
|
||||
DBCommandWrapper cm = null;
|
||||
if(IsNew)//Add or update?
|
||||
cm=DBUtil.GetCommandFromSQL(
|
||||
"INSERT INTO aUIUserFormSetting (aUserID, aFormName, aLayout) " +
|
||||
"VALUES (@UserID, @FormName, @Layout)"
|
||||
);
|
||||
else
|
||||
cm=DBUtil.GetCommandFromSQL(
|
||||
"UPDATE aUIUserFormSetting SET aUserID=@UserID, aFormName=@FormName, aLayout=@Layout " +
|
||||
"WHERE aUserID=@UserID AND aFormName=@FormName"
|
||||
);
|
||||
|
||||
|
||||
//UIUserFormSetting fields
|
||||
cm.AddInParameter("@UserID",DbType.Guid,mUserID);
|
||||
cm.AddInParameter("@FormName",DbType.String,mFormName);
|
||||
cm.AddInParameter("@Layout", DbType.String, mLayout);
|
||||
DBUtil.DB.ExecuteNonQuery(cm, tr);
|
||||
MarkOld();//db is now synched with object
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}//end UIUserFormSetting
|
||||
|
||||
}//end namespace GZTW.AyaNova.BLL
|
||||
Reference in New Issue
Block a user