Пример #1
0
        /// <summary>
        /// Updates NWS_Source values on Database.
        /// </summary>
        /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param>
        /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param>
        public static void updObject(
            SO_NWS_Source NWS_Source_in,
            bool forceUpdate_in,
            DBConnection dbConnection_in
            )
        {
            if (forceUpdate_in || NWS_Source_in.HasChanges)
            {
                DBConnection _connection = (dbConnection_in == null)
                                        ? DO__Utilities.DBConnection_createInstance(
                    DO__Utilities.DBServerType,
                    DO__Utilities.DBConnectionstring,
                    DO__Utilities.DBLogfile
                    )
                                        : dbConnection_in;

                IDbDataParameter[] _dataparameters = new IDbDataParameter[] {
                    _connection.newDBDataParameter("IDSource_", DbType.Int64, ParameterDirection.Input, NWS_Source_in.IDSource, 0),
                    _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, NWS_Source_in.IFApplication_isNull ? null : (object)NWS_Source_in.IFApplication, 0),
                    _connection.newDBDataParameter("IFSource__parent_", DbType.Int64, ParameterDirection.Input, NWS_Source_in.IFSource__parent_isNull ? null : (object)NWS_Source_in.IFSource__parent, 0),
                    _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, NWS_Source_in.Name, 255),
                    _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Source_in.IFUser__Approved_isNull ? null : (object)NWS_Source_in.IFUser__Approved, 0),
                    _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Source_in.Approved_date_isNull ? null : (object)NWS_Source_in.Approved_date, 0)
                };
                _connection.Execute_SQLFunction(
                    "sp0_NWS_Source_updObject",
                    _dataparameters
                    );
                if (dbConnection_in == null)
                {
                    _connection.Dispose();
                }
                NWS_Source_in.HasChanges = false;
            }
        }
Пример #2
0
        public static long insObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            SO_NWS_Source source_in,
            bool selectIdentity_in,

            out int[] errors_out
            )
        {
            long _output = -1L;

            Guid        _sessionguid;
            Sessionuser _sessionuser;

            #region check...
            List <int> _errorlist;
            if (!check(
                    sessionGuid_in,
                    ip_forLogPurposes_in,

                    ref source_in,

                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist
                    ))
            {
                errors_out = _errorlist.ToArray();
                return(_output);
            }
            #endregion

            if (_sessionuser.hasPermission(PermissionType.Source__approve))
            {
                source_in.Approved_date    = DateTime.Now;
                source_in.IFUser__Approved = _sessionuser.IDUser;
            }
            else
            {
                source_in.Approved_date_isNull    = true;
                source_in.IFUser__Approved_isNull = true;
            }
            source_in.IFApplication = _sessionuser.IDApplication;
            _output = DO_NWS_Source.insObject(
                source_in,
                selectIdentity_in,

                null
                );
            _errorlist.Add(ErrorType.source__successfully_created__WARNING);

            errors_out = _errorlist.ToArray();
            return(_output);
        }
Пример #3
0
 /// <summary>
 /// Updates NWS_Source values on Database.
 /// </summary>
 /// <param name="forceUpdate_in">assign with True if you wish to force an Update (even if no changes have been made since last time getObject method was run) and False if not</param>
 public static void updObject(
     SO_NWS_Source NWS_Source_in,
     bool forceUpdate_in
     )
 {
     updObject(
         NWS_Source_in,
         forceUpdate_in,
         null
         );
 }
Пример #4
0
 /// <summary>
 /// Inserts NWS_Source values into Database.
 /// </summary>
 /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param>
 /// <returns>insertion sequence/identity seed</returns>
 public static long insObject(
     SO_NWS_Source NWS_Source_in,
     bool selectIdentity_in
     )
 {
     return(insObject(
                NWS_Source_in,
                selectIdentity_in,
                null
                ));
 }
Пример #5
0
        public static SO_NWS_Source getObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            long idSource_in,

            out int[] errors_out
            )
        {
            SO_NWS_Source _output = null;
            List <int>    _errorlist;
            Guid          _sessionguid;
            Sessionuser   _sessionuser;

            #region check...
            if (!SBO_CRD_Authentication.isSessionGuid_valid(
                    sessionGuid_in,
                    ip_forLogPurposes_in,
                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist,
                    out errors_out
                    ))
            {
                //// no need!
                //errors_out = _errors.ToArray();

                return(_output);
            }
            #endregion
            #region check Permissions . . .
            if (
                !_sessionuser.hasPermission(
                    PermissionType.Source__select
                    )
                )
            {
                _errorlist.Add(ErrorType.source__lack_of_permissions_to_read);
                errors_out = _errorlist.ToArray();
                return(_output);
            }
            #endregion

            _output = DO_NWS_Source.getObject(
                idSource_in,

                null
                );

            errors_out = _errorlist.ToArray();
            return(_output);
        }
