Exemplo n.º 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hlBack.NavigateUrl = "Account.aspx?active=" + Request.QueryString["active"];

            MojoCube.Web.Sql.DropDownListBind(ddlType, "Sys_TypeID", "TypeName_CHS", "ID", "TableName='Mail_Account'", "ID", "asc");

            MojoCube.Web.Sql.DropDownListBind(ddlStatus, "Sys_StatusID", "StatusName_CHS", "ID", "TableName='Mail_Account'", "ID", "asc");

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

                MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
                account.GetData(int.Parse(ViewState["pk_Account"].ToString()));

                MojoCube.Web.Sql.ddlFindByValue(ddlType, account.TypeID.ToString());
                MojoCube.Web.Sql.ddlFindByValue(ddlStatus, account.StatusID.ToString());
                txtAccountName.Text = account.AccountName;
                txtDisplayName.Text = account.DisplayName;
                txtSmtpHost.Text    = account.SmtpHost;
                txtSmtpPort.Text    = account.SmtpPort.ToString();
                txtLoginName.Text   = account.LoginName;
                txtPassword.Attributes.Add("value", MojoCube.Api.Text.Security.DecryptString(account.Password));
                txtNote.Text = account.Remark;

                this.Title = "账号编辑:" + txtAccountName.Text.Trim();
            }
            else
            {
                this.Title = "账号编辑";
            }
        }
    }
Exemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtAccountName.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写名称");
            return;
        }

        MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();

        //修改
        if (ViewState["pk_Account"] != null)
        {
            account.GetData(int.Parse(ViewState["pk_Account"].ToString()));

            account.TypeID       = int.Parse(ddlType.SelectedValue);
            account.StatusID     = int.Parse(ddlStatus.SelectedValue);
            account.AccountName  = txtAccountName.Text.Trim();
            account.DisplayName  = txtDisplayName.Text.Trim();
            account.SmtpHost     = txtSmtpHost.Text.Trim();
            account.SmtpPort     = MojoCube.Web.String.ToInt(txtSmtpPort.Text.Trim());
            account.LoginName    = txtLoginName.Text.Trim();
            account.Password     = MojoCube.Api.Text.Security.EncryptString(txtPassword.Text.Trim());
            account.SmtpPwd      = MojoCube.Api.Text.Security.EncryptString(txtPassword.Text.Trim());
            account.SmtpUser     = txtLoginName.Text.Trim();
            account.Remark       = txtNote.Text.Trim();
            account.ModifyUserID = int.Parse(Session["UserID"].ToString());
            account.ModifyDate   = DateTime.Now.ToString();
            account.UpdateData(account.pk_Account);
        }
        //新增
        else
        {
            account.TypeID       = int.Parse(ddlType.SelectedValue);
            account.StatusID     = int.Parse(ddlStatus.SelectedValue);
            account.AccountName  = txtAccountName.Text.Trim();
            account.DisplayName  = txtDisplayName.Text.Trim();
            account.PopHost      = string.Empty;
            account.Port         = 110;
            account.UseSSL       = false;
            account.SmtpHost     = txtSmtpHost.Text.Trim();
            account.SmtpPort     = MojoCube.Web.String.ToInt(txtSmtpPort.Text.Trim());
            account.LoginName    = txtLoginName.Text.Trim();
            account.Password     = MojoCube.Api.Text.Security.EncryptString(txtPassword.Text.Trim());
            account.SmtpPwd      = MojoCube.Api.Text.Security.EncryptString(txtPassword.Text.Trim());
            account.SmtpUser     = txtLoginName.Text.Trim();
            account.SmtpUseSSL   = false;
            account.Signature    = string.Empty;
            account.Remark       = txtNote.Text.Trim();
            account.CreateUserID = int.Parse(Session["UserID"].ToString());
            account.CreateDate   = DateTime.Now.ToString();
            account.ModifyUserID = 0;
            account.ModifyDate   = DateTime.Now.ToString();
            account.InsertData();
        }

        Response.Redirect("Account.aspx?active=" + Request.QueryString["active"]);
    }
Exemplo n.º 3
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
        int index = 0;

        //删除
        if (e.CommandName == "_delete")
        {
            index = Convert.ToInt32(e.CommandArgument);
            account.DeleteData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text));
        }
        GridBind();
    }
Exemplo n.º 4
0
    //发送邮件
    private bool SendMail(string mailto, string firstName, string lastName, string userName)
    {
        MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
        account.GetDataTypeID(3);

        bool isSend = false;

        if (account.SmtpPort == 25)
        {
            MojoCube.Api.Mail.Thread mail = new MojoCube.Api.Mail.Thread();
            mail.From        = account.LoginName;
            mail.DisplayName = account.DisplayName;
            mail.To          = mailto;
            mail.Subject     = txtTitle.Text.Trim();
            mail.Body        = ReplaceMailBody(txtDescription.Text.Trim(), firstName, lastName, userName);
            mail.SmtpHost    = account.SmtpHost;
            mail.Port        = account.SmtpPort;
            mail.EnableSsl   = false;
            mail.UserName    = account.LoginName;
            mail.Password    = MojoCube.Api.Text.Security.DecryptString(account.Password);
            isSend           = mail.Send();
        }
        else
        {
            MojoCube.Api.Mail.WebMail mail = new MojoCube.Api.Mail.WebMail();
            mail.From        = account.LoginName;
            mail.DisplayName = account.DisplayName;
            mail.To          = mailto;
            mail.Subject     = txtTitle.Text.Trim();
            mail.Body        = ReplaceMailBody(txtDescription.Text.Trim(), firstName, lastName, userName);
            mail.SmtpHost    = account.SmtpHost;
            mail.Port        = account.SmtpPort;
            mail.EnableSsl   = true;
            mail.UserName    = account.LoginName;
            mail.Password    = MojoCube.Api.Text.Security.DecryptString(account.Password);
            isSend           = mail.Send();
        }

        return(isSend);
    }
Exemplo n.º 5
0
    //发送邮件
    private void SendMail(string mailto, string firstName, string lastName, string userName, string password)
    {
        MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
        account.GetDataTypeID(1);

        MojoCube.Web.Mail.Template template = new MojoCube.Web.Mail.Template();
        template.GetDataAccountID(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          = mailto;
            mail.Subject     = template.Subject;
            mail.Body        = ReplaceMailBody(template.Description, firstName, lastName, userName, password);
            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          = mailto;
            mail.Subject     = template.Subject;
            mail.Body        = ReplaceMailBody(template.Description, firstName, lastName, userName, password);
            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();
        }
    }
Exemplo n.º 6
0
 private string GetAccountName(string id)
 {
     MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
     account.GetData(int.Parse(id));
     return(account.AccountName);
 }
Exemplo n.º 7
0
    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()));
    }
Exemplo n.º 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hlBack.NavigateUrl = "Mail.aspx?active=" + Request.QueryString["active"];

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

                MojoCube.Web.Member.Mail mail = new MojoCube.Web.Member.Mail();
                mail.GetData(int.Parse(ViewState["pk_Mail"].ToString()));

                txtTitle.Text       = mail.Subject;
                txtDescription.Text = mail.Contents;

                MojoCube.Web.Member.List user = new MojoCube.Web.Member.List();
                user.GetData(mail.fk_Member);

                cblReceive.Items.Add(new ListItem("&nbsp;" + user.UserName, user.pk_Member.ToString()));
                cblReceive.Items[0].Selected = true;
                cblReceive.Items[0].Enabled  = false;

                this.Title = "邮件编辑:" + txtTitle.Text.Trim();
            }
            else
            {
                if (Request.QueryString["uid"] != null)
                {
                    string uid = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["uid"]);

                    DataTable dt = MojoCube.Web.Sql.SqlQueryDS("select * from Member_List where IsLock=0 and IsCheck=1 and pk_Member in (" + uid + ")").Tables[0];
                    cblReceive.DataSource = dt;
                    cblReceive.DataBind();
                    if (dt.Rows.Count > 0)
                    {
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            cblReceive.Items[i].Text     = dt.Rows[i]["UserName"].ToString();
                            cblReceive.Items[i].Value    = dt.Rows[i]["pk_Member"].ToString();
                            cblReceive.Items[i].Selected = true;
                        }
                    }
                }
                else
                {
                    cblReceive.Items.Add(new ListItem("&nbsp;所有会员", "0"));
                    cblReceive.Items[0].Selected = true;
                    cblReceive.Items[0].Enabled  = false;
                }

                MojoCube.Web.Mail.Account account = new MojoCube.Web.Mail.Account();
                account.GetDataTypeID(3);

                MojoCube.Web.Mail.Template template = new MojoCube.Web.Mail.Template();
                template.GetDataAccountID(account.pk_Account);
                txtTitle.Text       = template.Subject;
                txtDescription.Text = template.Description;

                this.Title = "邮件编辑";
            }
        }
    }