예제 #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            pnLogin.Visible    = true;
            pnUserInfo.Visible = false;

            if (CookieUtility.GetCookie("Member_Email") != null)
            {
                if (MemberDB.GetIDByEmail(CookieUtility.GetCookie("Member_Email")) != 0)
                {
                    MemberInfo info = MemberDB.GetInfoByEmail(CookieUtility.GetCookie("Member_Email"));
                    if (info != null)
                    {
                        pnLogin.Visible    = false;
                        pnUserInfo.Visible = true;

                        lnkMemberInfo.Text        = info.Member_Fullname;
                        lnkMemberInfo.NavigateUrl = lnkUserCP.NavigateUrl = AppEnv.WEB_CMD + "memberinfo&id=" + info.Member_ID;
                    }
                }
            }
        }
예제 #2
0
        protected void butRegister_Click(object sender, EventArgs e)
        {
            try
            {
                if (chkAgree.Checked)
                {
                    string email           = txtEmail.Text.Trim();
                    string password        = txtPassword.Text.Trim();
                    string confirmpassword = txtConfirmPassword.Text.Trim();
                    string fullname        = txtFullName.Text.Trim();

                    if (ConvertUtility.ToInt32(MemberDB.GetIDByEmail(email)) > 0)
                    {
                        MessageBox.Show("Email này đã được sử dụng trên my-deal.vn");
                        return;
                    }


                    if (!MiscUtility.CheckEmail(email))
                    {
                        MessageBox.Show("Email đăng ký không hợp lệ");
                        return;
                    }
                    if (email.Length == 0 || password.Length == 0 || confirmpassword.Length == 0 || fullname.Length == 0)
                    {
                        MessageBox.Show("Bạn phải điền đầy đủ các trường yêu cầu (*)");
                        return;
                    }
                    if (password != confirmpassword)
                    {
                        MessageBox.Show("Bạn nhập lại mật khẩu không đúng");
                        return;
                    }

                    string newpassword = SecurityMethod.MD5Encrypt(password);

                    var memberInfo = new MemberInfo
                    {
                        Member_Email            = email,
                        Member_Password         = newpassword,
                        Member_Fullname         = HTMLUtility.SecureHTML(fullname),
                        Member_Gender           = 2,
                        Member_Avatar           = "",
                        Member_Tel              = "",
                        Member_Address          = "",
                        Member_District         = "",
                        Member_City             = "",
                        Member_Rank             = 0,
                        Member_Birthday         = DateTime.Now,
                        Member_Active           = false,
                        Member_ActiveCode       = newpassword,
                        Member_IsForgotPassword = false
                    };

                    int memberid = MemberDB.Insert(memberInfo);

                    string activeUrl     = "http://" + Request.Url.Host + AppEnv.WEB_CMD + "active&code=" + newpassword + "&mi=" + memberid;
                    string manuactiveUrl = "http://" + Request.Url.Host + AppEnv.WEB_CMD + "activemanual";

                    var sb = new StringBuilder();
                    sb.Append("Xin chao, ");
                    sb.Append(fullname);
                    sb.Append("<br /><br />Chao mung ban den voi My-Deal.vn!");
                    sb.Append("<br />De hoan tat thu tuc dang ky, ban hay click vao day de kich hoat tai khoan cua minh");
                    sb.Append("<br />");
                    sb.Append("<a href=\"" + activeUrl + "\">" + activeUrl + "</a>");
                    sb.Append("<br /><br />");
                    sb.Append("Hoac ban vao duong dan duoi day:");
                    sb.Append("<br />");
                    sb.Append(manuactiveUrl);
                    sb.Append("<br />");
                    sb.Append("<br />");
                    sb.Append("Va dien vao cac thong tin sau:");
                    sb.Append("<br />");
                    sb.Append("<br />");
                    sb.Append("MI: " + memberid);
                    sb.Append("<br />");
                    sb.Append("Ma kich hoat: " + newpassword);
                    sb.Append("<br />");
                    sb.Append("<br />");
                    sb.Append("Xin chan thanh cam on!");
                    sb.Append("<br />My-Deal.vn");

                    string adminEmail = AppEnv.ContactEmail;


                    // new email solution start
                    MailMessage emailmess = new MailMessage(adminEmail, email);
                    emailmess.Subject    = "Kich hoat tai khoan tai My-Deal.vn";
                    emailmess.IsBodyHtml = true;
                    emailmess.Body       = sb.ToString();

                    SmtpClient smtp = new SmtpClient();

                    if (AppEnv.MailServer.Length == 0)
                    {
                        smtp.Host = "localhost";
                    }
                    else
                    {
                        smtp.Host = AppEnv.MailServer;
                    }

                    if (AppEnv.MailServerPort.Length == 0)
                    {
                        smtp.Port = 25;
                    }
                    else
                    {
                        smtp.Port = ConvertUtility.ToInt32(AppEnv.MailServerPort);
                    }

                    // if authentication
                    if (AppEnv.MailUsername.Length > 0 && AppEnv.MailPassword.Length > 0)
                    {
                        smtp.Credentials    = new NetworkCredential(AppEnv.MailUsername, AppEnv.MailPassword);
                        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                    }
                    // if authentication end

                    try
                    {
                        smtp.Send(emailmess);
                        notice.InnerHtml = "<br><br><br><font color=red><b>Email kích hoạt đã được gửi tới hòm thư " + email + ", vui lòng kiểm trả hòm thư đăng ký để hoàn tất thủ tục đăng ký.<br /><br />Xin chân thành cảm ơn</b></font>";
                    }
                    catch (Exception ex)
                    {
                        notice.InnerHtml = "<br /><br /><br /><font color=red><b>Email kích hoạt đã được gửi tới cho bạn, vui lòng kiểm tra hòm thư đăng ký để hoàn tất thủ tục đăng ký.<br /><br />Xin chân thành cảm ơn.</b></font>";
                        ErrorReportDB.NewReport(Request.RawUrl, ex.ToString());
                    }
                    finally
                    {
                        pnRegister.Visible = false;
                        notice.Visible     = true;
                    }
                }
                else
                {
                    MessageBox.Show("Bạn phải lựa chọn đồng ý với các điều khỏa của MyDeal");
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            if (chkAgree.Checked)
            {
                var fullname  = HTMLUtility.SecureHTML(txtFullName.Text.Trim());
                var tel       = HTMLUtility.SecureHTML(txtTel.Text.Trim());
                var address   = HTMLUtility.SecureHTML(txtAddress.Text.Trim());
                var district  = HTMLUtility.SecureHTML(txtDistrict.Text.Trim());
                var city      = HTMLUtility.SecureHTML(txtCity.Text.Trim());
                var note      = HTMLUtility.SecureHTML(txtNote.Text.Trim());
                var orderdate = DateTime.Now;


                if (fullname.Length == 0 || tel.Length == 0 || address.Length == 0 || district.Length == 0 || city.Length == 0)
                {
                    MessageBox.Show("Bạn phải điền đủ các trường (*)");
                    return;
                }



                var cart = (CommonLibrary.CartShopping.Cart)Session["cart"];

                string email = CookieUtility.GetCookie("Member_Email");

                var totalprice = cart.TotalPrice;

                var memberInfo = MemberDB.GetInfoByEmail(email);
                if (memberInfo.Member_Fullname.Length == 0)
                {
                    memberInfo.Member_Fullname = fullname;
                }
                if (memberInfo.Member_Tel.Length == 0)
                {
                    memberInfo.Member_Tel = tel;
                }
                if (memberInfo.Member_Address.Length == 0)
                {
                    memberInfo.Member_Address = address;
                }
                if (memberInfo.Member_District.Length == 0)
                {
                    memberInfo.Member_District = district;
                }
                if (memberInfo.Member_City.Length == 0)
                {
                    memberInfo.Member_City = city;
                }

                MemberDB.Update(memberInfo);

                var info = new OrderInfo();

                info.Member_ID        = MemberDB.GetIDByEmail(email);
                info.Order_Fullname   = fullname;
                info.Order_Email      = email;
                info.Order_Tel        = tel;
                info.Order_Address    = address;
                info.Order_District   = district;
                info.Order_City       = city;
                info.Order_Note       = note;
                info.Order_CreateDate = orderdate;
                info.Order_Status     = 0;
                info.Order_Price      = ConvertUtility.ToDouble(totalprice);
                info.Order_Quantity   = ConvertUtility.ToInt32(cart.Items.Count);

                var orderid = OrderDB.Insert(info);

                var sbProducts = new StringBuilder();

                sbProducts.Append("<tr>");

                foreach (DataGridItem item in dtgProduct.Items)
                {
                    var id       = ConvertUtility.ToInt32(item.Cells[0].Text);
                    var quantity = ConvertUtility.ToInt32(item.Cells[1].Text);
                    var price    = ConvertUtility.ToInt32(item.Cells[2].Text);
                    var sum      = price * quantity;
                    var oinfo    = new OrderProductInfo();


                    oinfo.Order_ID   = orderid;
                    oinfo.Content_ID = id;
                    oinfo.Quantity   = quantity;
                    oinfo.Price      = price;
                    oinfo.PriceSum   = sum;

                    OrderProductDB.Insert(oinfo);

                    sbProducts.Append("<td style=\"padding: 4px; border: 1px #b1d1e6 solid; text-align: center;\">" + item.ItemIndex + 1 + "</td>");
                    sbProducts.Append("<td style=\"padding: 4px; border: 1px #b1d1e6 solid;\">" + ContentDB.GetName(id) + "</td>");
                    sbProducts.Append("<td style=\"padding: 4px; border: 1px #b1d1e6 solid; text-align: center;\">" + quantity + "</td>");
                    sbProducts.Append("<td style=\"padding: 4px; border: 1px #b1d1e6 solid; text-align: center;\">" + string.Format("{0:0,0}", price) + "</td>");
                    sbProducts.Append("<td style=\"padding: 4px; border: 1px #b1d1e6 solid; text-align: center;\">" + string.Format("{0:0,0}", sum) + "</td>");
                }

                sbProducts.Append("</tr>");

                string emailadd = AppEnv.ContactEmail;

                var sb = new StringBuilder();
                sb.Append("Ban co don dat hang #" + orderid + " tu My-Deal.vn:");
                sb.Append("<br><br><b>Ten</b>: ");
                sb.Append(fullname);
                sb.Append("<br><b>Email</b>: ");
                sb.Append(email);
                sb.Append("<br><b>Dien thoai</b>: ");
                sb.Append(tel);
                sb.Append("<br><b>Dia chi</b>: ");
                sb.Append(txtAddress.Text);
                sb.Append("<br><b>Noi dung</b>:<br>");
                sb.Append(txtNote.Text);
                sb.Append("<br><br>-----------------------------<br>De biet thong tin chi tiet don hang, hay dang nhang vao website<br>");

                // new email solution start

                MailMessage emailmess = new MailMessage(email, emailadd);
                emailmess.Subject    = "Don dat hang cua khach hang tu website";
                emailmess.IsBodyHtml = true;
                emailmess.Body       = sb.ToString();

                SmtpClient smtp = new SmtpClient();

                if (AppEnv.MailServer.Length == 0)
                {
                    smtp.Host = "localhost";
                }
                else
                {
                    smtp.Host = AppEnv.MailServer;
                }

                if (AppEnv.MailServerPort.Length == 0)
                {
                    smtp.Port = 25;
                }
                else
                {
                    smtp.Port = ConvertUtility.ToInt32(AppEnv.MailServerPort);
                }

                // if authentication
                if (AppEnv.MailUsername.Length > 0 && AppEnv.MailPassword.Length > 0)
                {
                    smtp.Credentials    = new NetworkCredential(AppEnv.MailUsername, AppEnv.MailPassword);
                    smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
                }
                // if authentication end

                // gui cho khach hang thong tin deal

                var emailForCusContent = "";

                //try
                //{
                const string templateUrl = "/templates/deal_confirm.htm";
                var          htmlpage    = GetHtmlPage(templateUrl);
                if (htmlpage != "NULL")
                {
                    emailForCusContent = htmlpage;
                }
                //}
                //catch
                //{
                //    ErrorReportDB.NewReport(Request.RawUrl, "Thong tin CK HOSE:" + DateTime.Now);
                //}

                emailForCusContent = emailForCusContent.Replace("[[order_id]]", orderid.ToString()).Replace("[[order_datetime]]", orderdate.ToString("dd/MM/yyyy HH:mm")).Replace("[[order_note]]", note).Replace("[[order_products]]", sbProducts.ToString()).Replace("[[order_pricesum]]", string.Format("{0:0,0}", totalprice) + " VNĐ").Replace("[[order_fullname]]", fullname).Replace("[[order_address]]", address).Replace("[[order_tel]]", tel);

                // new email solution start
                var emailmess2 = new MailMessage(emailadd, email);
                emailmess2.Subject    = "[My-deal.vn] Thong tin dat hang #" + orderid;
                emailmess2.IsBodyHtml = true;
                emailmess2.Body       = emailForCusContent;

                var smtp2 = new SmtpClient();

                if (AppEnv.MailServer.Length == 0)
                {
                    smtp2.Host = "localhost";
                }
                else
                {
                    smtp2.Host = AppEnv.MailServer;
                }

                if (AppEnv.MailServerPort.Length == 0)
                {
                    smtp2.Port = 25;
                }
                else
                {
                    smtp2.Port = ConvertUtility.ToInt32(AppEnv.MailServerPort);
                }

                // if authentication
                if (AppEnv.MailUsername.Length > 0 && AppEnv.MailPassword.Length > 0)
                {
                    smtp2.Credentials    = new NetworkCredential(AppEnv.MailUsername, AppEnv.MailPassword);
                    smtp2.DeliveryMethod = SmtpDeliveryMethod.Network;
                }
                // if authentication end

                try
                {
                    smtp.Send(emailmess);

                    smtp2.Send(emailmess2);
                    notice.InnerHtml = "<br><br><br><font color=black><b>Đơn đặt hàng của bạn đã được gửi tới " + emailadd + ".Chúng tôi sẽ liên hệ với bạn trong thời gian ngắn nhất<br /><br />Xin chân thành cảm ơn!</b></font>";
                }
                catch (Exception z)
                {
                    notice.InnerHtml =
                        "<br><br><br><font color=black><b>Đơn đặt hàng của bạn đã được gửi đi..Chúng tôi sẽ liên hệ với bạn trong thời gian ngắn nhất<br /><br />Xin chân thành cảm ơn!</b></font><br>";
                }
                finally
                {
                    pnPayment.Visible = false;
                    notice.Visible    = true;
                    SessionUtility.Remove("cart");
                }
            }
            else
            {
                MessageBox.Show("Bạn cần phải đồng ý với điều khoản của My-Deal.vn");
            }
        }
예제 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            contentid = ConvertUtility.ToInt32(Request.QueryString["productid"]);

            string returnurl = ConvertUtility.ToString(Request.QueryString["returnurl"]);

            if (!string.IsNullOrEmpty(returnurl))
            {
                lnkReturn.NavigateUrl = returnurl;
            }
            else
            {
                lnkReturn.NavigateUrl = "/";
            }

            CommonLibrary.CartShopping.Cart cart = null;

            object obj = Session["cart"];

            if (obj == null)
            {
                cart            = new CommonLibrary.CartShopping.Cart();
                Session["cart"] = cart;
            }
            else
            {
                cart = (CommonLibrary.CartShopping.Cart)obj;
            }
            var justLogged = ConvertUtility.ToInt32(Request.QueryString["jl"]);

            if (justLogged == 0)
            {
                if (!Page.IsPostBack)
                {
                    //ViewState["urlreference"] = Request.UrlReferrer.AbsoluteUri;
                    if (contentid > 0)
                    {
                        var name = ConvertUtility.ToString(ContentDB.GetName(contentid));

                        /****************** project
                         * var mdInfo = MydealItemDB.GetInfo(contentid);
                         *
                         * if (mdInfo != null)
                         * {
                         *  var item = new CartItem();
                         *  item.Name = name;
                         *  item.Price = Convert.ToSingle(mdInfo.Mydeal_Price);
                         *  item.ID = contentid;
                         *  item.Quantity = 1;
                         *  cart.Items.Add(item);
                         * }
                         *
                         */
                    }
                }
            }
            pnPayment.Visible = false;
            notice.Visible    = true;

            if (CookieUtility.GetCookie("Member_Email") != null)
            {
                if (MemberDB.GetIDByEmail(CookieUtility.GetCookie("Member_Email")) != 0)
                {
                    MemberInfo info = MemberDB.GetInfoByEmail(CookieUtility.GetCookie("Member_Email"));
                    if (info != null)
                    {
                        pnPayment.Visible = true;
                        notice.Visible    = false;

                        txtFullName.Text = info.Member_Fullname;
                        txtTel.Text      = info.Member_Tel;
                        txtAddress.Text  = info.Member_Address;
                        txtDistrict.Text = info.Member_District;
                        txtCity.Text     = info.Member_City;
                    }
                }
            }
        }