public int InsertEDMData(HCustomers hUser) { string EDMCode = string.Empty; string CustCode = string.Empty; int Deleted = 0; string Author = string.Empty; string Description = string.Empty; string LastEdBy = string.Empty; string Revision = string.Empty; string Remarks = string.Empty; string Scale = string.Empty; string Format = string.Empty; CustCode = GetCustCode(hUser); EDMCode = new FacadeManager().GetEDMCode(CustCode); CustCode = hUser.RelCode; int insert = InsertEDM(EDMCode, CustCode, Deleted, Author, Description, LastEdBy, Revision, Remarks, Scale, Format); return(insert); }
protected void btnAddInfoOK_Click(object sender, EventArgs e) { try { double total_order_with_vat = double.Parse(txtAddInfoTotalPrc.Text.Replace(",", ".")); //total_order_with_vat double vat = double.Parse(Hey.Common.Utils.Functions.GetValueFromWebConfig("BTW")); double total_order = total_order_with_vat * (1 - (vat / 100)); //total_order //double discount_other = (double.Parse(hdnInfoShipCost.Value) + // double.Parse(hdnInfoTotalItems.Value)) - // double.Parse(hdnInfoDiscountItems.Value) - total_order; //discount_other HCustomers hUser = new HCustomers(); string PrjCode = txtAddInfoPrjCode.Text; string Description = txtAdditionalInfoDescription.Text; string ProdNotes = txtAddInfoProductie.Text; // update items... int result = UpdateWSOrder(PrjCode, Description, ProdNotes, total_order_with_vat, total_order); } catch (Exception ex) { } }
protected void Page_Load(object sender, EventArgs e) { HCustomers hUser = new HCustomers(); if (Session["userrole"] != null) { hUser = (HCustomers)Session["userrole"]; sessionid = hUser.RelCode; } else { HttpCookie cookie = Request.Cookies["usersession"]; if (cookie != null) { sessionid = cookie.Value.ToString(); } } if (!IsPostBack) { try { CheckUserType(); FillShoppingCartStandardData(); PopulateOrderDetail(); if ((UserType)ViewState[userType] == UserType.ADMIN) { FillShoppingCartSpecialData(); } else { HideUnauthorizedView(); } GetFileList(); } catch (Exception ex) { } } ConfirmationButtonManagement(); }
protected void btnLogin_Click(object sender, EventArgs e) { try { HCustomers CustomerObject = new HCustomers(); CustomerObject = new FacadeManager().GetCustomerInfoByLogin(txtUserName.Text.Trim(), txtPassword.Text.Trim()); if (CustomerObject != null) { lblMsg.Visible = false; RefreshLoginControl(); Session.Add("userrole", CustomerObject); // update ws_order table if order_id exists... if (!String.IsNullOrEmpty(OrderID)) { WebOrders wsOrder = new WebOrders(); wsOrder.OrderID = int.Parse(OrderID); wsOrder.CustCode = CustomerObject.RelCode; wsOrder.SessionId = CustomerObject.Email; if (CustomerObject.RelCode.Length > 4) { wsOrder.OrderCode = CustomerObject.RelCode.Substring(0, 4) + DateTime.Now.Date.ToString("yyMMdd"); } else { wsOrder.OrderCode = CustomerObject.RelCode + DateTime.Now.Date.ToString("yyMMdd"); } int update = new FacadeManager().UpdateWSOrder(wsOrder); } Response.Redirect("Shipping.aspx"); } else { lblMsg.Visible = true; lblMsg.Text = "Gebruikersnaamen/of wachtwoord is onjuist."; } } catch (Exception ex) {} }
protected void btnAdmOffer_Click(object sender, EventArgs e) { try { ShoppingCartManager cart = new ShoppingCartManager(); FacadeManager facade = new FacadeManager(); if (Session["orderid"] != null) { cart.OrderID = Session["orderid"].ToString(); facade.ConfirmOrder(cart, "O"); HCustomers hUser = (HCustomers)Session["userrole"]; if (hUser != null) { if (chkConfirmation.Checked) // if confirmation checkbox selected then send Order Confirmation mail to customer. { string orderid = Session["orderid"] != null ? Session["orderid"].ToString() : "Order ID Could not retrieve"; string heyEmail = ConfigurationManager.AppSettings["hey-admin-mail"]; string msg = "Product purchase offer submitted.<br /> Order ID : " + orderid + "<br/> Total Amount: " + lblTotal.Text + "<br/> Product Discount: " + lblProductDiscout.Text + "<br/> Other Discount: " + lblOtherDiscount.Text + "<br/> Shipping Cost: " + lblShippingCost.Text + "<br/> Total Amount (Including vat): " + lblTotalIncludingVat.Text + "<br/><br/> With kind regards,<br/><a href='new.hey-ermelo.nl'>HEY</a>"; EmailInfo eInfo = new EmailInfo(); eInfo.Email = hUser.Email; bool success = new FacadeManager().OrderConfirmationToCustomer(eInfo, heyEmail, msg); } } ManageSession(); Response.Redirect("Home.aspx"); } } catch (Exception ex) { } }
void CheckUserType() { try { ViewState[userType] = UserType.ADMIN; if (Session["userrole"] == null) // if user is anonymous i.e. webshoprole = 0 { ViewState[userType] = UserType.ANONYMOUS; } else { HCustomers hUser = (HCustomers)Session["userrole"]; if (hUser.WebShopRole == 2) // if user is not admin i.e. webshoprole = 2 { ViewState[userType] = UserType.REGISTERED; } else //if user is admin i.e. webshoprole = 1 { if (Request.QueryString["order_id"] != null) { ViewState["OrderID"] = Request.QueryString["order_id"]; if (Session["orderid"] == null) { Session.Add("orderid", Request.QueryString["order_id"]); } else { Session["orderid"] = Request.QueryString["order_id"]; } } } } } catch (Exception ex) { } }
protected void btnShoppingCart_Click(object sender, EventArgs e) { try { HCustomers hUser = new HCustomers(); string ItemCode = Request.QueryString["code"]; ImageButton btnShoppingCart = sender as ImageButton; GridViewRow row = (GridViewRow)btnShoppingCart.NamingContainer; TextBox txtQty = row.Cells[4].FindControl("txtQuantity") as TextBox; Label lblCost = row.Cells[5].FindControl("lblPurchasePrice") as Label; Label lblSell = row.Cells[6].FindControl("lblSellPrice") as Label; string SubItem = gvResult.DataKeys[row.RowIndex].Value.ToString(); string Description = HttpUtility.HtmlDecode(row.Cells[1].Text); string Units = HttpUtility.HtmlDecode(row.Cells[2].Text); double Quantity = 0.0; double PriceCost = 0.0; double PriceSell = 0.0; double Discount = 0.0; int ToEDM = 0; int ToProducts = 0; string Remarks = string.Empty; string ProdNotes = string.Empty; string OrderCode = string.Empty; string CustCode = string.Empty; string OrderStatus = "-"; string SessionId = string.Empty; string ItemType = "S"; if (!String.IsNullOrEmpty(txtQty.Text)) { Quantity = double.Parse(txtQty.Text.Replace(",", ".")); if (Quantity != 0.0) { if (!String.IsNullOrEmpty(lblCost.Text)) { PriceCost = double.Parse(lblCost.Text.Replace(",", ".")); } else { PriceCost = 0.0; } if (!String.IsNullOrEmpty(lblSell.Text)) { PriceSell = double.Parse(lblSell.Text.Replace(",", ".")); } else { PriceSell = 0.0; } if (Session["userrole"] == null) // if user is anonymous i.e. webshoprole = 0 { // step1: chek if the cust has order with order_status= '-' with this session id // step2: if order_status='-' exists, update ws_orders table // step3: if order_status != '-', then insert order ws_orders table // step4: for both 2 and 3, insert item to ws_order_items table. HttpCookie cookie = new HttpCookie("usersession"); cookie.Expires = DateTime.Today.AddDays(31); cookie.Value = Session.SessionID; Response.Cookies.Add(cookie); SessionId = Session.SessionID; DataTable dt = new DataTable(); dt = new FacadeManager().CheckOrderExist(SessionId); // step:1 if (dt.Rows.Count > 0) // step:2 - order exists.. order will update & insert item { int OrderID = int.Parse(dt.Rows[0]["order_id"].ToString()); OrderIdSession(OrderID.ToString()); // orderid put in session DataTable ItemTable = new DataTable(); ItemTable = new FacadeManager().CheckOrderItemExist(OrderID, SubItem); if (ItemTable.Rows.Count > 0) // update item { int upItem = UpdateWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); } else // insert item { int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } else // step:3 - insert new order & insert item { //SessionId = SessionId; int OrderId = InsertWSOrder(OrderCode, CustCode, OrderStatus, SessionId); OrderIdSession(OrderId.ToString()); // new orderid put in session int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderId, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } else // if user is registered i.e. webshoprole = 2 or 1 { // step1: check if the cust has discount // step2: chek if the cust has order with order_status= '-' // step3: if order_status='-' exists, update ws_orders table // step4: if order_status != '-', then insert order ws_orders table // step5: for both 3 and 4, insert item to ws_order_items table. hUser = (HCustomers)Session["userrole"]; Discount = GetDiscountValueForCustomer(hUser, SubItem); DataTable orderDT = new DataTable(); orderDT = new FacadeManager().CheckREGOrADMOrderExist(hUser.RelCode); // step 2. if (orderDT.Rows.Count > 0) // step:3 - update order & insert item { int OrderID = int.Parse(orderDT.Rows[0]["order_id"].ToString()); OrderIdSession(OrderID.ToString()); // orderid put in session DataTable ItemTable = new DataTable(); ItemTable = new FacadeManager().CheckOrderItemExist(OrderID, SubItem); if (ItemTable.Rows.Count > 0) // update item { int upItem = UpdateWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); } else // insert item { int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } else // step:4 - insert order & insert item { CustCode = GetCustCode(hUser); OrderCode = new FacadeManager().GetEDMCode(CustCode); CustCode = hUser.RelCode; OrderStatus = "-"; SessionId = hUser.Email; int OrderId = InsertWSOrder(OrderCode, CustCode, OrderStatus, SessionId); OrderIdSession(OrderId.ToString()); // new orderid put in session int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderId, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } } } } catch (Exception ex) { } }
protected void btnOK_Click(object sender, EventArgs e) { try { HCustomers hUser = new HCustomers(); hUser = (HCustomers)Session["userrole"]; string ItemCode = Request.QueryString["code"]; string SubItem = txtVan.Text; string Description = txtOms.Text; string Units = txtEnhd.Text; double Quantity = double.Parse(txtAntal.Text.Replace(",", ".")); if (Quantity != 0.0) { double PriceCost = double.Parse(txtKost.Text.Replace(",", ".")); double PriceSell = double.Parse(txtVerk.Text.Replace(",", ".")); double Discount = 0.0; string Remarks = txtOpmerk.Text; string ProdNotes = txtProdNotes.Text; string ItemType = "C"; int ToEDM = 0; int ToProducts = 0; string OrderCode = GetCustCode(hUser); string CustCode = string.Empty; string OrderStatus = "-"; if (chkArtikel.Checked) { ToProducts = 1; } if (chkEDM.Checked) { ToEDM = 1; } Discount = GetDiscountValueForCustomer(hUser, SubItem); DataTable orderDT = new DataTable(); orderDT = new FacadeManager().CheckREGOrADMOrderExist(hUser.RelCode); // step 2. is order exists if (orderDT.Rows.Count > 0) // step:3 - update order & insert item { int OrderID = int.Parse(orderDT.Rows[0]["order_id"].ToString()); OrderIdSession(OrderID.ToString()); // orderid put in session DataTable ItemTable = new DataTable(); ItemTable = new FacadeManager().CheckOrderItemExist(OrderID, SubItem); if (ItemTable.Rows.Count > 0) // update item { int upItem = UpdateWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); } else // insert item { int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } else // step:4 - insert order & insert item { OrderCode = new FacadeManager().GetEDMCode(CustCode); CustCode = hUser.RelCode; OrderStatus = "-"; string SessionId = hUser.Email; int OrderId = InsertWSOrder(OrderCode, CustCode, OrderStatus, SessionId); OrderIdSession(OrderId.ToString()); // new orderid put in session int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderId, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } } } catch (Exception ex) { } }
protected void btnAdmOrder_Click(object sender, EventArgs e) { try { ShoppingCartManager cart = new ShoppingCartManager(); FacadeManager facade = new FacadeManager(); if (Session["OrderID"] != null) { cart.OrderID = Session["orderid"].ToString(); HCustomers hUser = (HCustomers)Session["userrole"]; if (ViewState[userType] != null && hUser != null) { facade.ConfirmOrder(cart, "P"); // insert toedm and basematerial int IsEDM = 0; int IsBaseMaterial = 0; DataTable ItemTable = new DataTable(); ItemTable = new FacadeManager().GetAllItemForOrder(int.Parse(cart.OrderID)); if (ItemTable.Rows.Count > 0) { foreach (DataRow row in ItemTable.Rows) { IsEDM = Convert.ToInt32(row["to_edm"].ToString()); if (IsEDM == 1) { // insert EDM int res = InsertEDMData(hUser); } IsBaseMaterial = Convert.ToInt32(row["to_products"].ToString()); if (IsBaseMaterial == 1) { // insert into BaseMaterial int res = InsertBaseMaterialData(hUser); } } } if (chkConfirmation.Checked) // if confirmation checkbox selected then send Order Confirmation mail to customer. { string orderid = Session["orderid"] != null ? Session["orderid"].ToString() : "Order ID Could not retrieve"; string heyEmail = ConfigurationManager.AppSettings["hey-admin-mail"]; EmailInfo eInfo = new EmailInfo(); eInfo.Email = hUser.Email; string msg = "Product purchase order Confirmed.<br /> Order ID : " + orderid + "<br/> Total Amount: " + lblTotal.Text + "<br/> Product Discount: " + lblProductDiscout.Text + "<br/> Other Discount: " + lblOtherDiscount.Text + "<br/> Shipping Cost: " + lblShippingCost.Text + "<br/> Total Amount (Including vat): " + lblTotalIncludingVat.Text + "<br/><br/> With kind regards,<br/><a href='new.hey-ermelo.nl'>HEY</a>"; bool success = new FacadeManager().OrderConfirmationToCustomer(eInfo, heyEmail, msg); } ManageSession(); Response.Redirect("Home.aspx"); } } } catch (Exception ex) { } }
protected void btnLogin_Click(object sender, EventArgs e) { try { HCustomers CustomerObject = new HCustomers(); // get the customer information. CustomerObject = new FacadeManager().GetCustomerInfoByLogin(txtUserName.Text.Trim(), txtPassword.Text.Trim()); if (CustomerObject != null) { lblMsg.Visible = false; RefreshLoginControl(); Session.Add("userrole", CustomerObject); // user session for logged in customer UserControl ucl; DataTable orderDT = new DataTable(); orderDT = new FacadeManager().CheckREGOrADMOrderExist(CustomerObject.RelCode); // check if any Order exists for this Register or Admin user. if (orderDT.Rows.Count > 0) { int OrderID = int.Parse(orderDT.Rows[0]["order_id"].ToString()); if (Session["orderid"] == null) { Session.Add("orderid", OrderID.ToString()); } else { Session["orderid"] = OrderID.ToString(); } int TotalItem = new FacadeManager().TotalItemofOrder(OrderID); // Get the toal item number of the existing order. if (TotalItem > 0) // if item exists, a session is created/updated for store the current item number. { if (Session["itemno"] == null) { Session.Add("itemno", TotalItem.ToString()); } else { Session["itemno"] = TotalItem.ToString(); } } } // After successful log in, the page will redirect to the FilterItem.aspx page and the first subitem // of the first item of the menu will be selected and shows the image and filter pane of that selected Subitem. // The below code get the first subitem value i.e. code and description from the master page navigator control. // And the page will redirect with necessary querystring to the FilterItem.aspx page. AjaxControlToolkit.Accordion accordMenu = null; ucl = (UserControl)Master.FindControl("NavigatorControl1"); if (ucl != null) { accordMenu = (AjaxControlToolkit.Accordion)ucl.FindControl("accordMenu"); } LinkButton lnk = accordMenu.Panes[0].ContentContainer.Controls[0].Controls[0] as LinkButton; if (lnk.CommandName == "GetItemCode") { string[] values = lnk.CommandArgument.ToString().Split(new char[] { ',' }); Response.Redirect("FilterItem.aspx?code=" + values[0] + "&description=" + values[1]); } } else { lblMsg.Visible = true; lblMsg.Text = "Gebruikersnaamen/of wachtwoord is onjuist."; } } catch (Exception ex) { string errorMsg = ex.ToString(); } }
protected void btnAddSpOK_Click(object sender, EventArgs e) { try { HCustomers hUser = new HCustomers(); hUser = (HCustomers)Session["userrole"]; string SubItem = string.Empty; string EDMCode = string.Empty; string Artikelnr = string.Empty; string Description = txtAddSpDescription.Text; string Units = txtAddEenhd.Text; double Quantity = double.Parse(txtAddSpAntal.Text.Replace(",", ".")); if (Quantity != 0.0) { double PriceCost = double.Parse(txtAddSpCost.Text.Replace(",", ".")); double PriceSell = double.Parse(txtAddSpSell.Text.Replace(",", ".")); double Discount = 0.0; string Remarks = txtAddOpmerk.Text; string ProdNotes = txtAddProductie.Text; string ItemType = "O"; int ToEDM = 0; int ToProducts = 0; string CustCode = GetCustCode(hUser); if (chkAddSpEDM.Checked) { ToEDM = 1; EDMCode = new FacadeManager().GetEDMCode(CustCode); } if (chkAddSpArtikel.Checked) { ToProducts = 1; Artikelnr = new FacadeManager().GetKLSPCode(); } if (!String.IsNullOrEmpty(Artikelnr)) { SubItem = Artikelnr; } if (String.IsNullOrEmpty(SubItem)) { if (!String.IsNullOrEmpty(EDMCode)) { SubItem = EDMCode; } } string OrderCode = string.Empty; string OrderStatus = "-"; DataTable orderDT = new DataTable(); orderDT = new FacadeManager().CheckREGOrADMOrderExist(hUser.RelCode); // step 2. is order exists if (orderDT.Rows.Count > 0) // step:3 - update order & insert item { int OrderID = int.Parse(orderDT.Rows[0]["order_id"].ToString()); OrderIdSession(OrderID.ToString()); // orderid put in session int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderID, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } else // step:4 - insert order & insert item { OrderCode = new FacadeManager().GetEDMCode(CustCode); CustCode = hUser.RelCode; OrderStatus = "-"; string SessionId = hUser.Email; int OrderId = InsertWSOrder(OrderCode, CustCode, OrderStatus, SessionId); OrderIdSession(OrderId.ToString()); // new orderid put in session int item = InsertWSItem(SubItem, ItemType, Description, Units, Quantity, PriceCost, PriceSell, Discount, OrderId, Remarks, ProdNotes, ToEDM, ToProducts); ItemSession(); } FillShoppingCartSpecialData(); udpShoppingCart.Update(); } } catch (Exception ex) { } }