Esempio n. 1
0
        protected void uxJobSql_Inserted(object sender, SqlDataSourceStatusEventArgs e)
        {
            //get user id
            MembershipUser usr = Membership.GetUser();
            Guid uid = (Guid)usr.ProviderUserKey;

            //setup database connection
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_MYCHURCH"].ConnectionString);

            //setup a way to talk to the database
            SqlCommand command = new SqlCommand();
            command.Connection = connection;

            try
            {
                command.Connection.Open();
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "ChurchJobs_Insert";

                command.Parameters.Add(new SqlParameter("@UserId", uid));
                command.Parameters.Add(new SqlParameter("@JobID", e.Command.Parameters["@JobID"].Value));

                command.ExecuteNonQuery();

            }
            catch
            {

            }
            finally
            {
                command.Connection.Close();
            }
        }
        //fungsi: Handle Ketika data pada database telah ditambahkan
        protected void dsChangeShiftEdit_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
        {
            //Seleksi apakah terjadi error atau tidak
            //jika tidak ada record yang ter insert maka terjadi error
            if (e.AffectedRows == 0)
            {
                ExceptionDetails.Text = lblCannotUpdate.Text;     //& " (" & e.Exception.Message & ")"
                e.ExceptionHandled    = true;
                if (!isEntrySambung())
                {
                    setInitialComponent();
                }
            }
            else
            {
                //Catat ke Log
                rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "2431", e.Command.Parameters["@NIP"].Value.ToString() + "," + e.Command.Parameters["@TGL_AWAL"].Value.ToString(), Application["strCn"].ToString());
                ExceptionDetails.Text = "Data telah di simpan";

                GvChangeShift.DataBind();
                setInitialComponent();
            }

            if (!isEntrySambung())
            {
                showGridView(true);
            }
        }
Esempio n. 3
0
 protected void sqlAddRepair_Inserted(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.Exception == null || e.ExceptionHandled)
     {
         Response.Redirect("~/admin/admin.aspx");
     }
 }
 protected void SqlDataSourceEscola_Inserted(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.Command.Parameters["@Id_Escola"].Value.ToString() != "")
     {
         Response.Redirect("/Patrimonio/Escola.aspx?Id=" + e.Command.Parameters["@Id_Escola"].Value.ToString());
     }
 }
Esempio n. 5
0
        protected void dbServiceSql_Inserted(object sender, SqlDataSourceStatusEventArgs e)
        {
            //setup database connection
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DB_MYCHURCH"].ConnectionString);

            //setup a way to talk to the database
            SqlCommand command = new SqlCommand();
            command.Connection = connection;

            try
            {
                command.Connection.Open();
                command.CommandType = CommandType.Text;
                command.CommandText = "INSERT INTO SPScheduleService(ScheduleID, ServiceID) VALUES(@ScheduleID, @ServiceID)";
                
                command.Parameters.Add(new SqlParameter("@ServiceID", e.Command.Parameters["@ServiceID"].Value));
                command.Parameters.Add(new SqlParameter("@ScheduleID", sbo.sid.ToString()));

                command.ExecuteNonQuery();

            }
            catch
            {
                litScheduleInfo.Text = "error";
            }
            finally
            {
                command.Connection.Close();
            }
        }
        protected void SqlDataSourceTurma_Inserted(object sender, SqlDataSourceStatusEventArgs e)
        {
            DataTable dt = new DataTable();

            using (SqlConnection SQLconn = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ToString()))
            {

                SqlCommand cmd = new SqlCommand("Select Id_Disciplina from Tb_Disciplina Where Id_Curso = " + ddlCurso.SelectedValue, SQLconn);

                cmd.CommandType = CommandType.Text;

                SQLconn.Open();

                SqlDataAdapter da = new SqlDataAdapter(cmd);

                da.Fill(dt);

                SQLconn.Close();

            }

            if (dt.Rows.Count != 0)
            {

                foreach (DataRow dr in dt.Rows)
                {
                    SqlDataSourceCurso.InsertParameters["Id_Disciplina"].DefaultValue = dr[0].ToString();
                    SqlDataSourceCurso.Insert();
                }

            }
        }
Esempio n. 7
0
		protected internal override IEnumerable ExecuteSelect (
						DataSourceSelectArguments arguments)
		{
			oleCommand = new OleDbCommand (this.SelectCommand, oleConnection);
			SqlDataSourceSelectingEventArgs cmdEventArgs = new SqlDataSourceSelectingEventArgs (oleCommand, arguments);
			OnSelecting (cmdEventArgs);
			IEnumerable enums = null; 
			Exception exception = null;
			OleDbDataReader reader = null;
			try {
				System.IO.File.OpenRead (dataSource.DataFile).Close ();
				oleConnection.Open ();
				reader = (OleDbDataReader)oleCommand.ExecuteReader ();
			
				//enums = reader.GetEnumerator ();
				throw new NotImplementedException("OleDbDataReader doesnt implements GetEnumerator method yet");
			} catch (Exception e) {
				exception = e;
			}
			SqlDataSourceStatusEventArgs statusEventArgs = 
				new SqlDataSourceStatusEventArgs (oleCommand, reader.RecordsAffected, exception);
			OnSelected (statusEventArgs);
			if (exception !=null)
				throw exception;
			return enums;			
		}						
 protected void SqlDataSourceModifica_Deleted(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.Exception != null)
     {
         LabelErrorMessage.Text = "Impossibile eseguire la cancellazione probabilmente l'emento è in uso dalla tabella Strumenti.\n" + e.Exception.Message;
         e.ExceptionHandled = true;
     }
 }
 protected void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e)
 {
     if(e.Exception != null)
     {
         LabelErreur.Text = "Vous ne pouvez pas supprimer ce champs car il est en commande!";
         e.ExceptionHandled = true;
     }
 }
 protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         this.lblTeam.Visible = false;
         this.ddlTeams.Visible = false;
     }
 }
    protected void SqlDataSourceAppointments_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
    {
        SqlConnection connection = (SqlConnection)e.Command.Connection;

        using (SqlCommand command = new SqlCommand("SELECT IDENT_CURRENT('CarScheduling')", connection)) {
            lastInsertedIds.Add(Convert.ToInt32(command.ExecuteScalar()));
        }
    }
 protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         this.lblGames.Visible = true;
         this.Wizard1.Enabled = false;
     }
 }
Esempio n. 13
0
 // DXCOMMENT: This handler is called when a datasource insert operation has been completed
 protected void SchedulingDataSource_Inserted(object sender, SqlDataSourceStatusEventArgs e)
 {
     // DXCOMMENT: This method saves the last inserted appointment's unique identifier
     SqlConnection connection = (SqlConnection)e.Command.Connection;
     using (SqlCommand cmd = new SqlCommand("SELECT IDENT_CURRENT('Appointments')", connection)) {
         this.lastInsertedAppointmentId = Convert.ToInt32(cmd.ExecuteScalar());
     }
 }
Esempio n. 14
0
 protected void allUserGroupsDataSource_Inserted( object sender, SqlDataSourceStatusEventArgs e )
 {
     if ( e.Exception == null )
       {
     int newGroupId = ( int ) e.Command.Parameters["@NewGroupId"].Value;
     Response.Redirect( "~/manageGroup.aspx?group=" + newGroupId );
       }
 }
 protected void Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     int n = e.AffectedRows;
     if (n > 0)
         Label2.Text = string.Format("Numero de Registos {0}", n);
     else
         Label2.Text = "Não existem Registos ";
     return;
 }
 protected void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.Exception != null)
     {
         //ADMIN CANNOT DELETE
         lblError.Text = "YOU CANNOT DELETE USER,   ALREADY IN USE!";
         e.ExceptionHandled = true;
     }
 }
    protected void AppointmentsDataSource_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
    {
        // Autoincremented primary key case
        OleDbConnection connection = (OleDbConnection)e.Command.Connection;

        using (OleDbCommand cmd = new OleDbCommand("SELECT @@IDENTITY", connection)) {
            this.lastInsertedAppointmentId = (int)cmd.ExecuteScalar();
        }
    }
 protected void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e)
 {
     //if (e.Exception != null)
     //{
     //    //ADMIN CANNOT DELETE
     //    lblError1.Text = "YOU CANNOT DELETE QUESTION,   ALREADY IN USE!";
     //    e.ExceptionHandled = true;
     //}
 }
Esempio n. 19
0
        protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
        {
            if (e.Exception != null)
            {
                // Замаскировать ошибку общим сообщением
                LabelError.Text = "Запрос не выполнен";

                // Предположить, что ошибка обработана
                e.ExceptionHandled = true;
            }
        }
 protected void FailMessagesSqlDataSource_Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     //if (DataList1.Items.Count > 0)
     //{
     //    panelFailMessages.Visible = true;
     //}
     //else
     //{
     //    panelFailMessages.Visible = false;
     //}
 }
Esempio n. 21
0
        /*
           * Method that checks for exceptions, and handles them, when the SqlDataSource's Inserted, Updated, Selected and Deleted
           * events are raised.
           */
        protected void CheckForExceptions(object sender, SqlDataSourceStatusEventArgs e)
        {
            //Check if there's an exception
             if (e.Exception != null)
             {
            MessagePanel.Visible = true;
            Message.Text = e.Exception.Message;

            e.ExceptionHandled = true;
             }
        }
        protected virtual void OnDeleted(SqlDataSourceStatusEventArgs e)
        {
            if (!HasEvents())
            {
                return;
            }
            SqlDataSourceStatusEventHandler h = Events [EventDeleted] as SqlDataSourceStatusEventHandler;

            if (h != null)
            {
                h(this, e);
            }
        }
Esempio n. 23
0
 //Method yang dieksekusi setelah melakukan update pada database
 protected void ds_holiday_Updated(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text    = lblCannotUpdate.Text;
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1132", e.Command.Parameters["@TGL_LIBUR"].Value.ToString(), Application["strCn"].ToString());
     }
 }
 protected void dsRangeDetail_Deleted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows != 0)
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1153", e.Command.Parameters["@KODE_RANGE"].Value + " , " + e.Command.Parameters["@KODE_DEPARTEMEN"].Value, Application["strCn"].ToString());
     }
     else
     {
         ExceptionDetails.Text    = lblCannotUpdate.Text + " --> " + e.Exception.Message;
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
 }
        protected void SqlDataSourceTipoEquip_Inserted(object sender, SqlDataSourceStatusEventArgs e)
        {
            try
            {
                Response.Redirect("/Patrimonio/Equipamento.aspx?Id=" + e.Command.Parameters["@RETURN_VALUE"].Value.ToString());

            }
            catch (Exception)
            {

                throw;
            }
        }
 protected void dsParamLembur_Updated(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text = lblNotSaved.Text + " (" + e.Exception.Message + ")";
         e.ExceptionHandled    = true;
     }
     else
     {
         TextBox Kode = (TextBox)GvParamLembur.FooterRow.FindControl("txtKode");
         azlib.AddUserAct(Session["UserID"].ToString(), "1154", e.Command.Parameters["@KODE_LEMBUR"].Value.ToString(), Application["strCn"].ToString());
     }
 }
 protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         this.lblMsg.Text = "<br/>There are no schedules for this tournament yet. If you wish you can schedule it manually or wait until the end of the registration date and the system will do it for you automaticly.<br/>To run the auto scheduler now ";
         this.hlAutoScheduler.Visible = true;
         this.btnExport.Visible = false;
     }
     else
     {
         this.lblMsg.Text = string.Format("{0} matches are set", e.AffectedRows);
     }
 }
Esempio n. 28
0
        protected void CheckLogin(object sender, SqlDataSourceStatusEventArgs e)
        {
            if (e.AffectedRows > 0)
            {
                FormsAuthentication.RedirectFromLoginPage(Logintool.UserName,false);
                Session["user"] = Logintool.UserName;

            }
            else
            {
                Logintool.FailureText = "Invalid Login";
            }
        }
Esempio n. 29
0
 //fungsi: Handle Ketika data pada database telah ditambahkan
 protected void DsReport_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         //menampilkan kesalahan user
         ExceptionDetails.Text = lblNotSaved.Text + " (" + e.Exception.Message + ")";
         e.ExceptionHandled    = true;
     }
     else
     {
         //procedure untuk mencatat event user insert data
         azlib.AddUserAct(Session["UserID"].ToString(), "3301", e.Command.Parameters["@KODE_LAPORAN"].Value.ToString(), Application["strCn"].ToString());
     }
     GvLaporan.ShowFooter = false;
 }
Esempio n. 30
0
 //Method yang dieksekusi setelah melakukan input pada database
 //Fungsinya untuk memerikasa apakah terjadi Error
 protected void ds_holiday_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text    = lblNotSaved.Text + " (" + e.Exception.Message + ")";
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1131", e.Command.Parameters["@TGL_LIBUR"].Value.ToString(), Application["strCn"].ToString());
     }
     GVHoliday.ShowFooter = false;
     showGridView(true);
 }
Esempio n. 31
0
 //fungsi: Handle Ketika data pada database telah diupdate
 protected void DsReport_Updated(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     //Seleksi apakah terjadi error atau tidak
     //jika tidak ada record yang ter update maka terjadi error
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text = lblCannotUpdate.Text;                         //& " (" & e.Exception.Message & ")"
         e.ExceptionHandled    = true;
     }
     else
     {
         //Catat ke Log
         azlib.AddUserAct(Session["UserID"].ToString(), "3302", e.Command.Parameters["@KODE_LAPORAN"].Value.ToString(), Application["strCn"].ToString());
     }
 }
 protected void dsRangeDetail_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text    = e.Exception.Message;
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1151", e.Command.Parameters["@KODE_RANGE"].Value + " , " + e.Command.Parameters["@KODE_DEPARTEMEN"].Value, Application["strCn"].ToString());
     }
     GvTimeCardDetail.ShowFooter = false;
     showGridView(true);
 }
        /// <summary>
        /// Moves to the Next Login page if no records were returned
        /// </summary>
        protected void SqlDataSourceHoldsStatusEventHandler(Object source, SqlDataSourceStatusEventArgs e)
        {
            int rows = e.AffectedRows;

            if (rows == 0)
            {
            hdrHolds.Visible = false;
            Label1.Visible = false;
            }

            if (rows == 0 && !is_grad)
            {
            this.CurrentLoginData.LoginState["HoldsDone"] = true;
            this.NextLoginPage();
            }
        }