Пример #6
0
 private void btn_save_click(
     ref SO_NWS_Source source_ref
     )
 {
     source_ref.Name = this.TXT_Name.Text;
     #region source_ref.IFSource__parent = long.Parse(this.DDL_Source_parent.SelectedValue);
     if (string.IsNullOrEmpty(this.DDL_Source_parent.SelectedValue))
     {
         source_ref.IFSource__parent_isNull = true;
     }
     else
     {
         //source_ref.IFSource__parent = DDL_Source_parent.Kick.SelectedValue__get<long>();
         source_ref.IFSource__parent = long.Parse(
             this.DDL_Source_parent.SelectedValue,
             System.Globalization.NumberStyles.Integer,
             System.Globalization.CultureInfo.CurrentCulture
             );
     }
     #endregion
 }
Пример #7
0
        /// <summary>
        /// Inserts NWS_Source values into Database.
        /// </summary>
        /// <param name="selectIdentity_in">assign with True if you wish to retrieve insertion sequence/identity seed and with False if not</param>
        /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param>
        /// <returns>insertion sequence/identity seed</returns>
        public static long insObject(
            SO_NWS_Source NWS_Source_in,
            bool selectIdentity_in,
            DBConnection dbConnection_in
            )
        {
            DBConnection _connection = (dbConnection_in == null)
                                ? DO__Utilities.DBConnection_createInstance(
                DO__Utilities.DBServerType,
                DO__Utilities.DBConnectionstring,
                DO__Utilities.DBLogfile
                )
                                : dbConnection_in;

            IDbDataParameter[] _dataparameters = new IDbDataParameter[] {
                _connection.newDBDataParameter("IDSource_", DbType.Int64, ParameterDirection.Output, null, 0),
                _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Input, NWS_Source_in.IFApplication_isNull ? null : (object)NWS_Source_in.IFApplication, 0),
                _connection.newDBDataParameter("IFSource__parent_", DbType.Int64, ParameterDirection.Input, NWS_Source_in.IFSource__parent_isNull ? null : (object)NWS_Source_in.IFSource__parent, 0),
                _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Input, NWS_Source_in.Name, 255),
                _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Input, NWS_Source_in.IFUser__Approved_isNull ? null : (object)NWS_Source_in.IFUser__Approved, 0),
                _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Input, NWS_Source_in.Approved_date_isNull ? null : (object)NWS_Source_in.Approved_date, 0),

                _connection.newDBDataParameter("SelectIdentity_", DbType.Boolean, ParameterDirection.Input, selectIdentity_in, 1)
            };
            _connection.Execute_SQLFunction(
                "sp0_NWS_Source_insObject",
                _dataparameters
                );
            if (dbConnection_in == null)
            {
                _connection.Dispose();
            }

            NWS_Source_in.IDSource = (long)_dataparameters[0].Value; NWS_Source_in.HasChanges = false;


            return(NWS_Source_in.IDSource);
        }
Пример #8
0
        public void BTN_Save_Click(object sender, EventArgs e)
        {
            int[]         _errors;
            SO_NWS_Source _source;

            if (
                #region ((_source = ...) != null)
                (this.IDSource > 0)
                &&
                (
                    (_source = BusinessInstances.NWS_Source.InstanceClient.getObject(
                         Utilities.User.SessionGuid,
                         Utilities.ClientIPAddress,
                         this.IDSource,
                         out _errors
                         ))
                    !=
                    null
                )
                &&
                !this.Master__base.Error_add(_errors)
                #endregion
                )
            {
                this.btn_save_click(
                    ref _source
                    );

                BusinessInstances.NWS_Source.InstanceClient.updObject(
                    Utilities.User.SessionGuid,
                    Utilities.ClientIPAddress,
                    _source,
                    out _errors
                    );
            }
            else
            {
                _source = new SO_NWS_Source();

                this.btn_save_click(
                    ref _source
                    );

                _source.Approved_date_isNull    = true;
                _source.IFUser__Approved_isNull = true;
                _source.IFApplication           = Utilities.IDApplication;
                BusinessInstances.NWS_Source.InstanceClient.insObject(
                    Utilities.User.SessionGuid,
                    Utilities.ClientIPAddress,
                    _source,
                    false,
                    out _errors
                    );
            }
            if (!this.Master__base.Error_add(_errors))
            {
                Response.Redirect(
                    "NWS-NewsSource-list.aspx",
                    true
                    );
            }
        }
