Ejemplo n.º 1
0
        public void LoadAddPointsDetailView()
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                var list = from f in db.Customers.ToList()



                           //join e in db.Applicants.ToList() on f.ApplicationID equals e.ApplicationID
                           where (f.ID == CustomerID)

                           select new
                {
                    f.Name,
                    f.Surname,
                    f.ID_No,
                    f.Gender.GenderName,
                    f.Email,
                    f.DateCreated,
                    f.Cell_No,
                    f.ID,
                };
                AddPointsCustomerDetailsView.DataSource = list;
                AddPointsCustomerDetailsView.DataBind();
            }
        }
        public void LoadGrid()
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                var list = from f in db.Employees.ToList()



                           //join e in db.Applicants.ToList() on f.ApplicationID equals e.ApplicationID
                           //where (f.DAO_Approval == false && f.DM_Approval == false && f.ApplicationTypeID == 2)

                           select new
                {
                    f.Name,
                    f.Surname,
                    f.ID_No,
                    f.Gender.GenderName,
                    f.Email,
                    f.CellPhone,
                    f.EmployeeRole.RoleName,
                    f.Employee_No,
                    f.Username,
                    f.ID,
                };
                gvStaff.DataSource = list;
                gvStaff.DataBind();
            }
        }
        public void UpdateCustomer()
        {
            LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities();

            CustomerBL Cusbl = new CustomerBL();

            Models.Customer Custb = new Models.Customer();
            var             data  = db.Customers.ToList().FirstOrDefault(x => x.ID == CustomerID);

            double points = 0;

            if (Convert.ToDecimal(txtTotalAmount.Text) == 100)
            {
                points = double.Parse("10", CultureInfo.InvariantCulture);

                Custb.Loyalty_Points = (decimal)points;
            }
            else if (Convert.ToDecimal(txtTotalAmount.Text) == 1000)
            {
                points = double.Parse("100", CultureInfo.InvariantCulture);
                Custb.Loyalty_Points = (decimal)points;
            }
            else if (Convert.ToDecimal(txtTotalAmount.Text) < 100)
            {
                points = double.Parse("1", CultureInfo.InvariantCulture);
                Custb.Loyalty_Points = (decimal)points;
            }
            else if (Convert.ToDecimal(txtTotalAmount.Text) > 1000)
            {
                points = double.Parse("150", CultureInfo.InvariantCulture);
                Custb.Loyalty_Points = (decimal)points;
            }

            Cusbl.UpdateCustomer(Custb);
        }
Ejemplo n.º 4
0
 public List <EmployeeRole> LoadRole()
 {
     // this is the load method, its returns everything from the Register table where IsDeleted = false
     using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
     {
         return(db.EmployeeRoles.ToList());
     }
 }
Ejemplo n.º 5
0
 public List <Club> loadClubs()
 {
     // this is the load method, its returns everything from the Register table where IsDeleted = false
     using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
     {
         return(db.Clubs.ToList());
     }
 }
Ejemplo n.º 6
0
        public void CreateEmployeeRole(Models.EmployeeRole model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.EmployeeRole role = new Models.EmployeeRole();

                role.RoleName = model.RoleName;

                db.EmployeeRoles.Add(role);
            }
        }
Ejemplo n.º 7
0
        public void CreateGender(Models.Gender model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Gender ger = new Models.Gender();

                ger.GenderName = model.GenderName;

                db.Genders.Add(ger);
            }
        }
Ejemplo n.º 8
0
        public void UpdateCustomer(Models.Customer model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                var cus = db.Customers.ToList().FirstOrDefault(x => x.ID == model.ID);

                cus.ID             = model.ID;
                cus.Loyalty_Points = model.Loyalty_Points;

                db.SaveChanges();
            }
        }
Ejemplo n.º 9
0
        public void SaveCustomerPurchase()
        {
            //string www= labbbbb.Text;
            CustomerPurchaseBL busEmp = new CustomerPurchaseBL();

            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer_Purchase cusP = new Models.Customer_Purchase();

                string s = txtTotalAmount.Text;

                cusP.Date       = DateTime.Now;
                cusP.CustomerID = CustomerID;
                cusP.RecieptNo  = txtRecieptNo.Text;


                double fee = double.Parse(txtTotalAmount.Text, CultureInfo.InvariantCulture);

                cusP.TotalPrice  = (decimal)fee;
                cusP.RecieptDate = DateTime.Now;
                //cusP.RecieptDate = Convert.ToDateTime(txtReieptDate.Text.ToString("dd/m/yyyy"));
                double points = 0;

                if (Convert.ToDecimal(txtTotalAmount.Text) == 100)
                {
                    points = double.Parse("10", CultureInfo.InvariantCulture);

                    cusP.LoyaltyPoints = (decimal)points;
                }
                else if (Convert.ToDecimal(txtTotalAmount.Text) == 1000)
                {
                    points             = double.Parse("100", CultureInfo.InvariantCulture);
                    cusP.LoyaltyPoints = (decimal)points;
                }
                else if (Convert.ToDecimal(txtTotalAmount.Text) < 100)
                {
                    points             = double.Parse("1", CultureInfo.InvariantCulture);
                    cusP.LoyaltyPoints = (decimal)points;
                }
                else if (Convert.ToDecimal(txtTotalAmount.Text) > 1000)
                {
                    points             = double.Parse("150", CultureInfo.InvariantCulture);
                    cusP.LoyaltyPoints = (decimal)points;
                }

                busEmp.CreateCustomerPurchase(cusP);
            }
        }
