Ejemplo n.º 1
0
        /// <summary>
        /// This function create welcome label according to time and logined user.
        /// </summary>
        /// <returns>This function returns string.</returns>
        public static string WelcomeLabel()
        {
            string   tmpUsername = LoginedUser.getInstance().Customer.Name;
            DateTime date        = DateTime.Now;

            if (date.Hour <= 12 && date.Hour >= 05)
            {
                return("Good Morning " + tmpUsername.ToUpper()
                       + " Welcome to Dream Book Store! ");
            }
            else if (date.Hour <= 18 && date.Hour >= 12)
            {
                return("Good Afternoon " + tmpUsername.ToUpper()
                       + " Welcome to Dream Book Store! ");
            }
            else if (date.Hour <= 21 && date.Hour >= 18)
            {
                return("Good  Evening " + tmpUsername.ToUpper()
                       + " Welcome to Dream Book Store! ");
            }
            else
            {
                return("Good Night " + tmpUsername.ToUpper()
                       + " Welcome to Dream Book Store! ");
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// This function login the our store.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnLogin_Click(object sender, EventArgs e)
 {
     try
     {
         Database db = new Database();
         db.CustomerList();
         List <Customer> _cuslist = db.getCustomerList();
         foreach (Customer _customer in _cuslist)
         {
             if (_customer.IsValid(txtUsername.Text, txtPassword.Text))
             {
                 LoginedUser.getInstance().Customer = _customer;
                 MW = new MainWindow();
                 MW.Show();
                 this.Hide();
                 return;
             }
         }
         MessageBox.Show("Invalid username or password!");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// This function brings user control settings to front.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnSettings_Click(object sender, EventArgs e)
 {
     Logger.log("Click to Settings Button.");
     btnDashboard.BackColor     = Color.LightBlue;
     btnBooks.BackColor         = Color.LightBlue;
     btnMusicCDs.BackColor      = Color.LightBlue;
     btnMagazine.BackColor      = Color.LightBlue;
     btnMyOrders.BackColor      = Color.LightBlue;
     btnMyCart.BackColor        = Color.LightBlue;
     btnSetting.BackColor       = Color.Teal;
     pnlSelectedButton.Visible  = true;
     pnlSelectedButton.Location = new Point(0, 360);
     if (LoginedUser.getInstance().Customer.Username == "admin")
     {
         if (pnlContainer.Controls["UC_AdminControl"] == null)
         {
             UC_AdminControl ucAC = new UC_AdminControl();
             ucAC.Dock = DockStyle.Fill;
             pnlContainer.Controls.Add(ucAC);
         }
         pnlContainer.Controls["UC_AdminControl"].BringToFront();
     }
     else
     {
         if (pnlContainer.Controls["UC_CustomerSettings"] == null)
         {
             UC_CustomerSettings ucCS = new UC_CustomerSettings();
             ucCS.Dock = DockStyle.Fill;
             pnlContainer.Controls.Add(ucCS);
         }
         pnlContainer.Controls["UC_CustomerSettings"].BringToFront();
     }
 }
        private void UC_CustomerSettings_Load(object sender, EventArgs e)
        {
            Customer tmpCust = LoginedUser.getInstance().Customer;

            txtBoxCustomerName.Text     = tmpCust.Name;
            txtBoxCustomerUsername.Text = tmpCust.Username;
            txtBoxCustomerAddress.Text  = tmpCust.Address;
            txtBoxCustomerEmail.Text    = tmpCust.Email;
        }
Ejemplo n.º 5
0
 private void PaymentForm_Load(object sender, EventArgs e)
 {
     try
     {
         txtName.Text    = LoginedUser.getInstance().Customer.Name;
         txtAddress.Text = LoginedUser.getInstance().Customer.Address;
         txtEmail.Text   = LoginedUser.getInstance().Customer.Email;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 private void btnChangePassword_Click(object sender, EventArgs e)
 {
     Logger.log("Click to Change Password Button.");
     if (Util.ComputeSha256Hash(txtBoxCustomerOldPassword.Text)
         == LoginedUser.getInstance().Customer.Password)
     {
         LoginedUser.getInstance().Customer.Password =
             Util.ComputeSha256Hash(txtBoxCustomerNewPassword.Text);
         Database db = new Database();
         db.UpdateCustomer(LoginedUser.getInstance().Customer);
     }
     else
     {
         MessageBox.Show("Please Enter Correct Old Password.");
     }
 }
 private void btnUptadeCustomerInformations_Click(object sender, EventArgs e)
 {
     Logger.log("Click to Uptade Customer Information Button.");
     if (Util.ComputeSha256Hash(txtBoxPasswordControl.Text)
         == LoginedUser.getInstance().Customer.Password)
     {
         Database db = new Database();
         string   ID = LoginedUser.getInstance().Customer.CustomerID;
         db.UpdateCustomer(new Customer(ID, txtBoxCustomerName.Text, txtBoxCustomerAddress.Text,
                                        txtBoxCustomerEmail.Text, txtBoxCustomerUsername.Text,
                                        Util.ComputeSha256Hash(txtBoxPasswordControl.Text)));
     }
     else
     {
         MessageBox.Show("Please Enter Correct Password.");
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// This function saves user's every event to a txt file.
        /// </summary>
        /// <param name="btnlog">This parameter is user's event.</param>
        public static void log(string btnlog)
        {
            Customer cstmr = LoginedUser.getInstance().Customer;
            string   log   = cstmr.Username + "\t\t" + btnlog + " Button\t\t" + DateTime.Now.ToShortDateString() + "\t" + DateTime.Now.ToLongTimeString();
            string   path  = Application.StartupPath + @"/Log.txt";

            if (!File.Exists(path))
            {
                using (StreamWriter sw = File.CreateText(path))
                {
                    sw.WriteLine(string.Format("{0,-25} {1,-50} {2,-15} {3,-15}", "Username", "Button Info", "Date", "Time"));
                    sw.WriteLine(string.Format("{0,-25} {1,-50} {2,-15} {3,-15}", cstmr.Username, btnlog, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString()));
                }
            }
            using (StreamWriter sw = File.AppendText(path))
            {
                sw.WriteLine(string.Format("{0,-25} {1,-50} {2,-15} {3,-15}", cstmr.Username, btnlog, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString()));
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// This function is for adding orders to the database.
 /// </summary>
 /// <param name="totalPrice">This parameter is bill's Total Price.</param>
 public void SaveOrder(string totalPrice)
 {
     try
     {
         connection.Connection();
         connection.Open();
         SqlCommand command = new SqlCommand("Insert into Tbl_Bill(CustomerId,Date,TotalPrice) values(@CustomerId,@Date,@TotalPrice)", connection.Connect);
         command.Parameters.AddWithValue("@CustomerId", int.Parse(LoginedUser.getInstance().Customer.CustomerID));
         command.Parameters.AddWithValue("@Date", DateTime.Now);
         command.Parameters.AddWithValue("@TotalPrice", totalPrice);
         command.ExecuteNonQuery();
         SqlCommand cmd2 = new SqlCommand("SELECT TOP 1 * FROM Tbl_Bill ORDER BY ID DESC", connection.Connect);
         billId = (int)cmd2.ExecuteScalar();
         connection.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// This function is for pulling the order list from the database.
 /// </summary>
 public void OrderList()
 {
     try
     {
         billTable.Clear();
         connection.Connection();
         connection.Open();
         SqlDataAdapter da = new SqlDataAdapter("Select Date,TotalPrice,ID from Tbl_Bill where CustomerId=" + LoginedUser.getInstance().Customer.CustomerID, connection.Connect);
         da.Fill(billTable);
         connection.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }