コード例 #1
0
        public void Update(HPS.BLL.MessageBLL.BLLMessage_T businessObject, HPS.BLL.MessageBLL.BLLMessage_TKeys businessObjectKey)
        {
            try
            {
                if (businessObject.MessageID_bint == businessObjectKey.MessageID_bint)
                {
                    if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "UniqueMessageID_bint") == false)
                    {
                        throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString());
                    }
                }
                else
                {
                    if (businessObject.IsValid() == 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);
            }
        }
コード例 #2
0
        public HPS.BLL.MessageBLL.BLLMessage_T SelectByPrimaryKey(HPS.BLL.MessageBLL.BLLMessage_TKeys businessObjectKey)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_Message_T_SelectByPrimaryKey]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try
            {
                this.Command.Parameters.Clear();

                SqlParameter MessageID_bint = new SqlParameter();
                MessageID_bint.ParameterName = "@MessageID_bint";
                MessageID_bint.SqlDbType     = SqlDbType.BigInt;
                MessageID_bint.Direction     = ParameterDirection.Input;
                MessageID_bint.IsNullable    = false;
                MessageID_bint.Value         = businessObjectKey.MessageID_bint;
                this.Command.Parameters.Add(MessageID_bint);



                if (ControlConnection)
                {
                    this.BeginTransaction();
                }

                IDataReader dataReader = this.Command.ExecuteReader();
                HPS.BLL.MessageBLL.BLLMessage_T businessObject = new HPS.BLL.MessageBLL.BLLMessage_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;
            }
        }
コード例 #3
0
        public List <HPS.BLL.MessageBLL.BLLMessage_T> PopulateObjectsFromReader(IDataReader dataReader)
        {
            List <HPS.BLL.MessageBLL.BLLMessage_T> list = new List <HPS.BLL.MessageBLL.BLLMessage_T>();

            while (dataReader.Read())
            {
                HPS.BLL.MessageBLL.BLLMessage_T businessObject = new HPS.BLL.MessageBLL.BLLMessage_T();
                PopulateBusinessObjectFromReader(businessObject, dataReader);
                list.Add(businessObject);
            }
            return(list);
        }
コード例 #4
0
        public void Insert(HPS.BLL.MessageBLL.BLLMessage_T businessObject)
        {
            try
            {
                if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, "MessageID_bint") == 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);
            }
        }
コード例 #5
0
 protected override void ShowForm()
 {
     this.FillCombo();
     HPS.BLL.MessageBLL.BLLMessage_TFactory MessageFactory = new HPS.BLL.MessageBLL.BLLMessage_TFactory();
     HPS.BLL.MessageBLL.BLLMessage_T        MessageEntity  = MessageFactory.GetBy((HPS.BLL.MessageBLL.BLLMessage_TKeys)Key);
     if (MessageEntity == null)
     {
         throw new HPS.Exceptions.MessageNotFound();
     }
     MessageTitle_nvcTextBox.Text = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageEntity.MessageTitle_nvc, TypeCode.String).ToString();
     Message_nvcTextBox.Text      = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageEntity.Message_nvc, TypeCode.String).ToString();
     StartDate_nvcTextBox.Text    = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageEntity.StartDate_nvc, TypeCode.String).ToString();
     EndDate_nvcTextBox.Text      = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageEntity.EndDate_nvc, TypeCode.String).ToString();
     //    Visited_bitCheckBox.Checked = (Boolean)Hepsa.Core.Common.PersentationController.GetEntityValue(MessageEntity.Visited_bit, TypeCode.Boolean);
     Hepsa.Core.Common.PersentationController.SetComboBoxValue(ref RecipientUserName_nvcComboBox, MessageEntity.RecipientUserName_nvc, TypeCode.String);
 }
