Beispiel #1
0
    protected void btnUpdateUserAdmin_Click(object sender, EventArgs e)
    {
        try
        {
            string x   = (String)(Session["un"]);
            var    usr = db.Users.Where(d => d.Email == x).FirstOrDefault();

            if (usr != null)
            {
                usr.Email             = txtEmail.Text;
                usr.FirstName         = txtFirstName.Text;
                usr.LastName          = txtLastName.Text;
                usr.Password          = txtPassword.Text;
                usr.Role              = txtRole.Text;
                usr.AccountCreateDate = DateTime.Parse(txtAccountCreateDate.Text);
                usr.AddressLine1      = txtAddressLine1.Text;
                usr.AddressLine2      = txtAddressLine2.Text;
                usr.PostCode          = txtPostCode.Text;
                usr.Phone             = txtPhone.Text;
                usr.DivisionId        = Int32.Parse(DropDownListDivision.Text);

                db.SaveChanges();
                litMessage.Text = "data update successfully!";
            }
            else
            {
                litMessage.Text = "<span style='color:red'>data can not update!!! </span>";
            }
        }
        catch (Exception)
        {
            litMessage.Text = "something went wrong!";
        }
    }
Beispiel #2
0
    protected void btnAddSupplier_Click(object sender, EventArgs e)
    {
        Supplier supl = new Supplier();

        try
        {
            string   sup = txtSupplierName.Text;
            Supplier su  = db.Suppliers.ToList().SingleOrDefault(s => s.SupplierName == sup);
            if (su.SupplierName == sup)
            {
                lblAlertMessage.Text = txtSupplierName.Text + " Supplier Name is Already Exiest!";
            }
            else
            {
            }
        }
        catch (Exception)
        {
            supl.SupplierName  = txtSupplierName.Text;
            supl.SupplierEmail = txtSupplierEmail.Text;
            supl.SupplierPhone = txtSupplierPhone.Text;

            db.Suppliers.Add(supl);
            db.SaveChanges();
            txtSupplierName.Text  = "";
            txtSupplierEmail.Text = "";
            txtSupplierPhone.Text = "";

            lblSuccessMessage.Text = "Supplier Insert Successfully!";
        }
    }
        public ActionResult ResetPassword(ResetPasswordModel model)
        {
            var message = "";

            if (ModelState.IsValid)
            {
                using (myDatabaseEntities1 dc = new myDatabaseEntities1())
                {
                    var user = dc.Users.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault();
                    if (user != null)
                    {
                        user.Password          = Crypto.Hash(model.NewPassword);
                        user.ResetPasswordCode = "";
                        dc.Configuration.ValidateOnSaveEnabled = false;
                        dc.SaveChanges();
                        message = "New Password has been updated successfully.";
                    }
                }
            }
            else
            {
                message = "Something invalid";
            }
            ViewBag.Message = message;
            return(View(model));
        }
Beispiel #4
0
    protected void btnAddProduct_Click(object sender, EventArgs e)
    {
        var ProductData = db.Products.Where(d => d.Id == IdNumber).FirstOrDefault();

        ProductData.ProductName        = txtProductName.Text;
        ProductData.ProductDescription = txtDescription.Text;
        ProductData.Quantity           = Int32.Parse(txtQuantity.Text);
        ProductData.Price      = decimal.Parse(txtPrice.Text);
        ProductData.SKU        = txtSKU.Text;
        ProductData.BrandImage = lblBrandImage.Text;

        if (fileProductImage.HasFiles)
        {
            //fileProductImage.SaveAs(Server.MapPath("./Images/" + fileProductImage.FileName));
            //imgProduct.ImageUrl = "./Images/" + fileProductImage.FileName;

            lblProductImage.Text     = fileProductImage.FileName;
            ProductData.ProductImage = lblProductImage.Text;

            fileProductImage.SaveAs(Server.MapPath("./Images/" + lblProductImage.Text));
            imgProduct.ImageUrl = "./Images/" + fileProductImage.FileName;
        }



        db.SaveChanges();
        lblSuccessMessage.Text = "Product Update Successfully!";
    }
