Ejemplo n.º 1
0
        private void submitLogin_Click(object sender, System.EventArgs e)
        {
            string validEmail;
            string validPassword;
            string validFName;
            string validLName;

            validFName    = txtFName.Text;
            validLName    = txtLName.Text;
            validEmail    = txtEmail.Text;
            validPassword = txtPassword.Text;


            addCust = new WebReference1.adminCustomer();


            string resultAdd = addCust.addCust(validFName, validLName, validEmail, validPassword);

            if (resultAdd == "Success")
            {
                goLogin = new WebReference1.loginCustomer();

                string resultId = goLogin.validCustomer(validEmail, validPassword);


                if (resultId == "-1")
                {
                    addCustLabel.Text = "Unexpected Error!";
                    //this should not occur but if the database returns an error we can handle it here.
                }
                else
                {
                    addCustLabel.Text = "Welcome";
                    Session["userId"] = int.Parse(resultId);
                    Server.Transfer("start.aspx");
                }
            }
            else
            {
                addCustLabel.Text = "Invalid Data please re-enter.";
            }
        }
        public void custGrid_Update(Object sender, DataGridCommandEventArgs e)
        {
            int    upId       = int.Parse(e.Item.Cells[1].Text);
            string upFName    = ((TextBox)e.Item.Cells[2].Controls[0]).Text;
            string upLName    = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
            string upEmail    = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
            string upPassword = ((TextBox)e.Item.Cells[5].Controls[0]).Text;


            myView.RowFilter = "CT_ID='" + upId + "'";
            if (myView.Count > 0)
            {
                myView.Delete(0);
            }
            myView.RowFilter = "";


            DataRow dr = Dt.NewRow();

            dr[0] = upId;
            dr[1] = upFName;
            dr[2] = upLName;
            dr[3] = upEmail;
            dr[4] = upPassword;


            Dt.Rows.Add(dr);

            custGrid.EditItemIndex = -1;
            custGrid.DataSource    = myView;
            custGrid.DataBind();


            // Now update the database with the new data

            WebReference1.adminCustomer newData = new WebReference1.adminCustomer();

            newData.updateCust(upId, upFName, upLName, upEmail, upPassword);
        }