コード例 #6
0
        protected override void Insert()
        {
            HPS.BLL.MessageBLL.BLLMessage_TFactory MessageFactory = new HPS.BLL.MessageBLL.BLLMessage_TFactory();
            try
            {
                HPS.BLL.MessageBLL.BLLMessage_T MessageEntity = new HPS.BLL.MessageBLL.BLLMessage_T();
                MessageEntity.MessageTitle_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageTitle_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.Message_nvc      = Hepsa.Core.Common.PersentationController.GetEntityValue(Message_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.StartDate_nvc    = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.EndDate_nvc      = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString();
                ///             MessageEntity.Visited_bit = Visited_bitCheckBox.Checked;
                MessageEntity.RecipientUserName_nvc = (String)Hepsa.Core.Common.PersentationController.GetEntityValue(RecipientUserName_nvcComboBox.SelectedValue, TypeCode.String);
                MessageEntity.UserName_nvc          = HPS.Common.CurrentUser.user.UserName_nvc;

                MessageEntity.Date_nvc = date.ConvertToPersianShortDate();
                MessageEntity.Time_nvc = date.Time;

                MessageFactory.BeginProc();
                MessageFactory.Insert(MessageEntity);
                MessageFactory.CommitProc();
                if (DataTable != null)
                {
                    DataRow dr = this.DataTable.NewRow();
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageID_bint.ToString()]        = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.MessageID_bint, TypeCode.Int64);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageTitle_nvc.ToString()]      = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.MessageTitle_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Message_nvc.ToString()]           = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Message_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.StartDate_nvc.ToString()]         = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.StartDate_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.EndDate_nvc.ToString()]           = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.EndDate_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Visited_bit.ToString()]           = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Visited_bit, TypeCode.Boolean);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.RecipientUserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.RecipientUserName_nvc, TypeCode.String);
                    dr["RecipientUserName_nvcUserName_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(RecipientUserName_nvcComboBox);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Date_nvc.ToString()]     = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Date_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Time_nvc.ToString()]     = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Time_nvc, TypeCode.String);
                    dr[HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.UserName_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.UserName_nvc, TypeCode.String);

                    DataTable.Rows.Add(dr);
                    DataTable.AcceptChanges();
                }
                this.ClearForm(this);
            }
            catch (Exception ex)
            {
                MessageFactory.RollBackProc();
                throw ex;
            }
        }
コード例 #7
0
        protected override void Edit()
        {
            HPS.BLL.MessageBLL.BLLMessage_TFactory MessageFactory = new HPS.BLL.MessageBLL.BLLMessage_TFactory();
            try
            {
                HPS.BLL.MessageBLL.BLLMessage_T MessageEntity = new HPS.BLL.MessageBLL.BLLMessage_T();
                MessageEntity.MessageTitle_nvc = Hepsa.Core.Common.PersentationController.GetEntityValue(MessageTitle_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.Message_nvc      = Hepsa.Core.Common.PersentationController.GetEntityValue(Message_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.StartDate_nvc    = Hepsa.Core.Common.PersentationController.GetEntityValue(StartDate_nvcTextBox.Text, TypeCode.String).ToString();
                MessageEntity.EndDate_nvc      = Hepsa.Core.Common.PersentationController.GetEntityValue(EndDate_nvcTextBox.Text, TypeCode.String).ToString();
                ////              MessageEntity.Visited_bit = Visited_bitCheckBox.Checked;
                MessageEntity.RecipientUserName_nvc = (String)Hepsa.Core.Common.PersentationController.GetEntityValue(RecipientUserName_nvcComboBox.SelectedValue, TypeCode.String);
                MessageEntity.Date_nvc     = date.MyDate.ToShortDateString();
                MessageEntity.Time_nvc     = date.Time;
                MessageEntity.UserName_nvc = HPS.Common.CurrentUser.user.UserName_nvc;

                if (Hepsa.Core.Common.MessageBox.ConfirmMessage(HPS.Exceptions.ExceptionCs.EditMessage) == true)
                {
                    MessageFactory.BeginProc();
                    MessageFactory.Update(MessageEntity, (HPS.BLL.MessageBLL.BLLMessage_TKeys)Key);
                    MessageFactory.CommitProc();
                    if (DataTable != null)
                    {
                        DataRow[] dr = DataTable.Select(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageID_bint.ToString() + "='" + ((HPS.BLL.MessageBLL.BLLMessage_TKeys)Key).MessageID_bint.ToString() + "'");
                        if (dr.Length > 0)
                        {
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageTitle_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.MessageTitle_nvc, TypeCode.String);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Message_nvc.ToString()]      = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Message_nvc, TypeCode.String);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.StartDate_nvc.ToString()]    = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.StartDate_nvc, TypeCode.String);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.EndDate_nvc.ToString()]      = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.EndDate_nvc, TypeCode.String);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Visited_bit.ToString()]      = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Visited_bit, TypeCode.Boolean);
                            dr[0]["RecipientUserName_nvcUserName_nvc"] = Hepsa.Core.Common.PersentationController.GetComboBoxDisplayMember(RecipientUserName_nvcComboBox);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Date_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Date_nvc, TypeCode.String);
                            dr[0][HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Time_nvc.ToString()] = Hepsa.Core.Common.PersentationController.GetEntityValueInDatabaseFormat(MessageEntity.Time_nvc, TypeCode.String);
                        }
                        DataTable.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageFactory.RollBackProc();
                throw ex;
            }
        }