Esempio n. 34
0
 //method yang dieksekusi setelah melakukan penginputan ke database
 //setelah input seleksi apakah terjadi error atau tidak
 //jika tidak terjadi error maka catat ke log
 protected void ds_shift3_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         //Session["salahInput"] = lblCannotUpdate.Text; //& " (" & e.Exception.Message & ")"
         ExceptionDetails.Text    = lblCannotUpdate.Text + " (" + e.Exception.Message + ")";
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1121", e.Command.Parameters["@KODE_SHIFT"].Value.ToString(), Application["strCn"].ToString());
     }
     clearFormHarian();
     showGridView(true);
 }
 //fungsi: Handle Ketika data pada database telah didelete
 protected void dsChangeShift_Deleted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     //Seleksi apakah terjadi error atau tidak
     //jika tidak ada record yang ter delete maka terjadi error
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text = lblCannotUpdate.Text;
         e.ExceptionHandled    = true;
     }
     else
     {
         //Catat ke Log
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "2433", e.Command.Parameters["@NIP"].Value.ToString() + "," + e.Command.Parameters["@TGL_AWAL"].Value.ToString(), Application["strCn"].ToString());
     }
     GvChangeShift.DataBind();
 }
Esempio n. 36
0
 protected void dsOtoritasDepartemen_Deleted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     //Seleksi apakah terjadi error atau tidak
     //jika tidak ada record yang ter delete maka terjadi error
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text    = lblCannotEditApproved.Text;                      //e.Exception.Message
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         //Catat ke Log
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "4126", e.Command.Parameters["@USERNAME"].Value + "," + e.Command.Parameters["@KODE_DEPARTEMEN"].Value, Application["strCn"].ToString());
     }
 }
Esempio n. 37
0
 protected void dsUsers_Deleted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     //Seleksi apakah terjadi error atau tidak
     //jika tidak ada record yang ter delete maka terjadi error
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text    = lblCannotUpdate.Text;  //& " (" & e.Exception.Message & ")"
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         //Catat ke Log
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "4123", e.Command.Parameters["@USERNAME"].Value.ToString(), Application["strCn"].ToString());
     }
 }
Esempio n. 38
0
 //method yang dieksekusi setelah melakukan pengupdatean ke database
 protected void ds_Shift_Updated(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         //seleksi apakah terdapat error atau tidak
         //jika tidak terdapat error maka catat ke log lalu redirect ke shift.aspx
         ExceptionDetails.Text    = lblCannotUpdate.Text; // +" (" + e.Exception.Message + ")";
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "1122", e.Command.Parameters["@KODE_SHIFT"].Value.ToString(), Application["strCn"].ToString());
     }
     //clearFormMingguan(false);
     showGridView(true);
 }
Esempio n. 39
0
 protected void dsUsers_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     if (e.AffectedRows == 0)
     {
         //menampilkan kesalahan user
         ExceptionDetails.Text    = lblNotSaved.Text + " (" + e.Exception.Message + ")";
         ExceptionDetails.Visible = true;
         e.ExceptionHandled       = true;
     }
     else
     {
         //procedure untuk mencatat event user insert data
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "4121", e.Command.Parameters["@USERNAME"].Value.ToString(), Application["strCn"].ToString());
     }
     GvUsers.ShowFooter = false;
     showGridView(true);
 }
Esempio n. 40
0
 //fungsi: Handle Ketika data pada database telah diupdate
 protected void dsPunishmentEdit_Updated(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
     //Seleksi apakah terjadi error atau tidak
     //jika tidak ada record yang ter update maka terjadi error
     if (e.AffectedRows == 0)
     {
         ExceptionDetails.Text = lblCannotUpdate.Text;     //& " (" & e.Exception.Message & ")"
         e.ExceptionHandled    = true;
     }
     else
     {
         //Catat ke Log
         rtwin.azlib.AddUserAct(Session["UserID"].ToString(), "2432", e.Command.Parameters["@NIP"].Value.ToString() + "," + e.Command.Parameters["@TGL_AWAL"].Value.ToString(), Application["strCn"].ToString());
     }
     GvPunishment.DataBind();
     showGridView(true);
 }
Esempio n. 41
0
        protected virtual void OnUpdated(SqlDataSourceStatusEventArgs e)
        {
            if (owner.EnableCaching)
            {
                owner.Cache.Expire();
            }

            if (!HasEvents())
            {
                return;
            }
            SqlDataSourceStatusEventHandler h = Events [EventUpdated] as SqlDataSourceStatusEventHandler;

            if (h != null)
            {
                h(this, e);
            }
        }
		protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
		{
			if (!CanDelete)
				throw new NotSupportedException("Delete operation is not supported");
			if (oldValues == null && conflictOptions == ConflictOptions.CompareAllValues)
				throw new InvalidOperationException ("oldValues parameters should be specified when ConflictOptions is set to CompareAllValues");
			command = new SqlCommand (this.DeleteCommand, connection);
			SqlDataSourceCommandEventArgs cmdEventArgs = new SqlDataSourceCommandEventArgs (command);
			OnDeleting (cmdEventArgs);
			connection.Open ();
			Exception exception = null; 
			int result = -1;;
			try {
				result = command.ExecuteNonQuery();
			} catch (Exception e) {
				exception = e;
			}
			SqlDataSourceStatusEventArgs statusEventArgs = new SqlDataSourceStatusEventArgs (command, result, exception);
			OnDeleted (statusEventArgs);
			if (exception != null)
				throw exception;
			return result;
		}