Пример #9
0
        /// <summary>
        /// Selects NWS_Source values from Database and assigns them to the appropriate DO_NWS_Source property.
        /// </summary>
        /// <param name="IDSource_in">IDSource</param>
        /// <param name="dbConnection_in">Database connection, making the use of Database Transactions possible on a sequence of operations across the same or multiple DataObjects</param>
        /// <returns>null if NWS_Source doesn't exists at Database</returns>
        public static SO_NWS_Source getObject(
            long IDSource_in,
            DBConnection dbConnection_in
            )
        {
            SO_NWS_Source _output = null;

            DBConnection _connection = (dbConnection_in == null)
                                ? DO__Utilities.DBConnection_createInstance(
                DO__Utilities.DBServerType,
                DO__Utilities.DBConnectionstring,
                DO__Utilities.DBLogfile
                )
                                : dbConnection_in;

            IDbDataParameter[] _dataparameters = new IDbDataParameter[] {
                _connection.newDBDataParameter("IDSource_", DbType.Int64, ParameterDirection.InputOutput, IDSource_in, 0),
                _connection.newDBDataParameter("IFApplication_", DbType.Int32, ParameterDirection.Output, null, 0),
                _connection.newDBDataParameter("IFSource__parent_", DbType.Int64, ParameterDirection.Output, null, 0),
                _connection.newDBDataParameter("Name_", DbType.AnsiString, ParameterDirection.Output, null, 255),
                _connection.newDBDataParameter("IFUser__Approved_", DbType.Int64, ParameterDirection.Output, null, 0),
                _connection.newDBDataParameter("Approved_date_", DbType.DateTime, ParameterDirection.Output, null, 0)
            };
            _connection.Execute_SQLFunction("sp0_NWS_Source_getObject", _dataparameters);
            if (dbConnection_in == null)
            {
                _connection.Dispose();
            }

            if (_dataparameters[0].Value != DBNull.Value)
            {
                _output = new SO_NWS_Source();

                if (_dataparameters[0].Value == System.DBNull.Value)
                {
                    _output.IDSource = 0L;
                }
                else
                {
                    _output.IDSource = (long)_dataparameters[0].Value;
                }
                if (_dataparameters[1].Value == System.DBNull.Value)
                {
                    _output.IFApplication_isNull = true;
                }
                else
                {
                    _output.IFApplication = (int)_dataparameters[1].Value;
                }
                if (_dataparameters[2].Value == System.DBNull.Value)
                {
                    _output.IFSource__parent_isNull = true;
                }
                else
                {
                    _output.IFSource__parent = (long)_dataparameters[2].Value;
                }
                if (_dataparameters[3].Value == System.DBNull.Value)
                {
                    _output.Name = string.Empty;
                }
                else
                {
                    _output.Name = (string)_dataparameters[3].Value;
                }
                if (_dataparameters[4].Value == System.DBNull.Value)
                {
                    _output.IFUser__Approved_isNull = true;
                }
                else
                {
                    _output.IFUser__Approved = (long)_dataparameters[4].Value;
                }
                if (_dataparameters[5].Value == System.DBNull.Value)
                {
                    _output.Approved_date_isNull = true;
                }
                else
                {
                    _output.Approved_date = (DateTime)_dataparameters[5].Value;
                }

                _output.HasChanges = false;
                return(_output);
            }

            return(null);
        }
Пример #10
0
        private static SO_NWS_Source[] getRecord(
            DataTable dataTable_in
            )
        {
            DataColumn _dc_idsource         = null;
            DataColumn _dc_ifapplication    = null;
            DataColumn _dc_ifsource__parent = null;
            DataColumn _dc_name             = null;
            DataColumn _dc_ifuser__approved = null;
            DataColumn _dc_approved_date    = null;

            SO_NWS_Source[] _output
                = new SO_NWS_Source[dataTable_in.Rows.Count];
            for (int r = 0; r < dataTable_in.Rows.Count; r++)
            {
                if (r == 0)
                {
                    _dc_idsource         = dataTable_in.Columns["IDSource"];
                    _dc_ifapplication    = dataTable_in.Columns["IFApplication"];
                    _dc_ifsource__parent = dataTable_in.Columns["IFSource__parent"];
                    _dc_name             = dataTable_in.Columns["Name"];
                    _dc_ifuser__approved = dataTable_in.Columns["IFUser__Approved"];
                    _dc_approved_date    = dataTable_in.Columns["Approved_date"];
                }

                _output[r] = new SO_NWS_Source();
                if (dataTable_in.Rows[r][_dc_idsource] == System.DBNull.Value)
                {
                    _output[r].IDSource = 0L;
                }
                else
                {
                    _output[r].IDSource = (long)dataTable_in.Rows[r][_dc_idsource];
                }
                if (dataTable_in.Rows[r][_dc_ifapplication] == System.DBNull.Value)
                {
                    _output[r].IFApplication_isNull = true;
                }
                else
                {
                    _output[r].IFApplication = (int)dataTable_in.Rows[r][_dc_ifapplication];
                }
                if (dataTable_in.Rows[r][_dc_ifsource__parent] == System.DBNull.Value)
                {
                    _output[r].IFSource__parent_isNull = true;
                }
                else
                {
                    _output[r].IFSource__parent = (long)dataTable_in.Rows[r][_dc_ifsource__parent];
                }
                if (dataTable_in.Rows[r][_dc_name] == System.DBNull.Value)
                {
                    _output[r].Name = string.Empty;
                }
                else
                {
                    _output[r].Name = (string)dataTable_in.Rows[r][_dc_name];
                }
                if (dataTable_in.Rows[r][_dc_ifuser__approved] == System.DBNull.Value)
                {
                    _output[r].IFUser__Approved_isNull = true;
                }
                else
                {
                    _output[r].IFUser__Approved = (long)dataTable_in.Rows[r][_dc_ifuser__approved];
                }
                if (dataTable_in.Rows[r][_dc_approved_date] == System.DBNull.Value)
                {
                    _output[r].Approved_date_isNull = true;
                }
                else
                {
                    _output[r].Approved_date = (DateTime)dataTable_in.Rows[r][_dc_approved_date];
                }

                _output[r].HasChanges = false;
            }

            return(_output);
        }