Ejemplo n.º 10
0
        public void CreateCustomerPurchase(Models.Customer_Purchase model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer_Purchase CusPur = new Models.Customer_Purchase();

                CusPur.Date          = model.Date;
                CusPur.CustomerID    = model.CustomerID;
                CusPur.EmployeeID    = model.EmployeeID;
                CusPur.LoyaltyPoints = model.LoyaltyPoints;
                CusPur.TotalPrice    = model.TotalPrice;
                CusPur.RecieptDate   = model.RecieptDate;
                CusPur.RecieptNo     = model.RecieptNo;

                db.Customer_Purchase.Add(CusPur);
            }
        }
Ejemplo n.º 11
0
        public void SaveCustomer()
        {
            CustomerBL busEmp = new CustomerBL();

            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer emp = new Models.Customer();

                emp.GenderID = Convert.ToInt16(ddlGender.SelectedValue);
                emp.ID_No    = txtIDNumber.Text;
                emp.Name     = txtName.Text;
                emp.Surname  = txtSurname.Text;
                emp.Cell_No  = txtCellPhoneNO.Text;
                emp.Email    = txtEmail.Text;

                busEmp.CreateCustomer(emp);
            }
        }
Ejemplo n.º 12
0
        protected void GenerateQrScan()
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                var data = db.Customers.ToList().FirstOrDefault(x => x.ID == CustomerID);

                string          code        = data.ID_No + data.Name + data.Surname;
                QRCodeGenerator qrGenerator = new QRCodeGenerator();
                QRCodeData      qrCodeData  = qrGenerator.CreateQrCode(code, QRCodeGenerator.ECCLevel.Q);
                QRCode          qrCode      = new QRCode(qrCodeData);
                System.Web.UI.WebControls.Image imgBarCode = new System.Web.UI.WebControls.Image();
                imgBarCode.Height = 150;
                imgBarCode.Width  = 150;
                using (Bitmap bitMap = qrCode.GetGraphic(20))
                {
                    using (MemoryStream ms = new MemoryStream())
                    {
                        bitMap.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
                        byte[] byteImage = ms.ToArray();
                        imgBarCode.ImageUrl = "data:image/png;base64," + Convert.ToBase64String(byteImage);
                    }

                    PlaceHolder1.Controls.Add(imgBarCode);



                    //EmailBL EML = new EmailBL();

                    //EML.Email("You have successfully Registered for Loyalty Points: " + data.Name + " " + data.Surname, "Dear" + data.Name

                    //                + "<br/> <br/>"

                    //                + "This is your QrScan :" + "< img src = " + imgBarCode + " >" + "<br/>" +
                    //               "Your application has been Approve. " + "<br/>" +


                    //               "<br/>" + "This is an automatically generated email. Please do not reply. " +

                    //           "<br/> <br/>" + "For more details feel free to call us on 031 455 4576." + "<br/> <br/>" +
                    //           "Regards" + "<br/>" +
                    //           "Loyalty Point", data.Email, "Loyalty Point", "*****@*****.**");
                }
            }
        }
Ejemplo n.º 13
0
        public void CreateCustomer(Models.Customer model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Customer cus = new Models.Customer();

                cus.Cell_No        = model.Cell_No;
                cus.DateCreated    = model.DateCreated;
                cus.Email          = model.Email;
                cus.GenderID       = model.GenderID;
                cus.ID_No          = model.ID_No;
                cus.Loyalty_Points = model.Loyalty_Points;
                cus.Name           = model.Name;
                cus.Surname        = model.Surname;

                db.Customers.Add(cus);
                db.SaveChanges();
            }
        }
Ejemplo n.º 14
0
        public void sendEmail()
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                EmailBL EML = new EmailBL();

                EML.Email("Status Notification for Reference No: " + "refNo", "Dear Applicant"

                          + "<br/> <br/>"

                          + "Your Reference is :" + "refNo" + "<br/>" +
                          "Your application has been Approve. " + "<br/>" +


                          "<br/>" + "This is an automatically generated email. Please do not reply. " +

                          "<br/> <br/>" + "For more details feel free to call us on 031 455 4576." + "<br/> <br/>" +
                          "Regards" + "<br/>" +
                          "Ethekwini Municipality", "*****@*****.**", "Ethekwini Municipality", "*****@*****.**");
            }
        }
Ejemplo n.º 15
0
        public void CreateEmployee(Models.Employee model)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Employee emp = new Models.Employee();

                emp.Employee_No = model.Employee_No;
                emp.GenderID    = model.GenderID;
                emp.ID_No       = model.ID_No;
                emp.Name        = model.Name;
                emp.Surname     = model.Surname;
                emp.Password    = model.Password;
                emp.RoleID      = model.RoleID;
                emp.Username    = model.Username;
                emp.Email       = model.Email;
                emp.CellPhone   = model.CellPhone;
                emp.ClubName    = model.ClubName;
                emp.IsDeleted   = false;

                db.Employees.Add(emp);
                db.SaveChanges();
            }
        }