Beispiel #5
0
    protected void btnAddProduct_Click(object sender, EventArgs e)
    {
        Product pr = new Product();

        pr.ProductName        = txtProductName.Text;
        pr.ProductDescription = txtDescription.Text;
        pr.Quantity           = Int32.Parse(txtQuantity.Text);
        pr.Price        = decimal.Parse(txtPrice.Text);
        pr.SKU          = txtSKU.Text;
        pr.BrandImage   = lblBrandImage.Text;
        pr.BrandName    = dropBrandName.Text;
        pr.CategoryName = dropCategoryName.Text;
        pr.SupplierId   = Int32.Parse(dropSupplierName.Text);
        pr.WarrentyType = dropWarrentyType.Text;



        if (fileProductImage.HasFiles)
        {
            //fileProductImage.SaveAs(Server.MapPath("./Images/" + fileProductImage.FileName));
            //imgProduct.ImageUrl = "./Images/" + fileProductImage.FileName;

            lblProductImage.Text = fileProductImage.FileName;
            pr.ProductImage      = lblProductImage.Text;

            fileProductImage.SaveAs(Server.MapPath("../../admin/pages/Images/" + lblProductImage.Text));
            imgProduct.ImageUrl = "../../admin/pages/Images/" + fileProductImage.FileName;
        }


        db.Products.Add(pr);
        db.SaveChanges();
        lblSuccessMessage.Text = "Product Added Successfully!";
    }
        public JsonResult SaveEvent(Event e)
        {
            var status = false;

            using (myDatabaseEntities1 dc = new myDatabaseEntities1())
            {
                if (e.EventId > 0)
                {
                    //Update the event
                    var v = dc.Events.Where(a => a.EventId == e.EventId).FirstOrDefault();
                    if (v != null)
                    {
                        v.Subject     = e.Subject;
                        v.Start       = e.Start;
                        v.End         = e.End;
                        v.Description = e.Description;
                        v.IsFullDay   = e.IsFullDay;
                        v.ThemeColor  = e.ThemeColor;
                    }
                }
                else
                {
                    dc.Events.Add(e);
                }
                dc.SaveChanges();
                status = true;
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public ActionResult ForgetPassword(string EmailID)
        {
            //verify email Id

            //Generate Reset Password Link

            //Send email

            string message = "";
            bool   status  = false;

            using (myDatabaseEntities1 dc = new myDatabaseEntities1())
            {
                var account = dc.Users.Where(a => a.EmailId == EmailID).FirstOrDefault();

                if (account != null)
                {
                    string resetCode = Guid.NewGuid().ToString();
                    SendVerificationLinkEmail(account.EmailId, resetCode, "ResetPassword");
                    account.ResetPasswordCode = resetCode;

                    dc.Configuration.ValidateOnSaveEnabled = false;
                    dc.SaveChanges();
                    message = "Reset Password link has been sent to your email address";
                }
                else
                {
                    message = "Error!!, Email or Account does not exist";
                }
            }

            ViewBag.Message = message;
            return(View());
        }
Beispiel #8
0
    protected void BtnAddCategory_Click(object sender, EventArgs e)
    {
        Category cate = new Category();

        try
        {
            string   cat = TxtCategoryName.Text;
            Category ca  = db.Categories.ToList().SingleOrDefault(c => c.CategoryName == cat);

            if (ca.CategoryName == cat)
            {
                lblSuccessMessage.Text = "";
                lblAlertMessage.Text   = TxtCategoryName.Text + " Category is Already Exist!";
            }
            else
            {
            }
        }
        catch (Exception)
        {
            cate.CategoryName        = TxtCategoryName.Text;
            cate.CategoryDescription = TxtCategoryDescription.Text;

            db.Categories.Add(cate);
            db.SaveChanges();
            lblAlertMessage.Text        = "";
            lblSuccessMessage.Text      = "Category Insert Successfully!";
            TxtCategoryName.Text        = "";
            TxtCategoryDescription.Text = "";
        }
    }
Beispiel #9
0
    protected void ButtonAdd_Click(object sender, EventArgs e)
    {
        Brand brnd = new Brand();

        brnd.BrandName        = TextBoxBrandName.Text;
        brnd.BrandDescription = TextBoxdescription.Text;
        brnd.SupplierId       = Int32.Parse(DropDownList1.SelectedValue);

        if (checkBrand())
        {
            LabelMessage.Text = "brand already exiest!";
            return;
        }

        if (fileBrandImage.HasFile)
        {
            LabelBrandImage.Text = fileBrandImage.FileName;

            brnd.BrandImage = LabelBrandImage.Text;


            fileBrandImage.SaveAs(Server.MapPath("./Images/" + LabelBrandImage.Text));
            ImageBrand.ImageUrl = "./Images/" + fileBrandImage.FileName;
        }

        db.Brands.Add(brnd);
        db.SaveChanges();

        LabelMessage.Text = "brand add success!";
    }
Beispiel #10
0
    protected void btnWarrentyType_Click(object sender, EventArgs e)
    {
        Warrenty wrty = new Warrenty();

        try
        {
            string   wrt = txtWarrentyType.Text;
            Warrenty wr  = db.Warrenties.ToList().SingleOrDefault(d => d.WarrentyType == wrt);
            if (wr.WarrentyType == wrt)
            {
                lblSuccessMessage.Text = "";
                lblAlertMessage.Text   = txtWarrentyType.Text + " Warrenty Type is Already Exiest!";
            }
            else
            {
            }
        }
        catch (Exception)
        {
            wrty.WarrentyType = txtWarrentyType.Text;

            db.Warrenties.Add(wrty);
            db.SaveChanges();

            txtWarrentyType.Text   = "";
            lblAlertMessage.Text   = "";
            lblSuccessMessage.Text = "Warrenty Type Insert Successfully!";
        }
    }
Beispiel #11
0
    protected void btnAddDivision_Click(object sender, EventArgs e)
    {
        Division divi = new Division();

        try
        {
            string   div = txtDivisionName.Text.ToLower();
            Division di  = db.Divisions.ToList().SingleOrDefault(d => d.DivisionName == div);
            if (di.DivisionName == div)
            {
                lblSuccessMessage.Text = "";
                lblAlertMessage.Text   = txtDivisionName.Text + " Division is Already Exiest!";
            }
            else
            {
            }
        }
        catch (Exception)
        {
            divi.DivisionName        = txtDivisionName.Text;
            divi.DivisionDescription = txtDivisionDescription.Text;

            db.Divisions.Add(divi);
            db.SaveChanges();

            txtDivisionName.Text        = "";
            txtDivisionDescription.Text = "";
            lblAlertMessage.Text        = "";
            lblSuccessMessage.Text      = "Division Insert Successfully!";
        }
    }
        public ActionResult Registration([Bind(Exclude = "IsEmailVerified, ActivationCode")] User user)
        {
            bool   Status  = false;
            string Message = "";

            //Model validation

            if (ModelState.IsValid)
            {
                #region//Email Already Exist
                var isExist = isEmailExist(user.EmailId);
                if (isExist)
                {
                    ModelState.AddModelError("EmailExist", "Email Already Exist");
                    return(View(user));
                }
                #endregion

                #region  //Generate Activation code
                user.ActivationCode = Guid.NewGuid();
                #endregion


                #region  //Password Hashing
                user.Password        = Crypto.Hash(user.Password);
                user.ConfirmPassword = Crypto.Hash(user.ConfirmPassword);
                #endregion
                user.IsEmailVerified = false;


                #region  //Save data to database
                using (myDatabaseEntities1 dc = new myDatabaseEntities1())
                {
                    dc.Users.Add(user);
                    dc.SaveChanges();
                    //Send email to user
                    SendVerificationLinkEmail(user.EmailId, user.ActivationCode.ToString());
                    Message = "Registration Successfully Completed. Account activation link" +
                              "has been sent to you email address " + user.EmailId;
                    Status = true;
                }
                #endregion
            }
            else
            {
                Message = "Invalid Request";
            }

            ViewBag.Message = Message;
            ViewBag.Status  = Status;
            return(View(user));
        }
Beispiel #13
0
    protected void brnAddBrand_Click(object sender, EventArgs e)
    {
        Brand brnd = new Brand();
        //try
        //{
        string brn = txtBrandName.Text.ToLower();

        //var br = db.Brands.Where(b => b.BrandName == brn).FirstOrDefault();
        //if (br!=null)
        //{
        //    lblSuccessMessage.Text = "";
        //    LabelBrandNameExiest.Text = txtBrandName.Text + " Brand is Already Exiest!";

        //}
        //else
        //{
        brnd.BrandName        = txtBrandName.Text.ToLower();
        brnd.BrandDescription = txtBrandDescription.Text;
        brnd.SupplierId       = Int32.Parse(dropSupplierName.Text);
        if (fileBrandImage.HasFile)
        {
            //check file type (images)
            //if (Path.GetExtension(fileBrandImage.PostedFile.FileName) != "jpg"
            //    || Path.GetExtension(fileBrandImage.PostedFile.FileName) != "png")
            //{
            //    lblAlertMessage.Text = "Invalide image type! please try with valid one!";
            //    return;
            //}
            lblBrandImage.Text = fileBrandImage.FileName;
            brnd.BrandImage    = fileBrandImage.FileName;

            fileBrandImage.SaveAs(Server.MapPath("./Images/" + fileBrandImage.FileName));
            imgBrand.ImageUrl = "./Images/" + fileBrandImage.FileName;
        }

        db.Brands.Add(brnd);
        db.SaveChanges();

        //txtBrandName.Text = "";
        //txtBrandDescription.Text = "";
        //dropSupplierName.Text = "";
        //lblBrandImage.Text = "";
        //lblAlertMessage.Text = "";
        lblSuccessMessage.Text = "Brand Insert Successfully!";
        //}
        //}
        //catch (Exception ex1)
        //{

        //    lblAlertMessage.Text = "" + ex1.Message;
        //}
    }
Beispiel #14
0
    protected void btnUpdateUserAdmin_Click(object sender, EventArgs e)
    {
        try
        {
            string x   = (String)(Session["un"]);
            var    usr = db.Users.Where(d => d.Email == x).FirstOrDefault();

            if (usr != null)
            {
                usr.Email             = txtEmail.Text;
                usr.FirstName         = txtFirstName.Text;
                usr.LastName          = txtLastName.Text;
                usr.Password          = txtPassword.Text;
                usr.Role              = txtRole.Text;
                usr.AccountCreateDate = DateTime.Parse(txtAccountCreateDate.Text);
                usr.AddressLine1      = txtAddressLine1.Text;
                usr.AddressLine2      = txtAddressLine2.Text;
                usr.PostCode          = txtPostCode.Text;
                usr.Phone             = txtPhone.Text;
                usr.DivisionId        = Int32.Parse(dropDownDivision.Text);


                //emp.Salary = decimal.Parse(txtSalaey.Text);

                //if (FileUpload1.HasFile)
                //{

                //    lblPhoto.Text = FileUpload1.FileName;
                //    emp.Photo = lblPhoto.Text;

                //    FileUpload1.SaveAs(Server.MapPath("./myPic/" + lblPhoto.Text));
                //    Image1.ImageUrl = "./myPic/" + FileUpload1.FileName;
                //}

                db.SaveChanges();
                litMessage.Text = "data update successfully!";
            }
            else
            {
                litMessage.Text = "data can not update!!!";
            }
        }
        catch (Exception)
        {
            litMessage.Text = "something went wrong!";
        }
    }
        public JsonResult DeleteEvent(int eventId)
        {
            var status = false;

            using (myDatabaseEntities1 dc = new myDatabaseEntities1())
            {
                var v = dc.Events.Where(a => a.EventId == eventId).FirstOrDefault();
                if (v != null)
                {
                    dc.Events.Remove(v);
                    dc.SaveChanges();
                    status = true;
                }
            }
            return(new JsonResult {
                Data = new { status = status }
            });
        }
Beispiel #16
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row  = GridView1.Rows[e.RowIndex];
        int         x    = Int32.Parse(((TextBox)(row.Cells[3].Controls[0])).Text);
        var         data = db.Orders.Where(o => o.Id == x).FirstOrDefault();

        //Update the values.

        data.DeliveryStatus = ((DropDownList)(row.Cells[2].FindControl("DropdownList1"))).Text;
        data.OrderDate      = DateTime.Parse(((TextBox)(row.Cells[4].Controls[0])).Text);
        data.GranTotal      = decimal.Parse(((TextBox)(row.Cells[5].Controls[0])).Text);

        db.SaveChanges();
        //Reset the edit index.
        GridView1.EditIndex = -1;

        GridView1.DataSource = db.Orders.Select(od => new { od.Id, od.OrderDate, od.GranTotal, od.DeliveryStatus, od.CustomerId }).ToList();
        GridView1.DataBind();
    }
Beispiel #17
0
    protected void btnUpdateUser_Click(object sender, EventArgs e)
    {
        var UserData = db.Users.Where(u => u.Id == IdNumber).FirstOrDefault();

        UserData.Email     = txtEmail.Text;
        UserData.FirstName = txtFirstName.Text;
        UserData.LastName  = txtLastName.Text;
        UserData.Password  = txtPassword.Text;
        UserData.Role      = txtRole.Text;
        //UserData.AccountCreateDate = DateTime.Parse(txtAccountCreateDate.Text);
        UserData.AddressLine1 = txtAddressLine1.Text;
        UserData.AddressLine2 = txtAddressLine2.Text;
        UserData.PostCode     = txtPostCode.Text;
        UserData.Phone        = txtPhone.Text;
        UserData.DivisionId   = Int32.Parse(dropDivisionList.Text);

        db.SaveChanges();
        litMessage.Text = "User update successfully! " + DateTime.Now.ToString();
    }
        public ActionResult VerifyAccount(string id)
        {
            bool status = false;

            using (myDatabaseEntities1 dc = new myDatabaseEntities1())
            {
                dc.Configuration.ValidateOnSaveEnabled = false;

                var v = dc.Users.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault();
                if (v != null)
                {
                    v.IsEmailVerified = true;
                    dc.SaveChanges();
                    status = true;
                }
                else
                {
                    ViewBag.Message = "Request Is Invalid";
                }
            }

            ViewBag.status = status;
            return(View());
        }
Beispiel #19
0
    protected void btnAddUser_Click(object sender, EventArgs e)
    {
        User usrs = new User();


        try
        {
            string usr = txtEmail.Text;
            User   us  = db.Users.ToList().SingleOrDefault(u => u.Email == usr);

            if (us.Email == usr)
            {
                //litEmailMessage.Text = txtEmail.Text + " Category is Already Exist!";
                lblSuccessMessage.Text = "";
                lblAlertMessage.Text   = "(" + txtEmail.Text + " Email is Already Exist!" + ")";
            }
        }
        catch (Exception)
        {
            usrs.Email             = txtEmail.Text;
            usrs.FirstName         = txtFirstName.Text;
            usrs.LastName          = txtLastName.Text;
            usrs.Role              = DropDownListRole.Text;
            usrs.Password          = txtPassword.Text;
            usrs.AccountCreateDate = DateTime.Parse(txtAccountCreateDate.Text);

            if (checkBoxEmail.Checked == true)
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                mail.To.Add(txtEmail.Text);
                mail.From            = new System.Net.Mail.MailAddress("*****@*****.**", "Admin", System.Text.Encoding.UTF8);//"*****@*****.**", "Admin"
                mail.Subject         = "Your account info";
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.Body            = "<b>" + "your user email is- " + "</b>" + txtEmail.Text + "<br>" + " your password is- " + txtPassword.Text;
                mail.BodyEncoding    = System.Text.Encoding.UTF8;
                mail.IsBodyHtml      = true;
                mail.Priority        = System.Net.Mail.MailPriority.High;

                //if (FileUpload1.HasFile)
                //{
                //    string FileName = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
                //    mail.Attachments.Add(new System.Net.Mail.Attachment(FileUpload1.PostedFile.InputStream, FileName));
                //}

                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "retroelectro112233"); //"*****@*****.**", "round-27"
                client.Port        = 587;
                client.Host        = "smtp.gmail.com";
                client.EnableSsl   = true;

                try
                {
                    client.Send(mail);
                    ClientScript.RegisterStartupScript(GetType(), "alert", "alert: ('email sent successfully!')");
                }
                catch (Exception ex)
                {
                    litMessage.Text = ex.Message;
                }

                lblSuccessMessage.Text = "Email sent to user, account create successfully!";
                db.Users.Add(usrs);
                db.SaveChanges();
            }

            else
            {
                lblSuccessMessage.Text = "Account create successfully!";
                db.Users.Add(usrs);
                db.SaveChanges();
            }
        }
    }
Beispiel #20
0
    protected void btnAddProduct_Click(object sender, EventArgs e)
    {
        Product prod = new Product();

        try
        {
            string  pro = txtProductName.Text;
            Product pr  = db.Products.ToList().SingleOrDefault(p => p.ProductName == pro);
            if (pr.ProductName == pro)
            {
                lblSuccessMessage.Text = "";
                lblAlertMessage.Text   = txtProductName.Text + " Product is Already Exiest!";
            }
            else
            {
            }
        }
        catch (Exception)
        {
            prod.ProductName        = txtProductName.Text;
            prod.SKU                = txtSKU.Text;
            prod.ProductDescription = txtDescription.Text;
            prod.SupplierId         = Int32.Parse(dropSupplierName.Text);
            prod.CategoryName       = dropCategoryName.Text;
            prod.Quantity           = Int32.Parse(txtQuantity.Text);
            prod.Price              = decimal.Parse(txtPrice.Text);
            prod.BrandName          = dropBrandName.Text;
            prod.WarrentyType       = dropWarrentyType.Text;
            prod.BrandImage         = lblBrandImage.Text;

            if (fileProductImage.HasFile)
            {
                // file validation check
                //if (Path.GetExtension(fileProductImage.PostedFile.FileName) !="jpg"
                //    || Path.GetExtension(fileProductImage.PostedFile.FileName) != "png")
                //{
                //    lblAlertMessage.Text = "Invalide image type! please try with valid one!";
                //    return;
                //}
                lblProductImage.Text = fileProductImage.FileName;
                prod.ProductImage    = lblProductImage.Text;

                fileProductImage.SaveAs(Server.MapPath("./admin/pages/Images/" + lblProductImage.Text));
                imgProduct.ImageUrl = "./admin/pages/Images/" + fileProductImage.FileName;
            }

            //if (FileBrandImage.HasFile)
            //{
            //    lblBrandImage.Text = FileBrandImage.FileName;
            //    prod.BrandImage = lblBrandImage.Text;

            //    FileBrandImage.SaveAs(Server.MapPath("./Images/" + lblBrandImage.Text));
            //    imgBrand.ImageUrl = "./Images/" + FileBrandImage.FileName;


            //}


            db.Products.Add(prod);
            db.SaveChanges();

            txtProductName.Text = "";
            txtDescription.Text = "";
            txtQuantity.Text    = "";
            txtPrice.Text       = "";
            txtSKU.Text         = "";

            lblAlertMessage.Text   = "";
            lblSuccessMessage.Text = "Product Insert Successfully!";
        }
    }
Beispiel #21
0
    protected void ButtonCheckOut_Click(object sender, EventArgs e)
    {
        if (LabelGtotal.Text == "0")
        {
            LabelOrderSuccess.Text = "<p style='color:blue; font-size: 20px;'>" + "no item to order!" + "</p>";
            return;
        }
        else
        {
            Order ord = new Order();

            ord.OrderDate      = DateTime.Now.Date;
            ord.GranTotal      = decimal.Parse(LabelGtotal.Text);
            ord.CustomerId     = Int32.Parse(Session["uid"].ToString());
            ord.DeliveryStatus = "Pending";

            db.Orders.Add(ord);
            db.SaveChanges();

            OrderDetail ordetails = new OrderDetail();
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ordetails.OrderId   = ord.Id;
                ordetails.ProductId = Int32.Parse(dt.Rows[i][0].ToString());
                ordetails.Quantity  = Int32.Parse(dt.Rows[i][3].ToString());
                ordetails.Price     = decimal.Parse(dt.Rows[i][4].ToString());

                ordetails.Total = decimal.Parse(dt.Rows[i][5].ToString());



                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                mail.To.Add("*****@*****.**");
                mail.From            = new System.Net.Mail.MailAddress("*****@*****.**", "Admin", System.Text.Encoding.UTF8);//"*****@*****.**", "Admin"
                mail.Subject         = "New order!";
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.Body            = "<p style='color:red; font-size: 50px;'>" + "New order has arrive!" + "</p>";
                mail.BodyEncoding    = System.Text.Encoding.UTF8;
                mail.IsBodyHtml      = true;
                mail.Priority        = System.Net.Mail.MailPriority.High;

                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "retroelectro112233"); //"*****@*****.**", "round-27"
                client.Port        = 587;
                client.Host        = "smtp.gmail.com";
                client.EnableSsl   = true;

                try
                {
                    client.Send(mail);
                    ClientScript.RegisterStartupScript(GetType(), "alert", "alert: ('email sent successfully!')");
                }
                catch (Exception ex)
                {
                    LabelCustomerEmail.Text = ex.Message;
                }
                System.Threading.Thread.Sleep(3000);

                LabelOrderSuccess.Text = "<p style='color:green; font-size: 50px;'>" + "your order has process successfully! please check your RE account!" + "</p>";

                db.OrderDetails.Add(ordetails);
                db.SaveChanges();
            }

            Session["dt"] = null;
            dt            = (DataTable)Session["dt"];

            //Label lbl_UserName = this.Master.FindControl("LabelCart") as Label;
            //lbl_UserName.Text = Session["dt"].ToString();

            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
    }
