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; } }
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 { } }
// WHOLE LIST public void InvoiceListView() { CsInvoice list = new CsInvoice(InvoiceTable); try { ConnectionClass.DisplayInvoice(list); InvoiceList.DataSource = list.InvoiceList; InvoiceList.DataBind(); } catch { TEST.Text = "Error Occured, Please try reloading page. Sorry for inconvenience"; } finally { } }
public void ItemListView() { CsItemlist itemlist = new CsItemlist(itemTable); try { ConnectionClass.GetItemList(itemlist); itemListBoard.DataSource = itemlist.itemList; itemListBoard.DataBind(); } catch { testlabel.Text = "Error Occured, Please try reloading page. Sorry for inconvenience"; } finally { } }
void ItemViewByCat(string catName) { PagedDataSource pgd = new PagedDataSource(); if (catName == "All") { try { CsItemlist pos = new CsItemlist(itemTable); ConnectionClass.GetItemAll(pos); pgd.DataSource = pos.itemList.DefaultView; } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Sorry, Error Occured during the process, Please select again, ');</script>"); } } else { try { //PagedDataSource pgd = new PagedDataSource(); CsFilteredItemList flist = new CsFilteredItemList(catName, knote, itemTable); ConnectionClass.GetItemByCat(flist); pgd.DataSource = flist.fiTable.DefaultView; } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>"); } //finally } pgd.CurrentPageIndex = CurrentPageIndex; pgd.AllowPaging = true; pgd.PageSize = 8; itemLists.DataSource = pgd; itemLists.DataBind(); BtnPrevious.Enabled = !(pgd.IsLastPage); BtnNext.Enabled = !(pgd.IsFirstPage); }
public void FilterInvoiceByNumber() { KeyWordNum = keywordbox.Text; CsSearchInvoice filist = new CsSearchInvoice(KeyWordName, KeyWordNum, InvoiceTable); try { ConnectionClass.SearchInvoiceByNum(filist); InvoiceList.DataSource = filist.Invoicelist; InvoiceList.DataBind(); } catch { TEST.Text = "Error Occured, Please try reloading page. Sorry for inconvenience"; } finally { } }
protected void btnUpdate_Click(object sender, EventArgs e) { AbleTextBoxes(Page); provincelist.SelectedItem.Text = "- Please select province - "; CsProvincelist ProvinceList = new CsProvincelist(ProvinceTable); ConnectionClass.GetPVlist(ProvinceList); provincelist.DataSource = ProvinceList.Provinces; provincelist.DataTextField = ProvinceList.Provinces.Columns["provinceName"].ToString(); provincelist.DataValueField = ProvinceList.Provinces.Columns["provinceCode"].ToString(); provincelist.DataBind(); //provincelist.Enabled = true; btnUpdate.Visible = false; btnSave.Visible = true; }
protected void btnlogin_Click(object sender, EventArgs e) { username = uname.Text; password = pword.Text; CsUserlist userinfo = new CsUserlist(username, password); if (ConnectionClass.SignIn(userinfo)) { FormsAuthentication.RedirectFromLoginPage(username, CheckBox.Checked); } else { Response.Write("<script type='text/javascript'>"); Response.Write("alert('Please check your username and password');"); Response.Write("</script>"); } }
public void SearchListView() { nameKeyword = Session["SearchName"].ToString(); CsFilteredCustomerList nfcustomerlist = new CsFilteredCustomerList(nameKeyword, emailKeyword, CustomerTable); try { ConnectionClass.SearchCustomerByName(nfcustomerlist); CustomerList.DataSource = nfcustomerlist.fCustomerList; CustomerList.DataBind(); } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>"); } finally { } }
public void CustomerListView() { CsCustomerlist customerlists = new CsCustomerlist(CustomerTable); try { ConnectionClass.GetCustomerList(customerlists); cListBoard.DataSource = customerlists.customerList; cListBoard.DataBind(); } catch { testlabel.Text = "fail"; } finally { } }
protected void Page_Load(object sender, EventArgs e) { if (Session["itemNum"] != null && !IsPostBack) { inumlbl.Text = Session["itemNum"].ToString(); // update 이전: 텍스트박스+ 드롭다운리스트 disabled, 업로드버튼 invisible btnUpload.Visible = false; DisableTextBoxes(Page); iID = inumlbl.Text; try { CsItem theitem = new CsItem(iID, iCategory, iName, iPPrice, iRPrice, iNote, iImage, iQuantity, iRday); ConnectionClass.GetItemDetails(theitem); // NO CURRENCY DISPLAY (FOR EASILY UPDATING) CategoryList.SelectedItem.Text = theitem.itemCategory; iNameBox.Text = theitem.itemName; qtyList.SelectedItem.Text = theitem.itemQuantity; notebox.Text = theitem.itemNote; pPriceBox.Text = theitem.itemPPrice; rPriceBox.Text = theitem.itemRPrice; testimg.ImageUrl = theitem.itemImage; imgURL.Text = theitem.itemImage; } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>"); } finally { } } }
protected void Page_Load(object sender, EventArgs e) { try { CsDailyReport TodayReport = new CsDailyReport(tnum, TableA, TableB, TableC, TableD, TableE, TableF, TableG); ConnectionClass.DisplayReport(TodayReport); ReportA.DataSource = TodayReport.aTable; ReportA.DataBind(); ReportB.DataSource = TodayReport.bTable; ReportB.DataBind(); ReportC.DataSource = TodayReport.cTable; ReportC.DataBind(); ReportD.DataSource = TodayReport.dTable; ReportD.DataBind(); ReportE.DataSource = TodayReport.fTable; ReportE.DataBind(); ReportF.DataSource = TodayReport.gTable; ReportF.DataBind(); } catch { } finally { } }
protected void btnEmail_Click(object sender, EventArgs e) { email = lblCEmail.Text; subject = "Thank you for your purchase, " + lblCName.Text; string content1 = "<body style=\"text-align:center; background-color:#d8dfe5; padding-right:20%; padding-left:20%; \">"; string content2 = " <p style=\"font-size:20px;\"> Thank you for your purchase this time, Below is receipt details</p>" + "<br>"; string content3 = " <p style=\"font-size:14px; font-family:verdana; text-align:left;\"> Receipt # " + lblONum.Text + "</p>"; string content4 = GridViewToHtml(GridView1) + "<br>"; string content5 = "<div style=\"text-align:right; font-size:16px; \">"; string content6 = "Sales Quantity Total: " + lblTQty.Text + "<br>"; string content7 = "Net Total : " + lblTAmt.Text + "<br>"; string content8 = "Grand Total: " + lblGTotal.Text + "</div> <br>"; string content9 = "<p style=\"color:#405359; \"> For all returns, please bring this receipt with you </p>" + "</body>"; content = content1 + content2 + content3 + content4 + content5 + content6 + content7 + content8 + content9; CsRegisterEmail newemail = new CsRegisterEmail(subject, content, email); try { ConnectionClass.SendRegisterEmail(newemail); ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('email sent out.');</script>"); } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('error');</script>"); } finally { } }
protected void CheckOut(object sender, EventArgs e) { if (subTotal.Text == "0" && lblCustomerNumber.Text == "-") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Choose Item and Customer');</script>"); } else if (lblCustomerNumber.Text == "-" && subTotal.Text != "0") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Select Customer (Use Search box above)');</script>"); } else if (lblCustomerNumber.Text != "-" && subTotal.Text == "0") { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please Add Items to Cart');</script>"); } else { // CUSTOMER NUMBER FROM SEARCH WINDOW CustomerNum = lblCustomerNumber.Text; try { CsOrder newOrder = new CsOrder(OrderNum, CustomerNum, OrderDate); // INSERT ORDER + GET ORDER NUMBER ConnectionClass.CreateOrder(newOrder); // INSERT ORDER NUMBER INTO ORDERITEM TABLE (ITABLE) for (int a = 0; a < iTable.Rows.Count; a++) { iTable.Rows[a]["orderno"] = newOrder.OrderNumber; } // REBUILD GRIDVIEW //GridView1.DataSource = iTable; //GridView1.DataBind(); // UPLOAD ORDERITEM TABLE (ITABLE) ConnectionClass.UploadOrderItem(iTable); // PASS SESSION VALUE (ORDER NUMBER) Session["ONUM"] = newOrder.OrderNumber; Session["CNAME"] = lblCustomerName.Text; Session["CNUM"] = lblCustomerNumber.Text; // EMPTY ITABLE //Session["iTable"] = null; iTable.Clear(); //subTotal.Text = "0"; //grandTotal.Text = "0"; //GridView1.DataSource = iTable; //GridView1.DataBind(); //lblCustomerName.Text = " "; //lblCustomerNumber.Text = "-"; //SUCCESS MESSAGE ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Order Confirmed');</script>"); ClientScript.RegisterStartupScript(this.Page.GetType(), "", "window.open('012pos_seeOrderReceipt.aspx','window','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,height=350,width=700,left=130,top=220');", true); Page.ClientScript.RegisterStartupScript(this.GetType(), "refresh", "window.location.href=window.location;", true); } catch { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Error Occured,Please try again later. ');</script>"); } finally { } } }
// SELECT ITEM (BY CLICK ITEM IMAGE) protected void SelectItem(object sender, EventArgs e) { if (Session["ii"] == null) { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('Please select quantity ');</script>"); } else { ImageButton ibtn = (ImageButton)(sender); string itemNo = Convert.ToString(ibtn.CommandArgument); CsItem theitem = new CsItem(itemNo, iCategory, iName, iPPrice, iRPrice, iNote, iImage, iQuantity, iRday); ConnectionClass.GetItemDetails(theitem); bool found = false; if (iTable.Rows.Count > 0) // IF CART IS NOT EMPTY, { foreach (DataRow iRow in iTable.Rows) { if (Convert.ToString(iRow["No"]) == itemNo) // IF THE ITEM IS ALREADY IN THE CART LIST, UPDATE QTY { //double temp = Convert.ToDouble(iRow["qty"]); double temp = Convert.ToDouble(iRow["qty"]); // double uptemp = Convert.ToDouble(Session["ii"]) + temp; double uptemp = Convert.ToDouble(Session["ii"]) + temp; if (uptemp > Convert.ToDouble(theitem.itemQuantity)) // IF USER TRY TO ADD ITEM MORE THAN AVAILABLE NUMBER (=QUANTITY) { ClientScript.RegisterStartupScript(GetType(), "message", "<script>alert('You cannot add more than available stock ');</script>"); // ALERT MESSSAGE } else { iRow["qty"] = Convert.ToDouble(Session["ii"]) + temp; // UPDATE QUANTITY // iRow["amount"] = Math.Round(Convert.ToDouble(iRow["qty"]) * Convert.ToDouble(iRow["unitprice"]),2); iRow["amount"] = Math.Round(Convert.ToDouble(iRow["qty"]) * Convert.ToDouble(iRow["unitprice"]), 2); //iRow["tax"] = Convert.ToDouble(iRow["amount"]) * 0.13; iRow["tax"] = Math.Round(Convert.ToDouble(iRow["amount"]) * 0.13, 2); } found = true; } } if (!found) // IF ITEM IS NOT IN THE CART LIST, ADD ROW { iTable.Rows.Add("", itemNo, theitem.itemName, Math.Round(Convert.ToDouble(theitem.itemRPrice), 2), Convert.ToDouble(Session["ii"]), Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]), 2), Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]) * 0.13, 2)); } } else // IF CART IS EMPTY, { iTable.Rows.Add("", itemNo, theitem.itemName, Math.Round(Convert.ToDouble(theitem.itemRPrice), 2), Convert.ToDouble(Session["ii"]), Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]), 2), Math.Round(Convert.ToDouble(theitem.itemRPrice) * Convert.ToDouble(Session["ii"]) * 0.13, 2)); } GridView1.DataSource = iTable; // GridView1.DataBind(); object Sum = iTable.Compute(" SUM(amount) ", ""); double NetTotal = Math.Round(Double.Parse(Sum.ToString()), 2); double GrandTotal = Math.Round(NetTotal * 1.13, 2); subTotal.Text = NetTotal.ToString(); grandTotal.Text = GrandTotal.ToString(); Session["ii"] = null; } }