Esempio n. 43
0
 protected void SqlDataSource2_Updated(object sender, SqlDataSourceStatusEventArgs e)
 {
     e.Command.Parameters["@IncomeID"].Value = Session["EditedIncome"];
 }
Esempio n. 44
0
 protected void On_Inserted(object sender, SqlDataSourceStatusEventArgs e)
 {
     GridView1.DataBind();
 }
 protected virtual new void OnSelected(SqlDataSourceStatusEventArgs e)
 {
 }
        private int ExecuteDbCommand(DbCommand command, DataSourceOperation operation)
        {
            int  affectedRows = 0;
            bool flag         = false;

            try
            {
                if (command.Connection.State != ConnectionState.Open)
                {
                    command.Connection.Open();
                }
                affectedRows = command.ExecuteNonQuery();
                if (affectedRows > 0)
                {
                    this.OnDataSourceViewChanged(EventArgs.Empty);
                    DataSourceCache cache = this._owner.Cache;
                    if ((cache != null) && cache.Enabled)
                    {
                        this._owner.InvalidateCacheEntry();
                    }
                }
                flag = true;
                SqlDataSourceStatusEventArgs e = new SqlDataSourceStatusEventArgs(command, affectedRows, null);
                switch (operation)
                {
                case DataSourceOperation.Delete:
                    this.OnDeleted(e);
                    return(affectedRows);

                case DataSourceOperation.Insert:
                    this.OnInserted(e);
                    return(affectedRows);

                case DataSourceOperation.Select:
                    return(affectedRows);

                case DataSourceOperation.Update:
                    this.OnUpdated(e);
                    return(affectedRows);
                }
                return(affectedRows);
            }
            catch (Exception exception)
            {
                bool flag2;
                if (!flag)
                {
                    SqlDataSourceStatusEventArgs args2 = new SqlDataSourceStatusEventArgs(command, affectedRows, exception);
                    switch (operation)
                    {
                    case DataSourceOperation.Delete:
                        this.OnDeleted(args2);
                        break;

                    case DataSourceOperation.Insert:
                        this.OnInserted(args2);
                        break;

                    case DataSourceOperation.Update:
                        this.OnUpdated(args2);
                        break;
                    }
                    if (!args2.ExceptionHandled)
                    {
                        throw;
                    }
                    return(affectedRows);
                }
                exception = this.BuildCustomException(exception, operation, command, out flag2);
                if (flag2)
                {
                    throw exception;
                }
                throw;
            }
            finally
            {
                if (command.Connection.State == ConnectionState.Open)
                {
                    command.Connection.Close();
                }
            }
            return(affectedRows);
        }
        protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            SqlCacheDependency dependency;

            if (this.SelectCommand.Length == 0)
            {
                return(null);
            }
            DbConnection connection = this._owner.CreateConnection(this._owner.ConnectionString);

            if (connection == null)
            {
                throw new InvalidOperationException(System.Web.SR.GetString("SqlDataSourceView_CouldNotCreateConnection", new object[] { this._owner.ID }));
            }
            DataSourceCache cache          = this._owner.Cache;
            bool            flag           = (cache != null) && cache.Enabled;
            string          sortExpression = arguments.SortExpression;

            if (this.CanPage)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Page);
            }
            if (this.CanSort)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort);
            }
            if (this.CanRetrieveTotalRowCount)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount);
            }
            if (flag)
            {
                if (this._owner.DataSourceMode != SqlDataSourceMode.DataSet)
                {
                    throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_CacheNotSupported", new object[] { this._owner.ID }));
                }
                arguments.RaiseUnsupportedCapabilitiesError(this);
                DataSet set = this._owner.LoadDataFromCache(0, -1) as DataSet;
                if (set != null)
                {
                    IOrderedDictionary parameterValues = this.FilterParameters.GetValues(this._context, this._owner);
                    if (this.FilterExpression.Length > 0)
                    {
                        SqlDataSourceFilteringEventArgs args = new SqlDataSourceFilteringEventArgs(parameterValues);
                        this.OnFiltering(args);
                        if (args.Cancel)
                        {
                            return(null);
                        }
                    }
                    return(FilteredDataSetHelper.CreateFilteredDataView(set.Tables[0], sortExpression, this.FilterExpression, parameterValues));
                }
            }
            DbCommand command = this._owner.CreateCommand(this.SelectCommand, connection);

            this.InitializeParameters(command, this.SelectParameters, null);
            command.CommandType = GetCommandType(this.SelectCommandType);
            SqlDataSourceSelectingEventArgs e = new SqlDataSourceSelectingEventArgs(command, arguments);

            this.OnSelecting(e);
            if (e.Cancel)
            {
                return(null);
            }
            string sortParameterName = this.SortParameterName;

            if (sortParameterName.Length > 0)
            {
                if (command.CommandType != CommandType.StoredProcedure)
                {
                    throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_SortParameterRequiresStoredProcedure", new object[] { this._owner.ID }));
                }
                command.Parameters.Add(this._owner.CreateParameter(this.ParameterPrefix + sortParameterName, sortExpression));
                arguments.SortExpression = string.Empty;
            }
            arguments.RaiseUnsupportedCapabilitiesError(this);
            sortExpression = arguments.SortExpression;
            if (this.CancelSelectOnNullParameter)
            {
                int count = command.Parameters.Count;
                for (int i = 0; i < count; i++)
                {
                    DbParameter parameter = command.Parameters[i];
                    if (((parameter != null) && (parameter.Value == null)) && ((parameter.Direction == ParameterDirection.Input) || (parameter.Direction == ParameterDirection.InputOutput)))
                    {
                        return(null);
                    }
                }
            }
            this.ReplaceNullValues(command);
            IEnumerable enumerable = null;

            switch (this._owner.DataSourceMode)
            {
            case SqlDataSourceMode.DataReader:
            {
                if (this.FilterExpression.Length > 0)
                {
                    throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_FilterNotSupported", new object[] { this._owner.ID }));
                }
                if (sortExpression.Length > 0)
                {
                    throw new NotSupportedException(System.Web.SR.GetString("SqlDataSourceView_SortNotSupported", new object[] { this._owner.ID }));
                }
                bool flag4 = false;
                try
                {
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }
                    enumerable = command.ExecuteReader(CommandBehavior.CloseConnection);
                    flag4      = true;
                    SqlDataSourceStatusEventArgs args6 = new SqlDataSourceStatusEventArgs(command, 0, null);
                    this.OnSelected(args6);
                }
                catch (Exception exception2)
                {
                    bool flag5;
                    if (!flag4)
                    {
                        SqlDataSourceStatusEventArgs args7 = new SqlDataSourceStatusEventArgs(command, 0, exception2);
                        this.OnSelected(args7);
                        if (!args7.ExceptionHandled)
                        {
                            throw;
                        }
                        return(enumerable);
                    }
                    exception2 = this.BuildCustomException(exception2, DataSourceOperation.Select, command, out flag5);
                    if (flag5)
                    {
                        throw exception2;
                    }
                    throw;
                }
                return(enumerable);
            }

            case SqlDataSourceMode.DataSet:
                dependency = null;
                if (flag && (cache is SqlDataSourceCache))
                {
                    SqlDataSourceCache cache2 = (SqlDataSourceCache)cache;
                    if (string.Equals(cache2.SqlCacheDependency, "CommandNotification", StringComparison.OrdinalIgnoreCase))
                    {
                        if (!(command is SqlCommand))
                        {
                            throw new InvalidOperationException(System.Web.SR.GetString("SqlDataSourceView_CommandNotificationNotSupported", new object[] { this._owner.ID }));
                        }
                        dependency = new SqlCacheDependency((SqlCommand)command);
                        break;
                    }
                }
                break;

            default:
                return(enumerable);
            }
            DbDataAdapter adapter      = this._owner.CreateDataAdapter(command);
            DataSet       dataSet      = new DataSet();
            int           affectedRows = 0;
            bool          flag2        = false;

            try
            {
                affectedRows = adapter.Fill(dataSet, base.Name);
                flag2        = true;
                SqlDataSourceStatusEventArgs args3 = new SqlDataSourceStatusEventArgs(command, affectedRows, null);
                this.OnSelected(args3);
            }
            catch (Exception exception)
            {
                if (flag2)
                {
                    bool flag3;
                    exception = this.BuildCustomException(exception, DataSourceOperation.Select, command, out flag3);
                    if (flag3)
                    {
                        throw exception;
                    }
                    throw;
                }
                SqlDataSourceStatusEventArgs args4 = new SqlDataSourceStatusEventArgs(command, affectedRows, exception);
                this.OnSelected(args4);
                if (!args4.ExceptionHandled)
                {
                    throw;
                }
            }
            finally
            {
                if (connection.State == ConnectionState.Open)
                {
                    connection.Close();
                }
            }
            DataTable table = (dataSet.Tables.Count > 0) ? dataSet.Tables[0] : null;

            if (flag && (table != null))
            {
                this._owner.SaveDataToCache(0, -1, dataSet, dependency);
            }
            if (table == null)
            {
                return(enumerable);
            }
            IOrderedDictionary values = this.FilterParameters.GetValues(this._context, this._owner);

            if (this.FilterExpression.Length > 0)
            {
                SqlDataSourceFilteringEventArgs args5 = new SqlDataSourceFilteringEventArgs(values);
                this.OnFiltering(args5);
                if (args5.Cancel)
                {
                    return(null);
                }
            }
            return(FilteredDataSetHelper.CreateFilteredDataView(table, sortExpression, this.FilterExpression, values));
        }
