public HPS.BLL.BLLYear_T SelectByPrimaryKey(HPS.BLL.BLLYear_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Year_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter YearID_int = new SqlParameter(); YearID_int.ParameterName = "@YearID_int"; YearID_int.SqlDbType = SqlDbType.Int; YearID_int.Direction = ParameterDirection.Input; YearID_int.IsNullable = false; YearID_int.Value = businessObjectKey.YearID_int; this.Command.Parameters.Add(YearID_int); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.BLLYear_T businessObject = new HPS.BLL.BLLYear_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; } }
public void Insert(HPS.BLL.BLLYear_T businessObject) { try { if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueYearID_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.BLLYear_T> PopulateObjectsFromReader(IDataReader dataReader) { try { List <HPS.BLL.BLLYear_T> list = new List <HPS.BLL.BLLYear_T>(); while (dataReader.Read()) { HPS.BLL.BLLYear_T businessObject = new HPS.BLL.BLLYear_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public void PopulateBusinessObjectFromReader(HPS.BLL.BLLYear_T businessObject, IDataReader dataReader) { try { businessObject.YearID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.YearID_int.ToString())); businessObject.Year_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.Year_nvc.ToString())); businessObject.StartDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.StartDate_nvc.ToString())); businessObject.EndDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.EndDate_nvc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.Description_nvc.ToString())) == false) { businessObject.Description_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.Description_nvc.ToString())); } else { businessObject.Description_nvc = String.Empty; } businessObject.CurrencyID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.CurrencyID_int.ToString())); businessObject.Default_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.Default_bit.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.SourceFiscalYearID_int.ToString())) == false) { businessObject.SourceFiscalYearID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.SourceFiscalYearID_int.ToString())); } else { businessObject.SourceFiscalYearID_int = null; } if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.DataBase_nvc.ToString())) == false) { businessObject.DataBase_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.BLLYear_T.Year_TField.DataBase_nvc.ToString())); } else { businessObject.DataBase_nvc = String.Empty; } } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public void Update(HPS.BLL.BLLYear_T businessObject, HPS.BLL.BLLYear_TKeys businessObjectKey) { try { List <string> ExceptList = new List <string>(); if (businessObject.YearID_int == businessObjectKey.YearID_int) { ExceptList.Add("UniqueYearID_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.BLLYear_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_Year_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try{ this.Command.Parameters.Clear(); SqlParameter YearID_int = new SqlParameter(); YearID_int.ParameterName = "@YearID_int"; YearID_int.SqlDbType = SqlDbType.Int; YearID_int.Direction = ParameterDirection.Output; YearID_int.IsNullable = false; YearID_int.Value = businessObject.YearID_int; this.Command.Parameters.Add(YearID_int); SqlParameter Year_nvc = new SqlParameter(); Year_nvc.ParameterName = "@Year_nvc"; Year_nvc.SqlDbType = SqlDbType.NVarChar; Year_nvc.Direction = ParameterDirection.Input; Year_nvc.IsNullable = false; Year_nvc.Value = businessObject.Year_nvc; this.Command.Parameters.Add(Year_nvc); SqlParameter StartDate_nvc = new SqlParameter(); StartDate_nvc.ParameterName = "@StartDate_nvc"; StartDate_nvc.SqlDbType = SqlDbType.NVarChar; StartDate_nvc.Direction = ParameterDirection.Input; StartDate_nvc.IsNullable = false; StartDate_nvc.Value = businessObject.StartDate_nvc; this.Command.Parameters.Add(StartDate_nvc); SqlParameter EndDate_nvc = new SqlParameter(); EndDate_nvc.ParameterName = "@EndDate_nvc"; EndDate_nvc.SqlDbType = SqlDbType.NVarChar; EndDate_nvc.Direction = ParameterDirection.Input; EndDate_nvc.IsNullable = false; EndDate_nvc.Value = businessObject.EndDate_nvc; this.Command.Parameters.Add(EndDate_nvc); SqlParameter Description_nvc = new SqlParameter(); Description_nvc.ParameterName = "@Description_nvc"; Description_nvc.SqlDbType = SqlDbType.NText; Description_nvc.Direction = ParameterDirection.Input; Description_nvc.IsNullable = true; if (String.IsNullOrEmpty(businessObject.Description_nvc)) { Description_nvc.Value = DBNull.Value; } else { Description_nvc.Value = businessObject.Description_nvc; } this.Command.Parameters.Add(Description_nvc); SqlParameter CurrencyID_int = new SqlParameter(); CurrencyID_int.ParameterName = "@CurrencyID_int"; CurrencyID_int.SqlDbType = SqlDbType.Int; CurrencyID_int.Direction = ParameterDirection.Input; CurrencyID_int.IsNullable = false; CurrencyID_int.Value = businessObject.CurrencyID_int; this.Command.Parameters.Add(CurrencyID_int); SqlParameter Default_bit = new SqlParameter(); Default_bit.ParameterName = "@Default_bit"; Default_bit.SqlDbType = SqlDbType.Bit; Default_bit.Direction = ParameterDirection.Input; Default_bit.IsNullable = false; Default_bit.Value = businessObject.Default_bit; this.Command.Parameters.Add(Default_bit); SqlParameter SourceYearID_int = new SqlParameter(); SourceYearID_int.ParameterName = "@SourceFiscalYearID_int"; SourceYearID_int.SqlDbType = SqlDbType.Int; SourceYearID_int.Direction = ParameterDirection.Input; SourceYearID_int.IsNullable = true; if (businessObject.SourceFiscalYearID_int.HasValue == false) { SourceYearID_int.Value = DBNull.Value; } else { SourceYearID_int.Value = businessObject.SourceFiscalYearID_int; } this.Command.Parameters.Add(SourceYearID_int); SqlParameter DataBase_nvc = new SqlParameter(); DataBase_nvc.ParameterName = "@DataBase_nvc"; DataBase_nvc.SqlDbType = SqlDbType.NVarChar; DataBase_nvc.Direction = ParameterDirection.Input; DataBase_nvc.IsNullable = true; if (String.IsNullOrEmpty(businessObject.DataBase_nvc)) { DataBase_nvc.Value = DBNull.Value; } else { DataBase_nvc.Value = businessObject.DataBase_nvc; } this.Command.Parameters.Add(DataBase_nvc); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.YearID_int = (Int32)(this.Command.Parameters["@YearID_int"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
private void Login_Load(object sender, EventArgs e) { string s = Hepsa.Core.Common.ApplicationInfo.MacAddress; if (string.IsNullOrEmpty(Hepsa.Core.Common.ConnectionString.ConnectionString)) { HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram); sqlManager.ShowDialog(); } HPS.BLL.BLLYear_T year = null; Hepsa.Core.Common.ConnectionString.DataBase = Properties.Settings.Default.DataBaseName; try { LoadFiscalYearCombo(); } catch (Exception ex) { HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram); sqlManager.ShowDialog(); LoadFiscalYearCombo(); } if (HPS.Common.CurrentUser.Year != null) { YearEntity = HPS.Common.CurrentUser.Year; HPS.Common.CurrentUser.Year = null; } //while (true) //{ HPS.BLL.UserBLL.BLLUser_TFactory UserFactory = new HPS.BLL.UserBLL.BLLUser_TFactory(); try { HPS.BLL.VersionBLL.BLLVersion_TFactory VersionFactory = new HPS.BLL.VersionBLL.BLLVersion_TFactory(); string DBVersion_nvc = string.Empty; VersionFactory.SelectLastOldVersion(out DBVersion_nvc); string APPVersion = Assembly.GetEntryAssembly().GetName().Version.ToString(); APPVersion = APPVersion.Substring(0, APPVersion.Length - 2); string[] splitedVersion = APPVersion.Split('.'); if (splitedVersion[1].Length == 1) { splitedVersion[1] = "0" + splitedVersion[1]; } if (splitedVersion[2].Length == 1) { splitedVersion[2] = "0" + splitedVersion[2]; } APPVersion = splitedVersion[0] + "/" + splitedVersion[1] + "/" + splitedVersion[2]; if (string.IsNullOrEmpty(DBVersion_nvc)) { HPS.BLL.VersionBLL.BLLVersion_T VersionEntity = new HPS.BLL.VersionBLL.BLLVersion_T(); VersionEntity.Version_nvc = APPVersion; VersionEntity.Date_nvc = VersionFactory.ServerJalaliDate; VersionEntity.Time_nvc = VersionFactory.ServerTime; VersionFactory.Insert(VersionEntity); } else { // \\172.24.129.5\exe\ // \\192.168.200.50\exe\ // if (DBVersion_nvc.CompareTo(APPVersion) > 0) { throw new ApplicationException("نسخه اجرایی شما قدیمی است لطفاً به روز رسانی نمایید"); } else if (DBVersion_nvc.CompareTo(APPVersion) < 0) { HPS.BLL.VersionBLL.BLLVersion_T VersionEntity = new HPS.BLL.VersionBLL.BLLVersion_T(); VersionEntity.Version_nvc = APPVersion; VersionEntity.Date_nvc = VersionFactory.ServerJalaliDate; VersionEntity.Time_nvc = VersionFactory.ServerTime; VersionFactory.Insert(VersionEntity); } } if (YearEntity != null) { HPS.Common.CurrentUser.Year = YearEntity; } // If FiscalYearEntity IsNot Nothing Then // HPS.Common.CurrentUser.FiscalYear = FiscalYearEntity //End If } catch (Exception ex) { if (ex.Message == "The ConnectionString property has not been initialized.") { HPS.Present.SQL.SQLConnectionManager sqlManager = new HPS.Present.SQL.SQLConnectionManager(HPS.Present.SQL.SQLConnectionManager.enumCloseMode.EndProgram); sqlManager.ShowDialog(); } else { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); Environment.Exit(0); } } finally { } //} try { //TINYLib.Tiny tinylock = new TINYLib.Tiny(); ////tinylock.ServerIP = Hepsa.Core.Common.ConnectionString.Server; //tinylock.Initialize = true; //if (tinylock.TinyErrCode != 0) //{ // throw new ApplicationException("خطا در اتصال به قفل"); //} //tinylock.UserPassWord = "******"; //tinylock.ShowTinyInfo = true; //if (tinylock.TinyErrCode != 0) // throw new ApplicationException("خطا در اتصال به قفل"); //if (tinylock.SerialNumber != "2039-8806-1473") // throw new ApplicationException("قفل مورد استفاده نامعتبر می باشد"); } catch (Exception ex) { Hepsa.Core.Common.MessageBox.ErrorMessage(ex.Message); Environment.Exit(0); } }