Ejemplo n.º 16
0
        public void SaveEmployee()
        {
            EmployeeBL busEmp = new EmployeeBL();

            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                Models.Employee emp = new Models.Employee();

                emp.RoleID      = Convert.ToInt16(ddlEmployeeRole.SelectedValue);
                emp.Employee_No = GetEmployeeNo();
                emp.GenderID    = Convert.ToInt16(ddlGender.SelectedValue);
                emp.ID_No       = txtIDNumber.Text;
                emp.Name        = txtName.Text;
                emp.Password    = txtPassword.Text;
                emp.Surname     = txtSurname.Text;
                emp.Username    = txtEmail.Text;
                emp.CellPhone   = txtCellPhoneNO.Text;
                emp.Email       = txtEmail.Text;
                emp.ClubName    = ddlLoungeName.SelectedItem.Text;

                busEmp.CreateEmployee(emp);
            }
        }
Ejemplo n.º 17
0
        public void UpdateRedeemPointsCustomer()
        {
            LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities();

            CustomerBL Cusbl = new CustomerBL();

            Models.Customer Custb = new Models.Customer();
            var             data  = db.Customers.ToList().FirstOrDefault(x => x.ID == CustomerID);

            Custb.ID = data.ID;
            double points = 0;

            if (data.Loyalty_Points > 0)
            {
                if (Convert.ToDecimal(txtAmountToBeDeducted.Text) == 100)
                {
                    if (data.Loyalty_Points >= 10)
                    {
                        points = double.Parse("10", CultureInfo.InvariantCulture);
                        Custb.Loyalty_Points = data.Loyalty_Points - (decimal)points;
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Insufficient Points')", true);
                    }
                }
                else if (Convert.ToDecimal(txtAmountToBeDeducted.Text) == 1000)
                {
                    if (data.Loyalty_Points >= 100)
                    {
                        points = double.Parse("100", CultureInfo.InvariantCulture);
                        Custb.Loyalty_Points = data.Loyalty_Points - (decimal)points;
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Insufficient Points')", true);
                    }
                }
                else if (Convert.ToDecimal(txtAmountToBeDeducted.Text) < 100)
                {
                    if (data.Loyalty_Points >= 1)
                    {
                        points = double.Parse("1", CultureInfo.InvariantCulture);
                        Custb.Loyalty_Points = data.Loyalty_Points - (decimal)points;
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Insufficient Points')", true);
                    }
                }
                else if (Convert.ToDecimal(txtAmountToBeDeducted.Text) > 1000)
                {
                    if (data.Loyalty_Points >= 150)
                    {
                        points = double.Parse("150", CultureInfo.InvariantCulture);
                        Custb.Loyalty_Points = data.Loyalty_Points - (decimal)points;
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Insufficient Points')", true);
                    }
                }
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('You don't have points to Redeem')", true);
            }


            Cusbl.UpdateCustomer(Custb);
        }
Ejemplo n.º 18
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            using (LoyaltyPointSystemEntities db = new LoyaltyPointSystemEntities())
            {
                string username = txtUsername.Text;
                string password = txtPassword.Text;

                var user = db.Employees.ToList().FirstOrDefault(x => x.Username == username && x.Password == txtPassword.Text.Trim());

                if (user != null)
                {
                    Session["UserId"] = user.ID;

                    //Decrypt password

                    Session["UserName"] = user.Username;
                    Session["UserRole"] = user.RoleID;
                    Session["Name"]     = user.Name;
                    //Session["UserId"] = user.UserId;



                    // string dencryptedPassword = business.Decrypt(user.Password);

                    var pass = db.Employees.ToList().FirstOrDefault(x => x.Username == username && x.Password == txtPassword.Text.Trim());

                    if (password == pass.Password)
                    {
                        //Store user login details in Session

                        Session["UserName"] = user.Username;
                        //Session["UserRole"] = user.RoleID;
                        Session["UserId"] = user.ID;
                        Session["Name"]   = user.Name;



                        if (user.RoleID == 1)
                        {
                            Session["UserRole"] = "General Employee";
                            Response.Redirect("~/Views/ViewAllCustomers.aspx?");
                        }
                        else if (user.RoleID == 2)
                        {
                            Session["UserRole"] = "Administrator";
                            Response.Redirect("~/Views/ViewAllCustomers.aspx?");
                        }


                        else if (user.RoleID == 3)
                        {
                            Session["UserRole"] = "Supervisor";
                            Response.Redirect("~/Views/ViewAllCustomers.aspx?");
                        }
                        else
                        {
                            lblErrorMessage.Visible = true;
                            lblErrorMessage.Text    = "The password provided is incorrect.";

                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter Correct UserName and Password!')", true);
                        }
                    }

                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter Correct UserName and Password!')", true);
                    }
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Please enter Correct UserName and Password!')", true);
                }
            }
        }