Esempio n. 48
0
 protected void sqldtsrc_DebateResults_Selected(object sender, SqlDataSourceStatusEventArgs e)
 {
     DataPager DataPager1 = (DataPager)lstvw_DebateResults.FindControl("DataPager1");
     if (e.AffectedRows <= DataPager1.PageSize)
     {
         DataPager1.Visible = false;
     }
 }
 /// <summary>
 /// Executed when the Sql data source completes a select command.
 /// Retrieves the # of rows fetched by the data source.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void SqlDataSourceStatusEventHandler(object sender, SqlDataSourceStatusEventArgs e)
 {
     rowsSelected = e.AffectedRows;
 }
        /// <summary>
        /// Check if there is almost one user
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SqlDSUsers_Selected(object sender,SqlDataSourceStatusEventArgs e)
        {
            int iRows = e.AffectedRows;

            if (iRows <= 0)
            {
                //ltrlUsers.Text = "There are no users to delete.";
                ltrlUsers.Text = "<p>" + getDictionaryItem("users_NoUsersToDelete") + "</p>";
                btnDeleteUsers.Visible = false;
            }
        }
 protected void WithdrawalHistorySqlDataSource1_Inserted(object sender, SqlDataSourceStatusEventArgs e)
 {
     //MemberSqlDataSource1.UpdateParameters["DepositAmount"].DefaultValue = DepositAmount.ToString();
     //MemberSqlDataSource1.Update();
 }
