protected void btnSave_Click(object sender, EventArgs e)
        {
            cnum      = cnumlbl.Text;
            firstName = fnamebox.Text;
            lastName  = lnamebox.Text;
            address   = addressbox.Text;


            city        = citybox.Text;
            province    = provincelist.SelectedValue.ToString();
            postalCode  = pcodebox.Text;
            phonenumber = phonebox.Text;

            emailAddress = emailbox.Text;
            notes        = notebox.Text;


            CsCustomer oldCustomerInfo = new CsCustomer(cnum, firstName, lastName, address, city, province, postalCode, phonenumber, emailAddress, notes, registerDate, levels);

            try
            {
                ConnectionClass.UpdateCustomerDetail(oldCustomerInfo);
                ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Updated!');</script>");
            }
            catch
            {
                ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Update failed');</script>");
            }

            finally
            {
                DisableTextBoxes(Page);
                provincelist.Enabled = false;
            }
        }
        // Get Province list into dropdownlist
        // 032 customer_seedetail.aspx page open
        public static void GetCustomerDetail(CsCustomer thecustomer)
        {
            string eQuery = string.Format(@"SELECT * FROM tblCustomer WHERE customerID = ('{0}');", thecustomer.cNumber);

            cmdString = new SqlCommand(eQuery, cntString);

            try
            {
                cntString.Open();

                SqlDataAdapter da = new SqlDataAdapter(cmdString);
                DataTable      dt = new DataTable();
                DataSet        ds = new DataSet();
                da.Fill(dt);
                ds.Tables.Add(dt);

                thecustomer.cFirstName = dt.Rows[0]["fName"].ToString();
                thecustomer.cLastName  = dt.Rows[0]["lName"].ToString();
                thecustomer.cAddress   = dt.Rows[0]["Address"].ToString();
                thecustomer.cCity      = dt.Rows[0]["City"].ToString();

                thecustomer.cProvince     = dt.Rows[0]["Province"].ToString();
                thecustomer.cPhone        = dt.Rows[0]["Phone"].ToString();
                thecustomer.cEmail        = dt.Rows[0]["Email"].ToString();
                thecustomer.cNote         = dt.Rows[0]["Note"].ToString();
                thecustomer.cRegisterDate = dt.Rows[0]["RegisterDate"].ToString();
                thecustomer.cPostalCode   = dt.Rows[0]["PostalCode"].ToString();
            }

            finally
            {
                cntString.Close();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["ONUM"] != null && Session["CNAME"] != null && !IsPostBack)
            {
                lblONum.Text  = Session["ONUM"].ToString();
                lblCName.Text = Session["CNAME"].ToString();
                lblCNum.Text  = Session["CNUM"].ToString();

                Cnum = Session["CNUM"].ToString();

                orderNum = lblONum.Text;

                try
                {
                    CsReceipt recept = new CsReceipt(orderNum, reTable, toTable);
                    ConnectionClass.DisplayReceipt(recept);


                    GridView1.DataSource = recept.ReceiptTable;
                    GridView1.DataBind();

                    CsCustomer thisCustomer = new CsCustomer(Cnum, CFname, CLname, CAddress, Ccity, Cprovince, CPcode,
                                                             CPhone, CEmail, CNote, CRDate, Clv);
                    ConnectionClass.GetCustomerDetail(thisCustomer);

                    lblCEmail.Text = thisCustomer.cEmail;

                    lblOrderDate.Text = recept.TotalTable.Rows[0][4].ToString();
                    lblTQty.Text      = recept.TotalTable.Rows[0][0].ToString();
                    lblTAmt.Text      = recept.TotalTable.Rows[0][1].ToString();
                    lblTTax.Text      = recept.TotalTable.Rows[0][2].ToString();
                    lblGTotal.Text    = recept.TotalTable.Rows[0][3].ToString();
                }

                catch
                {
                    ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>");
                }
                finally
                {
                }
            }



            else
            {
                //ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('No Order');</script>");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["customerNum"] != null && !IsPostBack)
            {
                cnumlbl.Text = Session["customerNum"].ToString();

                cnum = cnumlbl.Text;

                DisableTextBoxes(Page);

                try
                {
                    CsCustomer thatCustomer = new CsCustomer(cnum, firstName, lastName, address, city, province, postalCode, phonenumber, emailAddress, notes, registerDate, levels);

                    ConnectionClass.GetCustomerDetail(thatCustomer);

                    fnamebox.Text   = thatCustomer.cFirstName;
                    lnamebox.Text   = thatCustomer.cLastName;
                    addressbox.Text = thatCustomer.cAddress;
                    citybox.Text    = thatCustomer.cCity;


                    emailbox.Text = thatCustomer.cEmail;
                    phonebox.Text = thatCustomer.cPhone;
                    pcodebox.Text = thatCustomer.cPostalCode;
                    notebox.Text  = thatCustomer.cNote;

                    provincelist.SelectedItem.Text = thatCustomer.cProvince;
                    //provincelist.Enabled = false;
                }

                catch
                {
                    ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>");
                }

                finally
                {
                }
            }

            else if (Session["customerNum"] != null && IsPostBack)
            {
                //provincelist.Enabled = true;
            }
        }
Пример #5
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            firstname  = fnamebox.Text;
            lastname   = lnamebox.Text;
            email      = emailbox.Text;
            phone      = phonebox.Text;
            address    = addressbox.Text;
            city       = citybox.Text;
            province   = provincelist.SelectedValue.ToString();
            postalcode = postalcodebox.Text;
            note       = notebox.Text;

            CsCustomer newcustomer = new CsCustomer(customernum, firstname, lastname, address, city, province, postalcode, phone, email, note, registerdate, level);

            subject = "Thank you for registering, " + fnamebox.Text;
            content = @"<h2 style='color:blue;'> Hello " + fnamebox.Text + " ," + " Your account is created successfully. </h2> ";

            CsRegisterEmail newemail = new CsRegisterEmail(subject, content, email);

            try
            {
                ConnectionClass.RegistrationCustomer(newcustomer);

                ConnectionClass.SendRegisterEmail(newemail);

                ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('New Customer Registered successfully and Confirmation email sent out.');</script>");



                ClearTextBoxes(Page);
                provincelist.ClearSelection();
            }

            catch
            {
                Response.Write("<script type='text/javascript'>");
                Response.Write("alert('please fill out all required fields ');");
                Response.Write("</script>");
            }

            finally
            {
            }
        }
        public static void RegistrationCustomer(CsCustomer customer)
        {
            string cQuery = string.Format(@"INSERT INTO tblCustomer 
            (customerID,fName,lName,Email,Phone,Address,City,Province,PostalCode,Note,RegisterDate)
            VALUES(NEXT VALUE FOR SQcustomer,(N'{0}'),(N'{1}'),('{2}'),('{3}'),(N'{4}'),(N'{5}'),('{6}'),('{7}'),(N'{8}'),GETDATE());",
                                          customer.cFirstName, customer.cLastName, customer.cEmail, customer.cPhone, customer.cAddress, customer.cCity, customer.cProvince, customer.cPostalCode, customer.cNote);

            cmdString = new SqlCommand(cQuery, cntString);

            try
            {
                cntString.Open();
                cmdString.ExecuteNonQuery();
            }

            finally
            {
                cntString.Close();
            }
        }
        // Get Province list into dropdownlist
        // 032 customer_seedetail.aspx press save button

        public static void UpdateCustomerDetail(CsCustomer thiscustomer)
        {
            string fQuery = string.Format(@"UPDATE tblCustomer SET fName=(N'{0}'),lName=(N'{1}'),
            Address=(N'{2}'),City=(N'{3}'),Province=('{4}'),Phone=('{5}'),Email=('{6}'),PostalCode=('{7}'),Note=(N'{8}') WHERE customerID=('{9}');",
                                          thiscustomer.cFirstName, thiscustomer.cLastName, thiscustomer.cAddress, thiscustomer.cCity,
                                          thiscustomer.cProvince, thiscustomer.cPhone, thiscustomer.cEmail, thiscustomer.cPostalCode, thiscustomer.cNote, thiscustomer.cNumber);


            cmdString = new SqlCommand(fQuery, cntString);

            try
            {
                cntString.Open();
                cmdString.ExecuteNonQuery();
            }

            finally
            {
                cntString.Close();
            }
        }