Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Application Center Admin > C# Button
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 1 Topic 1098 of 1167
Post > Topic >>

C# Button

by =?Utf-8?B?ZGJhY2g=?= <dbach@[EMAIL PROTECTED] > Aug 23, 2007 at 02:24 PM

I have a button on a C# form that requires a double click to fire off the 
btnSubmit_Click event. Is this a bug in VS 2005?

using System;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SalesOrderProgress
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //int t = 0;

            btnSubmit.ID = "btnSubmit";
            lblTime.Text = System.DateTime.Now.ToString();
        }

        private void bindGridView()
        {
            clsDataAccess da=new clsDataAccess();

            Session["strSQL"] = "Exec sopGetProductionHeaderbySales '" + 
txtSalesOrder.Text + "','" + txtPosNo.Text + "','" + txtSalesOrder2.Text +

"','" + txtItem.Text + "','" + txtCustomer.Text + "'";
            Session["SalesOrder"] = txtSalesOrder.Text;

            //DataSet dsSalesProgress = new DataSet();
            //SqlDataAdapter daSalesProgress = new 
SqlDataAdapter(Session["strSQL"].ToString(), 
System.Configuration.ConfigurationManager.AppSettings["MC_Baan_Sql"]);
            //SqlCommandBuilder cmdBldr = new 
SqlCommandBuilder(daSalesProgress);
            //daSalesProgress.Fill(dsSalesProgress);
            //gvSalesProgress.DataSource = dsSalesProgress; 08/01/2007 DOB
2 
different methods to create the dataset

            gvSalesProgress.DataSource = 
da.RunSQLWithDataSet(Session["strSQL"].ToString(), 
System.Configuration.ConfigurationManager.AppSettings["MC_Baan_Sql"]);    
 
            gvSalesProgress.DataBind();
            buildPrintCriteria();

            if (gvSalesProgress.PageCount > 0)
            {
                lblNoRecords.Visible = false;
                gvSalesProgress.Visible = true;
            }
            else
            {
                lblNoRecords.Text = "No records found for " + 
txtSalesOrder.Text;
                lblNoRecords.Visible = true;
                gvSalesProgress.Visible = false;
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            
           try
           {
            lblNoRecords.Visible = false;
            txtCustomer.Text = "";
            txtItem.Text = "";
            
            if (txtPosNo.Text != "" && txtSalesOrder.Text == "")
            {
                lblError.Visible = true;
                lblError.Text = "<p>Please enter a sales order for this 
position</p>";
            }
            else if (txtSalesOrder.Text == "")
            {
                lblError.Visible = true;
                lblError.Text = "<p>Please enter a sales order</p>";
            }
            else
            {
                bindGridView();
            }
           }
           catch(Exception ex)
               {
                   HttpContext.Current.Session["errText"] = ex.Message;
                   throw new Exception("An exception occured in 
btnSubmit_Click", ex);
               }
        }

        protected void btnSubmit2_Click(object sender, EventArgs e)
        {

            try
            {
                lblNoRecords.Visible = false;
                txtSalesOrder.Text = "";
                txtSalesOrder2.Text = "";
                txtPosNo.Text = "";

                if (txtCustomer.Text == "" && txtItem.Text == "")
                {
                    lblError.Visible = true;
                    lblError.Text = "<p>Please enter an Item or
Customer</p>";
                }
                else
                {
                    bindGridView();
                }
            }
            catch (Exception ex)
            {
                HttpContext.Current.Session["errText"] = ex.Message;
                throw new Exception("An exception occured in 
btnSubmit2_Click", ex);
            }
        }

        protected void gvSalesProgress_PageIndexChanging(Object sender, 
GridViewPageEventArgs e)
        {
            gvSalesProgress.PageIndex = e.NewPageIndex;
            bindGridView();
        }

        protected void btnPrint_Click(object sender, EventArgs e)
        {
            Response.Redirect("Printable.aspx?SalesOrder=" + 
Session["SalesOrder"] + "&PosNo=" + Session["PosNo"]);
        }

        private void buildPrintCriteria()
        {
            Session["Criteria"] = "";

            if (txtSalesOrder.Text != "" && txtSalesOrder2.Text != "")
            {
                Session["Criteria"] = " Sales Orders Between <b>" + 
txtSalesOrder.Text + "</b> and <b>" + txtSalesOrder2.Text + "</b>";
            }

            if (txtSalesOrder.Text != "" && txtSalesOrder2.Text == "")
            {
                Session["Criteria"] = " Sales Order <b>" + 
txtSalesOrder.Text + "</b>";
            }

            if (txtItem.Text!= "")
            {
                Session["Criteria"] = " Item <b>" + txtItem.Text + "</b>";
            }

            if (txtCustomer.Text != "")
            {
                Session["Criteria"] = " Customer <b>" + txtCustomer.Text +

"</b>";
            }

        }
    }
}
 




 1 Posts in Topic:
C# Button
=?Utf-8?B?ZGJhY2g=?= <  2007-08-23 14:24:06 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Tue Dec 2 6:44:11 CST 2008.