Esempio n. 52
0
        protected internal override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            if (SortParameterName.Length > 0 && SelectCommandType == SqlDataSourceCommandType.Text)
            {
                throw new NotSupportedException("The SortParameterName property is only supported with stored procedure commands in SqlDataSource");
            }

            if (arguments.SortExpression.Length > 0 && owner.DataSourceMode == SqlDataSourceMode.DataReader)
            {
                throw new NotSupportedException("SqlDataSource cannot sort. Set DataSourceMode to DataSet to enable sorting.");
            }

            if (arguments.StartRowIndex > 0 || arguments.MaximumRows > 0)
            {
                throw new NotSupportedException("SqlDataSource does not have paging enabled. Set the DataSourceMode to DataSet to enable paging.");
            }

            if (FilterExpression.Length > 0 && owner.DataSourceMode == SqlDataSourceMode.DataReader)
            {
                throw new NotSupportedException("SqlDataSource only supports filtering when the data source's DataSourceMode is set to DataSet.");
            }

            InitConnection();

            DbCommand command = factory.CreateCommand();

            command.CommandText = SelectCommand;
            command.Connection  = connection;
            if (SelectCommandType == SqlDataSourceCommandType.Text)
            {
                command.CommandType = CommandType.Text;
            }
            else
            {
                command.CommandType = CommandType.StoredProcedure;
                if (SortParameterName.Length > 0 && arguments.SortExpression.Length > 0)
                {
                    command.Parameters.Add(CreateDbParameter(SortParameterName, arguments.SortExpression));
                }
            }

            if (SelectParameters.Count > 0)
            {
                InitializeParameters(command, SelectParameters, null, null, false);
            }

            Exception exception = null;

            if (owner.DataSourceMode == SqlDataSourceMode.DataSet)
            {
                DataView dataView = null;

                if (owner.EnableCaching)
                {
                    dataView = (DataView)owner.Cache.GetCachedObject(SelectCommand, SelectParameters);
                }

                if (dataView == null)
                {
                    SqlDataSourceSelectingEventArgs selectingArgs = new SqlDataSourceSelectingEventArgs(command, arguments);
                    OnSelecting(selectingArgs);
                    if (selectingArgs.Cancel || !PrepareNullParameters(command, CancelSelectOnNullParameter))
                    {
                        return(null);
                    }
                    try {
                        DbDataAdapter adapter = factory.CreateDataAdapter();
                        DataSet       dataset = new DataSet();

                        adapter.SelectCommand = command;
                        adapter.Fill(dataset, name);

                        dataView = dataset.Tables [0].DefaultView;
                        if (dataView == null)
                        {
                            throw new InvalidOperationException();
                        }
                    }
                    catch (Exception e) {
                        exception = e;
                    }
                    int rowsAffected = (dataView == null) ? 0 : dataView.Count;
                    SqlDataSourceStatusEventArgs selectedArgs = new SqlDataSourceStatusEventArgs(command, rowsAffected, exception);
                    OnSelected(selectedArgs);

                    if (exception != null && !selectedArgs.ExceptionHandled)
                    {
                        throw exception;
                    }

                    if (owner.EnableCaching)
                    {
                        owner.Cache.SetCachedObject(SelectCommand, selectParameters, dataView);
                    }
                }

                if (SortParameterName.Length == 0 || SelectCommandType == SqlDataSourceCommandType.Text)
                {
                    dataView.Sort = arguments.SortExpression;
                }

                if (FilterExpression.Length > 0)
                {
                    IOrderedDictionary fparams            = FilterParameters.GetValues(context, owner);
                    SqlDataSourceFilteringEventArgs fargs = new SqlDataSourceFilteringEventArgs(fparams);
                    OnFiltering(fargs);
                    if (!fargs.Cancel)
                    {
                        object [] formatValues = new object [fparams.Count];
                        for (int n = 0; n < formatValues.Length; n++)
                        {
                            formatValues [n] = fparams [n];
                            if (formatValues [n] == null)
                            {
                                return(dataView);
                            }
                        }
                        dataView.RowFilter = string.Format(FilterExpression, formatValues);
                    }
                }

                return(dataView);
            }
            else
            {
                SqlDataSourceSelectingEventArgs selectingArgs = new SqlDataSourceSelectingEventArgs(command, arguments);
                OnSelecting(selectingArgs);
                if (selectingArgs.Cancel || !PrepareNullParameters(command, CancelSelectOnNullParameter))
                {
                    return(null);
                }

                DbDataReader reader = null;
                bool         closed = connection.State == ConnectionState.Closed;

                if (closed)
                {
                    connection.Open();
                }
                try {
                    reader = command.ExecuteReader(closed ? CommandBehavior.CloseConnection : CommandBehavior.Default);
                }
                catch (Exception e) {
                    exception = e;
                }
                SqlDataSourceStatusEventArgs selectedArgs =
                    new SqlDataSourceStatusEventArgs(command, reader.RecordsAffected, exception);
                OnSelected(selectedArgs);
                if (exception != null && !selectedArgs.ExceptionHandled)
                {
                    throw exception;
                }

                return(reader);
            }
        }
Esempio n. 53
0
        protected override int ExecuteDelete(IDictionary keys, IDictionary oldValues)
        {
            if (!CanDelete)
            {
                throw new NotSupportedException("Delete operation is not supported");
            }
            if (oldValues == null && ConflictDetection == ConflictOptions.CompareAllValues)
            {
                throw new InvalidOperationException("oldValues parameters should be specified when ConflictOptions is set to CompareAllValues");
            }

            InitConnection();

            DbCommand command = factory.CreateCommand();

            command.CommandText = DeleteCommand;
            command.Connection  = connection;
            if (DeleteCommandType == SqlDataSourceCommandType.Text)
            {
                command.CommandType = CommandType.Text;
            }
            else
            {
                command.CommandType = CommandType.StoredProcedure;
            }

            IDictionary oldDataValues;

            if (ConflictDetection == ConflictOptions.CompareAllValues)
            {
                oldDataValues = new Hashtable();
                if (keys != null)
                {
                    foreach (DictionaryEntry de in keys)
                    {
                        oldDataValues [de.Key] = de.Value;
                    }
                }
                if (oldValues != null)
                {
                    foreach (DictionaryEntry de in oldValues)
                    {
                        oldDataValues [de.Key] = de.Value;
                    }
                }
            }
            else
            {
                oldDataValues = keys;
            }

            InitializeParameters(command, DeleteParameters, null, oldDataValues, true);

            SqlDataSourceCommandEventArgs args = new SqlDataSourceCommandEventArgs(command);

            OnDeleting(args);
            if (args.Cancel)
            {
                return(-1);
            }

            bool closed = connection.State == ConnectionState.Closed;

            if (closed)
            {
                connection.Open();
            }
            Exception exception = null;
            int       result    = -1;;

            try {
                result = command.ExecuteNonQuery();
            } catch (Exception e) {
                exception = e;
            }

            if (closed)
            {
                connection.Close();
            }

            OnDataSourceViewChanged(EventArgs.Empty);

            SqlDataSourceStatusEventArgs deletedArgs =
                new SqlDataSourceStatusEventArgs(command, result, exception);

            OnDeleted(deletedArgs);

            if (exception != null && !deletedArgs.ExceptionHandled)
            {
                throw exception;
            }

            return(result);
        }
Esempio n. 54
0
 protected void ResultsDataSource_Selected(object sender, SqlDataSourceStatusEventArgs e) {
     if (e.Exception == null) {
         row_count = e.AffectedRows;
     } else {
         row_count = 0;
     }
     if (row_count == 0) {
         EmptyResultLabel.Text = "<br />No records found";
     } else {
         EmptyResultLabel.Text = "";
     }
 }
Esempio n. 55
0
 //fungsi: Handle Ketika data pada database telah ditambahkan
 protected void dsperformanceEdit_Inserted(object sender, System.Web.UI.WebControls.SqlDataSourceStatusEventArgs e)
 {
 }