Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SetMutliviewDefaultView();

                //is he logged in
                if (!IsLoggedIn())
                {
                    Response.Redirect($"{SharedLogic.LOGIN_PAGE}?Msg={SharedLogic.RELOGIN_NEEDED_MSG}");
                }

                //if button click
                if (IsPostBack)
                {
                    return;
                }

                //set the user info
                SystemUser user = Session["User"] as SystemUser;
                btnUserDetails.Text = $"Name: {user.FullName}";
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 2
0
        protected void btnLogout_Click(object sender, EventArgs e)
        {
            try
            {
                Session.Clear();
                Response.Redirect($"{SharedLogic.LOGIN_PAGE}?Msg={SharedLogic.SUCCESSFULL_LOGOUT_MSG}");
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 3
0
        protected void btnInitiateRegister_Click(object sender, EventArgs e)
        {
            try
            {
                lblInfoMsg.Text = "Supply User Details Below";
                multiViewContent.SetActiveView(viewRegisterUser);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 4
0
        private void RemoveItemFromShoppingCart(string ItemId)
        {
            try
            {
                //get items available for sale
                List <Item> ItemsAvailableForSale = LoadItems();

                //get items stored in session
                List <Item> shoppingCart = GetItemsAlreadyInShoppingCart();

                //look for the item with the id specified
                Item itemSelected = ItemsAvailableForSale.Where(i => i.ItemCode == ItemId).FirstOrDefault();

                //we cant find the item selected
                if (itemSelected == null)
                {
                    ShowErrorMsg("Unable to Remove Item Selected. Try again");
                    return;
                }


                //add item to shopping cart
                shoppingCart.Remove(itemSelected);

                //save cart in session
                Session["ItemsInShoppingCart"] = shoppingCart;

                //update count of Items available for sale (locally)..db update will be done at point of payment
                ItemsAvailableForSale.Where(i => i.ItemCode == ItemId).Select(S => { S.ItemCount = S.ItemCount + 1; return(S); });

                lblItemCount.InnerText = $"{shoppingCart.Count}";

                lblInfoMsg.Text = $"Item [{itemSelected.ItemName}] Added To Your Cart";
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 5
0
        protected void btnBrowse_Click(object sender, EventArgs e)
        {
            try
            {
                multiViewContent.SetActiveView(viewItems);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 6
0
        protected void btnRegisterSystemUser_Click(object sender, EventArgs e)
        {
            try
            {
                //set up on new user here
                SystemUser user = new SystemUser
                {
                    FullName   = txtUserFullName.Text,
                    Password   = txtUserPassword.Text,
                    Username   = txtUsername.Text,
                    RoleCode   = ddRoles.SelectedValue,
                    ModifiedBy = txtUsername.Text
                };

                //password and confirmed password dont match
                if (user.Password != txtConfirmedPassword.Text)
                {
                    lblInfoMsg.Text = ("Passwords dont match. Please retype Password");
                    return;
                }

                //attach sale item to new user
                Result result = SharedLogic.TcmpTestCore.RegisterSystemUser(user);

                //error on initiating a new user
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = (result.StatusDesc);
                    return;
                }

                lblInfoMsg.Text = ("User has Been Created Successfully");
                //btnInitiateLogin(null, null);
                return;
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 7
0
        protected void btnBankPayment_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                lblInfoMsg.Text = "Deposit Funds on the Account with Details below";
                multiViewContent.SetActiveView(viewBankDepositInstructions);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 8
0
        protected void btnOnlinePayment_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                string MerchantCode     = Globals.GATEWAY_MERCHANTCODE;
                string Currency         = "UGX";
                string ItemDesc         = $"Payment For Sale [ {GenerateTransactionIDIfNotExists()} ]";
                string CustomerRef      = Session["CustID"] as string;
                string Amount           = GetItemTotal();
                string Password         = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, Globals.GATEWAY_PASSWORD);
                string ReturnUrl        = Globals.RETURN_URL;
                string VendorCode       = Globals.GATEWAY_VENDORCODE;
                string VendorTranId     = GenerateTransactionIDIfNotExists();
                string datatToSign      = VendorCode + MerchantCode + Amount + ItemDesc + Currency + ReturnUrl + VendorTranId;
                string DigitalSignature = SharedCommons.GenearetHMACSha256Hash(Globals.GATEWAY_SECRET_KEY, datatToSign);
                string RequestData      = "VENDORCODE=" + VendorCode + "&PASSWORD="******"&VENDOR_TRANID=" + VendorTranId + "&ITEM_TOTAL=" + Amount + "&ITEM_DESCRIPTION=" + ItemDesc + "&CURRENCY=" + Currency + "&RETURN_URL=" + ReturnUrl + "&DIGITAL_SIGNATURE=" + DigitalSignature + "&MERCHANTCODE=" + MerchantCode + "&CUSTOMER_REF=" + CustomerRef;
                string URL = Globals.URL_FOR_PEGASUS_PAYMENTS_GATEWAY + "?" + RequestData;
                Response.Redirect(URL);
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 9
0
        protected void btnCompleteCheckout_Click(object sender, EventArgs e)
        {
            try
            {
                //save the customer
                Customer customer = new Customer
                {
                    CustomerName = txtCustName.Text,
                    Email        = txtEmail.Text,
                    Phone        = txtCustPhone.Text
                };

                //set the customer ID to either the phone or email depending on whats supplied
                customer.CustomerID = customer.Phone ?? customer.Email;

                //register customer
                Result result = SharedLogic.TcmpTestCore.RegisterCustomer(customer);

                //error on initiating a new sale
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = (result.StatusDesc);
                    return;
                }

                //get items stored in session
                List <Item> shoppingCart = GetItemsAlreadyInShoppingCart();

                //oops..nothing in shopping cart
                if (shoppingCart.Count <= 0)
                {
                    lblInfoMsg.Text = ("No Items Found in Shopping Cart");
                    return;
                }

                //create a new sale
                Sale sale = new Sale
                {
                    SaleID     = GenerateTransactionIDIfNotExists(),
                    CustomerId = customer.CustomerID
                };

                //initiate a new sale
                result = SharedLogic.TcmpTestCore.RegisterSale(sale);

                //error on initiating a new sale
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = (result.StatusDesc);
                    return;
                }

                List <SaleItem> saleItems = new List <SaleItem>();

                //go item by item in cart
                foreach (var item in shoppingCart)
                {
                    //attach each item to this sale
                    SaleItem saleItem = new SaleItem
                    {
                        ItemId = item.ItemCode,
                        SaleId = sale.SaleID
                    };
                    saleItems.Add(saleItem);
                }

                //attach sale item to new sale
                result = SharedLogic.TcmpTestCore.RegisterSaleItems(saleItems.ToArray());

                //error on initiating a new sale
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = (result.StatusDesc);
                    return;
                }

                //success
                lblInfoMsg.Text = "Please Click ON Your Prefered Method of Payment";

                //make him select a payment method
                multiViewContent.SetActiveView(viewPaymentMethodChoice);
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 10
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                String     username = txtLoginUsername.Text;
                string     Password = txtLoginPassword.Text;
                SystemUser user     = SharedLogic.TcmpTestCore.Login(username, Password);

                if (user.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = user.StatusDesc;
                    return;
                }

                //reset Session
                Session.Clear();
                Session["User"] = user;

                if (user.RoleCode.ToUpper().Equals("ADMIN") || user.RoleCode.ToUpper().Equals("SUPER_ADMIN"))
                {
                    Response.Redirect("ViewReports.aspx");
                    return;
                }

                if (user.RoleCode.ToUpper().Equals("STORE_KEEPER"))
                {
                    Response.Redirect("AddNewItems.aspx");
                    return;
                }

                lblInfoMsg.Text = "UNABLE TO DETERMINE YOUR ROLE IN SYSTEM";
            }
            catch (Exception ex)
            {
                //display error
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 11
0
        protected void btnInitiateCheckout_Click(object sender, EventArgs e)
        {
            try
            {
                //get items stored in session
                List <Item> shoppingCart = GetItemsAlreadyInShoppingCart();

                //oops..nothing in shopping cart
                if (shoppingCart.Count <= 0)
                {
                    ShowErrorMsg("No Items Found in Shopping Cart. Please Select Some Items to Purchase");
                    return;
                }

                //its ok
                lblInfoMsg.Text = "Before we proceed, Please Supply the Details below";

                //change the view
                multiViewContent.SetActiveView(viewCustomerDetails);
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 12
0
        //public List<Item> ItemsAvailableForSale = new List<Item>();

        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                //if button click
                if (IsPostBack)
                {
                    return;
                }

                if (IsItemAddRequest())
                {
                    UpdateShoppingCart();
                }

                SetMutliviewDefaultView();

                //get items for sale
                List <Item> ItemsAvailableForSale = LoadItems();

                //no items found for sale
                if (ItemsAvailableForSale.Count <= 0)
                {
                    multiViewContent.ActiveViewIndex = 1;
                    lblMessage.Text = "There Are NO Items found for Sale Today. Login And Add a few Items first";
                    return;
                }
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 13
0
        protected void btnRegisterItem_Click(object sender, EventArgs e)
        {
            try
            {
                SystemUser user = Session["User"] as SystemUser;

                //create item
                Item item = new Item
                {
                    CreatedBy = user.Username,
                    ItemCode  = Request.QueryString["ItemId"] == null?SharedCommons.GenerateUniqueId("ITEM-") : Request.QueryString["ItemId"],
                                    ItemCount  = SharedCommons.GetIntFromStringDefaultsToZero(txtItemCount.Text),
                                    ItemImage  = GetBase64StringOfImageUploaded(),
                                    ItemName   = txtItemName.Text,
                                    ItemPrice  = SharedCommons.GetIntFromStringDefaultsToZero(txtPrice.Text),
                                    ModifiedBy = user.Username,
                };

                Result result = SharedLogic.TcmpTestCore.RegisterItem(item);

                //failed to save
                if (result.StatusCode != SharedCommonsGlobals.SUCCESS_STATUS_CODE)
                {
                    lblInfoMsg.Text = result.StatusDesc;
                    return;
                }

                //success
                lblInfoMsg.Text = "Item Registered Successfully";

                //reload items from database
                ItemsAvailableForSale = LoadItems();
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                SetMutliviewDefaultView();

                //is he logged in
                if (!IsLoggedIn())
                {
                    Response.Redirect($"{SharedLogic.LOGIN_PAGE}?Msg={SharedLogic.RELOGIN_NEEDED_MSG}");
                }

                //if button click
                if (IsPostBack)
                {
                    return;
                }

                //set the user info
                SystemUser user = Session["User"] as SystemUser;
                btnUserDetails.Text = $"Name: {user.FullName}";

                //get items for sale
                ItemsAvailableForSale = LoadItems();

                if (!IsItemEditRequest())
                {
                    return;
                }

                string ItemID = Request.QueryString["ItemId"];
                Item   item   = ItemsAvailableForSale.Where(i => i.ItemCode == ItemID).FirstOrDefault();

                if (item == null)
                {
                    ShowErrorMsg($"Unable to find Item with ID [{ItemID}] to Edit");
                    return;
                }

                txtItemCount.Text = item.ItemCount.ToString();
                txtItemName.Text  = item.ItemName;
                txtPrice.Text     = item.ItemPrice.ToString();
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }
Esempio n. 15
0
        protected void btnAddItems_Click(object sender, EventArgs e)
        {
            try
            {
            }
            catch (Exception ex)
            {
                ShowErrorMsg(SharedLogic.INTERNAL_ERROR_MSG);

                //log error
                SharedLogic.TcmpTestCore.LogError($"EXCEPTION:{ex.Message}", $"{this.GetType().Name}-{SharedLogic.GetCurrentMethod()}", "N/A");
            }
        }