コード例 #8
0
        public void PopulateBusinessObjectFromReader(HPS.BLL.MessageBLL.BLLMessage_T businessObject, IDataReader dataReader)
        {
            businessObject.MessageID_bint   = dataReader.GetInt64(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageID_bint.ToString()));
            businessObject.MessageTitle_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.MessageTitle_nvc.ToString()));
            businessObject.Message_nvc      = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Message_nvc.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.StartDate_nvc.ToString())) == false)
            {
                businessObject.StartDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.StartDate_nvc.ToString()));
            }
            else
            {
                businessObject.StartDate_nvc = String.Empty;
            }

            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.EndDate_nvc.ToString())) == false)
            {
                businessObject.EndDate_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.EndDate_nvc.ToString()));
            }
            else
            {
                businessObject.EndDate_nvc = String.Empty;
            }

            businessObject.Visited_bit = dataReader.GetBoolean(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Visited_bit.ToString()));
            if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.RecipientUserName_nvc.ToString())) == false)
            {
                businessObject.RecipientUserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.RecipientUserName_nvc.ToString()));
            }
            else
            {
                businessObject.RecipientUserName_nvc = String.Empty;
            }

            businessObject.Date_nvc     = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Date_nvc.ToString()));
            businessObject.Time_nvc     = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.Time_nvc.ToString()));
            businessObject.UserName_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.MessageBLL.BLLMessage_T.Message_TField.UserName_nvc.ToString()));
        }
