public void PopulateBusinessObjectFromReader(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject, IDataReader dataReader) { try { businessObject.OnlineUserID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.OnlineUserID_int.ToString())); businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.UserName_nvc.ToString())); businessObject.MacAddress_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.MacAddress_nvc.ToString())); businessObject.LoginDate_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LoginDate_vc.ToString())); businessObject.LoginTime_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LoginTime_vc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LogOutDate_vc.ToString())) == false) { businessObject.LogOutDate_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LogOutDate_vc.ToString())); } else { businessObject.LogOutDate_vc = String.Empty; } if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LogOutTime_vc.ToString())) == false) { businessObject.LogOutTime_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T.OnlineUser_TField.LogOutTime_vc.ToString())); } else { businessObject.LogOutTime_vc = String.Empty; } } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public HPS.BLL.OnlineUserBLL.BLLOnlineUser_T SelectByPrimaryKey(HPS.BLL.OnlineUserBLL.BLLOnlineUser_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_OnlineUser_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter OnlineUserID_int = new SqlParameter(); OnlineUserID_int.ParameterName = "@OnlineUserID_int"; OnlineUserID_int.SqlDbType = SqlDbType.Int; OnlineUserID_int.Direction = ParameterDirection.Input; OnlineUserID_int.IsNullable = false; OnlineUserID_int.Value = businessObjectKey.OnlineUserID_int; this.Command.Parameters.Add(OnlineUserID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_T(); if (dataReader.Read()) { PopulateBusinessObjectFromReader(businessObject, dataReader); } else { businessObject = null; } if (dataReader.IsClosed == false) { dataReader.Close(); } if (ControlConnection) { this.Commit(); } return(businessObject); } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
private void AcceptButton_Click(object sender, EventArgs e) { try { HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory(); Hepsa.Core.BLL.BLLUserLogin_T UserLogin = new Hepsa.Core.BLL.BLLUserLogin_T(); UserLogin.UserName_nvc = this.UserName_nvcTextBox.Text; UserLogin.Password_nvc = Hepsa.Core.Common.Security.MD5(this.Password_nvcTextBox.Text); HPS.BLL.UserBLL.BLLUser_T UserEntity = UserFactory.Login(UserLogin); var OnlineUserEntity = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_T(); var OnlineUserFactory = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_TFactory(); if (!CheckComputerRegistration(UserEntity)) { throw new ApplicationException("این کامپیوتر مجاز به استفاده از سیستم نمی باشد"); } if (UserEntity != null) { HPS.Common.CurrentUser.user = UserEntity; if (Hepsa.Core.Common.ApplicationInfo.MainForm != null) { this.SaveSetting(); this.makeLog(); //--hp> var onlineUsertable = new DataTable(); OnlineUserFactory.GetAllByCondition(string.Format("[OnlineUser_T].[UserName_nvc]='{0}' and LoginDate_vc='{1}' AND LogOutDate_vc IS NULL ", HPS.Common.CurrentUser.user.UserName_nvc, OnlineUserFactory.ServerJalaliDate), ref onlineUsertable); if (onlineUsertable != null && onlineUsertable.Rows.Count > 1 && (UserEntity.MultiAccess_bit == false)) { throw new ApplicationException("حساب کاربری شما در سیستم دیگر در حال استفاده می باشد "); } //--<hp OnlineUserEntity.UserName_nvc = UserEntity.UserName_nvc; OnlineUserEntity.LoginDate_vc = OnlineUserFactory.ServerJalaliDate; OnlineUserEntity.LoginTime_vc = OnlineUserFactory.ServerTime; OnlineUserEntity.MacAddress_nvc = Hepsa.Core.Common.ApplicationInfo.MacAddress; OnlineUserFactory.Insert(OnlineUserEntity); HPS.Common.CurrentUser.user.OnlineUserID_int = OnlineUserEntity.OnlineUserID_int; this.DialogResult = DialogResult.OK; this.Close(); } } } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); } }
public void Insert(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueOnlineUserID_int") == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Insert(businessObject); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public List <HPS.BLL.OnlineUserBLL.BLLOnlineUser_T> PopulateObjectsFromReader(IDataReader dataReader) { try { List <HPS.BLL.OnlineUserBLL.BLLOnlineUser_T> list = new List <HPS.BLL.OnlineUserBLL.BLLOnlineUser_T>(); while (dataReader.Read()) { HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject = new HPS.BLL.OnlineUserBLL.BLLOnlineUser_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public void Update(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject, HPS.BLL.OnlineUserBLL.BLLOnlineUser_TKeys businessObjectKey) { try { List <string> ExceptList = new List <string>(); if (businessObject.OnlineUserID_int == businessObjectKey.OnlineUserID_int) { ExceptList.Add("UniqueOnlineUserID_int"); } if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, ExceptList.ToArray()) == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Update(businessObject, businessObjectKey); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Insert(HPS.BLL.OnlineUserBLL.BLLOnlineUser_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_OnlineUser_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter OnlineUserID_int = new SqlParameter(); OnlineUserID_int.ParameterName = "@OnlineUserID_int"; OnlineUserID_int.SqlDbType = SqlDbType.Int; OnlineUserID_int.Direction = ParameterDirection.Output; OnlineUserID_int.IsNullable = false; OnlineUserID_int.Value = businessObject.OnlineUserID_int; this.Command.Parameters.Add(OnlineUserID_int); SqlParameter UserName_nvc = new SqlParameter(); UserName_nvc.ParameterName = "@UserName_nvc"; UserName_nvc.SqlDbType = SqlDbType.NVarChar; UserName_nvc.Direction = ParameterDirection.Input; UserName_nvc.IsNullable = false; UserName_nvc.Value = businessObject.UserName_nvc; this.Command.Parameters.Add(UserName_nvc); SqlParameter MacAddress_nvc = new SqlParameter(); MacAddress_nvc.ParameterName = "@MacAddress_nvc"; MacAddress_nvc.SqlDbType = SqlDbType.NVarChar; MacAddress_nvc.Direction = ParameterDirection.Input; MacAddress_nvc.IsNullable = false; MacAddress_nvc.Value = businessObject.MacAddress_nvc; this.Command.Parameters.Add(MacAddress_nvc); SqlParameter LoginDate_vc = new SqlParameter(); LoginDate_vc.ParameterName = "@LoginDate_vc"; LoginDate_vc.SqlDbType = SqlDbType.VarChar; LoginDate_vc.Direction = ParameterDirection.Input; LoginDate_vc.IsNullable = false; LoginDate_vc.Value = businessObject.LoginDate_vc; this.Command.Parameters.Add(LoginDate_vc); SqlParameter LoginTime_vc = new SqlParameter(); LoginTime_vc.ParameterName = "@LoginTime_vc"; LoginTime_vc.SqlDbType = SqlDbType.VarChar; LoginTime_vc.Direction = ParameterDirection.Input; LoginTime_vc.IsNullable = false; LoginTime_vc.Value = businessObject.LoginTime_vc; this.Command.Parameters.Add(LoginTime_vc); SqlParameter LogOutDate_vc = new SqlParameter(); LogOutDate_vc.ParameterName = "@LogOutDate_vc"; LogOutDate_vc.SqlDbType = SqlDbType.VarChar; LogOutDate_vc.Direction = ParameterDirection.Input; LogOutDate_vc.IsNullable = true; if (String.IsNullOrEmpty(businessObject.LogOutDate_vc)) { LogOutDate_vc.Value = DBNull.Value; } else { LogOutDate_vc.Value = businessObject.LogOutDate_vc; } this.Command.Parameters.Add(LogOutDate_vc); SqlParameter LogOutTime_vc = new SqlParameter(); LogOutTime_vc.ParameterName = "@LogOutTime_vc"; LogOutTime_vc.SqlDbType = SqlDbType.VarChar; LogOutTime_vc.Direction = ParameterDirection.Input; LogOutTime_vc.IsNullable = true; if (String.IsNullOrEmpty(businessObject.LogOutTime_vc)) { LogOutTime_vc.Value = DBNull.Value; } else { LogOutTime_vc.Value = businessObject.LogOutTime_vc; } this.Command.Parameters.Add(LogOutTime_vc); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.OnlineUserID_int = (Int32)(this.Command.Parameters["@OnlineUserID_int"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }