示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (!IsPostBack)
            {
                hlBack.NavigateUrl = "Receive.aspx?active=" + Request.QueryString["active"];

                MojoCube.Web.Sql.DropDownListBind(ddlAccount, "Mail_Account", "AccountName", "pk_Account", null, "AccountName", "asc");

                if (Request.QueryString["id"] != null)
                {
                    ViewState["pk_Receive"] = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["id"]);

                    MojoCube.Web.Mail.Receive receive = new MojoCube.Web.Mail.Receive();
                    receive.GetData(int.Parse(ViewState["pk_Receive"].ToString()));

                    MojoCube.Web.Sql.ddlFindByValue(ddlAccount, receive.fk_Account.ToString());
                    txtNickName.Text = receive.NickName;
                    txtEmail.Text    = receive.Email;
                    txtContent.Text  = receive.Remark;

                    this.Title = "通知编辑:" + txtEmail.Text.Trim();
                }
                else
                {
                    this.Title = "通知编辑";
                }
            }
        }
    }
示例#2
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        MojoCube.Web.Mail.Receive receive = new MojoCube.Web.Mail.Receive();
        int index = 0;

        //删除
        if (e.CommandName == "_delete")
        {
            index = Convert.ToInt32(e.CommandArgument);
            receive.DeleteData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text));
        }
        GridBind();
    }
示例#3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtEmail.Text.Trim() == "" || txtNickName.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写接收邮件和昵称");
            return;
        }

        MojoCube.Web.Mail.Receive receive = new MojoCube.Web.Mail.Receive();

        //修改
        if (ViewState["pk_Receive"] != null)
        {
            receive.GetData(int.Parse(ViewState["pk_Receive"].ToString()));
            receive.fk_Account   = int.Parse(ddlAccount.SelectedValue);
            receive.NickName     = txtNickName.Text.Trim();
            receive.Email        = txtEmail.Text.Trim();
            receive.Remark       = txtContent.Text.Trim();
            receive.ModifyDate   = DateTime.Now.ToString();
            receive.ModifyUserID = int.Parse(Session["UserID"].ToString());
            receive.UpdateData(receive.pk_Receive);
        }
        //新增
        else
        {
            receive.fk_Account   = int.Parse(ddlAccount.SelectedValue);
            receive.NickName     = txtNickName.Text.Trim();
            receive.FirstName    = string.Empty;
            receive.LastName     = string.Empty;
            receive.Sex          = 0;
            receive.Email        = txtEmail.Text.Trim();
            receive.Power        = 0;
            receive.TypeID       = 0;
            receive.Remark       = txtContent.Text.Trim();
            receive.CreateDate   = DateTime.Now.ToString();
            receive.CreateUserID = int.Parse(Session["UserID"].ToString());
            receive.ModifyDate   = DateTime.Now.ToString();
            receive.ModifyUserID = 0;
            receive.InsertData();
        }

        AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
    }
    protected void btnOrder_Click(object sender, EventArgs e)
    {
        if (txtContactName.Text == "" || txtAddress.Text == "" || txtContactPhone.Text == "")
        {
            MojoCube.Api.UI.Script.ScriptMessage(this, "请填写完整收货信息");
            return;
        }

        #region  获取邮件信息

        //获取发送邮件账号
        MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
        account.GetDataTypeID(2);
        //获取邮件模板
        MojoCube.Web.Mail.Template template = new MojoCube.Web.Mail.Template();
        template.GetDataAccountID(account.pk_Account);
        string mailbody     = template.Description;
        string templateInfo = string.Empty;
        //获取替代方法
        MojoCube.Web.ReplaceText replace = new MojoCube.Web.ReplaceText();
        string repeatText = replace.GetRepeat("<tr class=\"repeat\">", "</tr>", template.Description);

        #endregion

        #region  加入订单列表

        MojoCube.Web.Order.List list = new MojoCube.Web.Order.List();
        list.fk_Member       = int.Parse(Session["Member_UserID"].ToString());
        list.fk_Express      = 0;
        list.OrderNumber     = MojoCube.Api.Text.Function.DateTimeString(true);
        list.TrackingNumber  = string.Empty;
        list.CustomerName    = txtContactName.Text.Trim();
        list.CustomerSex     = 0;
        list.CustomerPhone1  = txtContactPhone.Text.Trim();
        list.CustomerPhone2  = string.Empty;
        list.CustomerQQ      = string.Empty;
        list.CustomerEmail   = ViewState["Email"].ToString();
        list.CustomerZip     = string.Empty;
        list.CustomerAddress = txtAddress.Text.Trim();
        list.Description     = string.Empty;
        list.Remark          = txtRemark.Text.Trim();
        list.Note            = string.Empty;
        list.TypeID          = 0;
        list.Freight         = 0;
        list.Premium         = 0;
        list.Amount          = (decimal)ViewState["Total"];
        list.Currency        = 0;
        list.CreateDate      = DateTime.Now.ToString();
        list.EndDate         = DateTime.Now.ToString();
        list.fk_Payment      = 0;
        list.PaymentDate     = DateTime.Now.ToString();
        list.ShipmentDate    = DateTime.Now.ToString();
        list.ShipperCode     = string.Empty;
        list.LogisticCode    = string.Empty;
        list.LogisticInfo    = string.Empty;
        list.LastCheck       = DateTime.Now.ToString();
        list.CancelDate      = DateTime.Now.ToString();
        list.IsPublic        = false;
        list.IsAssess        = false;
        list.IsComment       = false;
        list.Comments        = string.Empty;
        list.StatusID        = 0;
        list.IsDeleted       = false;
        int orderId = list.InsertData();

        #endregion

        #region  加入订单产品

        MojoCube.Web.Order.Item item = new MojoCube.Web.Order.Item();
        item.fk_Order = orderId;

        string productList = string.Empty;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            item.fk_ID      = int.Parse(((Label)GridView1.Rows[i].FindControl("lblfkID")).Text);
            item.fk_Price   = 0;
            item.TypeID     = 0;
            item.Title      = ((Label)GridView1.Rows[i].FindControl("lblProductName")).Text;
            item.ImagePath  = ((Label)GridView1.Rows[i].FindControl("lblImagePath")).Text;
            item.PageName   = ((Label)GridView1.Rows[i].FindControl("lblPageName")).Text;
            item.Price      = decimal.Parse(((Label)GridView1.Rows[i].FindControl("lblPrice")).Text);
            item.Amount     = decimal.Parse(((Label)GridView1.Rows[i].FindControl("lblAmount")).Text);
            item.Currency   = 0;
            item.Qty        = int.Parse(((TextBox)GridView1.Rows[i].FindControl("txtQty")).Text.Trim());
            item.Remark     = string.Empty;
            item.StatusID   = 0;
            item.CreateDate = DateTime.Now.ToString();
            item.InsertData();

            //邮件替换内容
            replace.ProductName = ((Label)GridView1.Rows[i].FindControl("lblProductName")).Text;
            replace.Price       = ((Label)GridView1.Rows[i].FindControl("lblPrice")).Text;
            replace.Qty         = ((TextBox)GridView1.Rows[i].FindControl("txtQty")).Text.Trim();
            replace.Amount      = ((Label)GridView1.Rows[i].FindControl("lblAmount")).Text;
            templateInfo       += replace.Replace(repeatText);

            //产品名称组合
            productList += ((Label)GridView1.Rows[i].FindControl("lblProductName")).Text + "×" + item.Qty.ToString() + ",";
        }

        if (productList.Length > 1)
        {
            productList = productList.Substring(0, productList.Length - 1);

            list.Description = productList;
            list.UpdateData(orderId);
        }

        #endregion

        #region  发送通知信息

        mailbody         = mailbody.Replace(repeatText, templateInfo);
        replace.TrueName = list.CustomerName;
        replace.Total    = ViewState["Total"].ToString();
        mailbody         = replace.Replace(mailbody);

        MojoCube.Web.Mail.Receive receive = new MojoCube.Web.Mail.Receive();
        string mailList = receive.GetEmailList(account.pk_Account);

        if (account.SmtpPort == 25)
        {
            MojoCube.Api.Mail.Thread mail = new MojoCube.Api.Mail.Thread();
            mail.From        = account.LoginName;
            mail.DisplayName = account.DisplayName;
            //给买家发送邮件
            mail.To = list.CustomerEmail;
            //CC给系统需要通知的人员
            if (mailList != "")
            {
                mail.CC = mailList;
            }
            mail.Subject   = template.Subject;
            mail.Body      = mailbody;
            mail.SmtpHost  = account.SmtpHost;
            mail.Port      = account.SmtpPort;
            mail.EnableSsl = false;
            mail.UserName  = account.LoginName;
            mail.Password  = MojoCube.Api.Text.Security.DecryptString(account.Password);
            mail.Send();
        }
        else
        {
            MojoCube.Api.Mail.WebMail mail = new MojoCube.Api.Mail.WebMail();
            mail.From        = account.LoginName;
            mail.DisplayName = account.DisplayName;
            //给买家发送邮件
            mail.To = list.CustomerEmail;
            //CC给系统需要通知的人员
            if (mailList != "")
            {
                mail.CC = mailList;
            }
            mail.Subject   = template.Subject;
            mail.Body      = mailbody;
            mail.SmtpHost  = account.SmtpHost;
            mail.Port      = account.SmtpPort;
            mail.EnableSsl = true;
            mail.UserName  = account.LoginName;
            mail.Password  = MojoCube.Api.Text.Security.DecryptString(account.Password);
            mail.Send();
        }

        //发送短信通知
        //MojoCube.Web.SMS.Function.Send(0, 1, orderId);

        #endregion

        #region   单成功重置

        MojoCube.Web.Sql.SqlQuery("update Member_Cart set StatusID=1 where fk_Member=" + Session["Member_UserID"].ToString() + " and StatusID=0 and pk_Cart in (" + Session["CartToOrder"].ToString() + ")");
        Session.Remove("CartToOrder");

        #endregion

        Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Pay", MojoCube.Api.UI.Language.GetLanguage()) + "?id=" + MojoCube.Api.Text.Security.EncryptString(orderId.ToString()));
    }