コード例 #9
0
        public void Insert(HPS.BLL.MessageBLL.BLLMessage_T businessObject)
        {
            bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open);

            this.Command.CommandText = "[sp_Message_T_Add]";
            this.Command.CommandType = CommandType.StoredProcedure;

            try
            {
                this.Command.Parameters.Clear();

                SqlParameter MessageID_bint = new SqlParameter();
                MessageID_bint.ParameterName = "@MessageID_bint";
                MessageID_bint.SqlDbType     = SqlDbType.BigInt;
                MessageID_bint.Direction     = ParameterDirection.Output;
                MessageID_bint.IsNullable    = false;
                MessageID_bint.Value         = businessObject.MessageID_bint;
                this.Command.Parameters.Add(MessageID_bint);

                SqlParameter MessageTitle_nvc = new SqlParameter();
                MessageTitle_nvc.ParameterName = "@MessageTitle_nvc";
                MessageTitle_nvc.SqlDbType     = SqlDbType.NVarChar;
                MessageTitle_nvc.Direction     = ParameterDirection.Input;
                MessageTitle_nvc.IsNullable    = false;
                MessageTitle_nvc.Value         = businessObject.MessageTitle_nvc;
                this.Command.Parameters.Add(MessageTitle_nvc);

                SqlParameter Message_nvc = new SqlParameter();
                Message_nvc.ParameterName = "@Message_nvc";
                Message_nvc.SqlDbType     = SqlDbType.NVarChar;
                Message_nvc.Direction     = ParameterDirection.Input;
                Message_nvc.IsNullable    = false;
                Message_nvc.Value         = businessObject.Message_nvc;
                this.Command.Parameters.Add(Message_nvc);

                SqlParameter StartDate_nvc = new SqlParameter();
                StartDate_nvc.ParameterName = "@StartDate_nvc";
                StartDate_nvc.SqlDbType     = SqlDbType.NVarChar;
                StartDate_nvc.Direction     = ParameterDirection.Input;
                StartDate_nvc.IsNullable    = true;
                if (String.IsNullOrEmpty(businessObject.StartDate_nvc))
                {
                    StartDate_nvc.Value = DBNull.Value;
                }
                else
                {
                    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    = true;
                if (String.IsNullOrEmpty(businessObject.EndDate_nvc))
                {
                    EndDate_nvc.Value = DBNull.Value;
                }
                else
                {
                    EndDate_nvc.Value = businessObject.EndDate_nvc;
                }
                this.Command.Parameters.Add(EndDate_nvc);

                SqlParameter Visited_bit = new SqlParameter();
                Visited_bit.ParameterName = "@Visited_bit";
                Visited_bit.SqlDbType     = SqlDbType.Bit;
                Visited_bit.Direction     = ParameterDirection.Input;
                Visited_bit.IsNullable    = false;
                Visited_bit.Value         = businessObject.Visited_bit;
                this.Command.Parameters.Add(Visited_bit);

                SqlParameter RecipientUserName_nvc = new SqlParameter();
                RecipientUserName_nvc.ParameterName = "@RecipientUserName_nvc";
                RecipientUserName_nvc.SqlDbType     = SqlDbType.NVarChar;
                RecipientUserName_nvc.Direction     = ParameterDirection.Input;
                RecipientUserName_nvc.IsNullable    = true;
                if (string.IsNullOrEmpty(businessObject.RecipientUserName_nvc))
                {
                    RecipientUserName_nvc.Value = DBNull.Value;
                }
                else
                {
                    RecipientUserName_nvc.Value = businessObject.RecipientUserName_nvc;
                }
                this.Command.Parameters.Add(RecipientUserName_nvc);

                SqlParameter Date_nvc = new SqlParameter();
                Date_nvc.ParameterName = "@Date_nvc";
                Date_nvc.SqlDbType     = SqlDbType.NVarChar;
                Date_nvc.Direction     = ParameterDirection.Input;
                Date_nvc.IsNullable    = false;
                Date_nvc.Value         = businessObject.Date_nvc;
                this.Command.Parameters.Add(Date_nvc);

                SqlParameter Time_nvc = new SqlParameter();
                Time_nvc.ParameterName = "@Time_nvc";
                Time_nvc.SqlDbType     = SqlDbType.NVarChar;
                Time_nvc.Direction     = ParameterDirection.Input;
                Time_nvc.IsNullable    = false;
                Time_nvc.Value         = businessObject.Time_nvc;
                this.Command.Parameters.Add(Time_nvc);

                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);



                if (ControlConnection)
                {
                    this.BeginTransaction();
                }

                this.Command.ExecuteNonQuery();

                businessObject.MessageID_bint = (Int64?)(this.Command.Parameters["@MessageID_bint"].Value);

                if (ControlConnection)
                {
                    this.Commit();
                }
            }
            catch (System.Exception ex)
            {
                if (ControlConnection)
                {
                    this.RollBack();
                }
                throw ex;
            }
        }