Beispiel #22
0
    protected void btnSignup_Click(object sender, EventArgs e)
    {
        if (txtPassword.Text != txtConfirmPassword.Text)
        {
            lblExistingMessage.Text = "";
            lblSuccessMessage.Text  = "";
            lblPassNotMatch.Text    = "password not match";
            return;
        }


        User usrs = new User();

        try
        {
            string usr = txtEmail.Text;
            User   us  = db.Users.ToList().SingleOrDefault(u => u.Email == usr);

            if (us.Email == usr)
            {
                //litEmailMessage.Text = txtEmail.Text + " Category is Already Exist!";
                lblPassNotMatch.Text    = "";
                lblSuccessMessage.Text  = "";
                lblExistingMessage.Text = "(" + txtEmail.Text + " Email is Already Exist!" + ")";
            }
        }
        catch (Exception)
        {
            usrs.Email             = txtEmail.Text;
            usrs.FirstName         = txtFirstName.Text;
            usrs.LastName          = txtLastName.Text;
            usrs.Role              = txtRoleCustomer.Text;
            usrs.Password          = txtConfirmPassword.Text;
            usrs.AccountCreateDate = DateTime.Parse(txtAccountCreateDate.Text);

            if (checkGetConfirmEmail.Checked == true)
            {
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                mail.To.Add(txtEmail.Text);
                mail.From            = new System.Net.Mail.MailAddress("*****@*****.**", "Admin", System.Text.Encoding.UTF8);//"*****@*****.**", "Admin"
                mail.Subject         = "RE customer account Confirmation!";
                mail.SubjectEncoding = System.Text.Encoding.UTF8;
                mail.Body            = "<b>" + "your user email is- " + "</b>" + txtEmail.Text + "<br>" + " your password is- " + txtPassword.Text;
                mail.BodyEncoding    = System.Text.Encoding.UTF8;
                mail.IsBodyHtml      = true;
                mail.Priority        = System.Net.Mail.MailPriority.High;

                System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
                client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "retroelectro112233"); //"*****@*****.**", "round-27"
                client.Port        = 587;
                client.Host        = "smtp.gmail.com";
                client.EnableSsl   = true;

                try
                {
                    client.Send(mail);
                    ClientScript.RegisterStartupScript(GetType(), "alert", "alert: ('email sent successfully!')");
                }
                catch (Exception ex)
                {
                    //litMessage.Text = ex.Message;
                }
                lblPassNotMatch.Text    = "";
                lblExistingMessage.Text = "";
                lblSuccessMessage.Text  = "Check your Email, account create successfully!";
                db.Users.Add(usrs);
                db.SaveChanges();
            }

            else
            {
                lblPassNotMatch.Text    = "";
                lblExistingMessage.Text = "";
                lblSuccessMessage.Text  = "Account create successfully!";
                db.Users.Add(usrs);
                db.SaveChanges();
            }
        }
    }