Ejemplo n.º 1
0
        public void Initialize(PageClass page, Control control, string sqlScript)
        {
            Button btn = (Button)control;
            //instantiate onClick event args to pass page and sql script to Click event
            SqlOnClickEventArgs eventArgs = new SqlOnClickEventArgs()
            {
                Page      = page,
                SqlScript = sqlScript
            };

            //wire up Click event and use delegate in order to pass custom event args
            btn.Click += delegate(object sender, EventArgs e)
            {
                btn_Click(sender, eventArgs);
            };
            //Make sure the user can't click the button more than once
            UtilityFunctions.DoubleSubmitPrevention(page, btn);
        }
Ejemplo n.º 2
0
        private void btn_Click(object sender, SqlOnClickEventArgs e)
        {
            //parse any values in the sql script
            string _sqlScript = DataUtils.ParseValues(e.Page.oFacadeObject, e.SqlScript);

            //execute the script that has been parsed
            DataUtils.ExecuteSql(_sqlScript); //any errors get set to Config.LastError
            string message;

            //Check for error and do something for either case
            if (!UtilityFunctions.ER())
            {
                message = "Success";
            }
            else
            {
                message = "Failure";
            }
            Button btn = (Button)sender;

            btn.Text = message;
        }