Пример #11
0
        private static bool check(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            ref SO_NWS_Source source_ref,

            out Guid sessionGuid_out,
            out Sessionuser sessionUser_out,
            out List <int> errorlist_out
            )
        {
            #region check...
            if (!SBO_CRD_Authentication.isSessionGuid_valid(
                    sessionGuid_in,
                    ip_forLogPurposes_in,
                    out sessionGuid_out,
                    out sessionUser_out,
                    out errorlist_out
                    ))
            {
                return(false);
            }
            #endregion
            #region check Permissions . . .
            if (
                !sessionUser_out.hasPermission(
                    false,
                    PermissionType.Source__insert,
                    PermissionType.Source__update
                    )
                )
            {
                errorlist_out.Add(ErrorType.source__lack_of_permissions_to_write);
                return(false);
            }

            if (
                !sessionUser_out.hasPermission(PermissionType.Source__approve)
                &&
                (
                    !source_ref.Approved_date_isNull
                    ||
                    !source_ref.IFUser__Approved_isNull
                )
                )
            {
                errorlist_out.Add(ErrorType.source__lack_of_permissions_to_approve);
                return(false);
            }
            #endregion

            // ToDos: here! check parent existence
            // ToDos: here! check if parent within same application
            // ToDos: here! check if any other checkings needed ...
            if (source_ref.IFSource__parent <= 0)
            {
                source_ref.IFSource__parent_isNull = true;
            }

            #region check Source ...
            if (
                (source_ref.Name = source_ref.Name.Trim()).Length == 0
                )
            {
                errorlist_out.Add(ErrorType.source__invalid_name);
                return(false);
            }
            #endregion

            return(true);
        }
Пример #12
0
        public static void updObject(
            string sessionGuid_in,
            string ip_forLogPurposes_in,

            SO_NWS_Source source_in,

            out int[] errors_out
            )
        {
            Guid        _sessionguid;
            Sessionuser _sessionuser;

            #region check...
            List <int> _errorlist;
            if (!check(
                    sessionGuid_in,
                    ip_forLogPurposes_in,

                    ref source_in,

                    out _sessionguid,
                    out _sessionuser,
                    out _errorlist
                    ))
            {
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion
            #region check existence . . .
            SO_NWS_Source _source;
            if (
                source_in.IDSource <= 0
                ||
                (
                    (_source = DO_NWS_Source.getObject(
                         source_in.IDSource
                         )) == null
                )
                )
            {
                _errorlist.Add(ErrorType.data__not_found);
                errors_out = _errorlist.ToArray();
                return;
            }
            #endregion

            if (
                _source.IFUser__Approved_isNull
                ||
                _source.Approved_date_isNull
                )
            {
                if (_sessionuser.hasPermission(PermissionType.Source__approve))
                {
                    source_in.Approved_date    = DateTime.Now;
                    source_in.IFUser__Approved = _sessionuser.IDUser;
                }
                else
                {
                    source_in.Approved_date_isNull    = true;
                    source_in.IFUser__Approved_isNull = true;
                }
            }
            else
            {
                source_in.Approved_date    = _source.Approved_date;
                source_in.IFUser__Approved = _source.IFUser__Approved;
            }

            source_in.IFApplication = _source.IFApplication;
            DO_NWS_Source.updObject(
                source_in,
                true,

                null
                );
            _errorlist.Add(ErrorType.source__successfully_updated__WARNING);

            errors_out = _errorlist.ToArray();
        }