public void btnSend_OnClick(object sender, EventArgs e)
        {
            foreach (DataGridItem dgi in this.dg.Items)
            {
                CheckBox chkIsSend = dgi.FindControl("chkIsSend") as CheckBox;
                if (chkIsSend.Checked)
                {
                    TempEmail tempEmail = new TempEmail();
                    tempEmail.TempEmailName = dgi.Cells[3].Text;

                    if (!UserAdmin.TempEmailCreateDeleteUpdate(tempEmail, UserAction.Create))
                    {
                        StringHelper.AlertInfo("发送邮件插入失败", this.Page);
                    }
                }
            }
            this.Response.Redirect("UserInfoAdmin.aspx");
        }
        /// <summary>
        /// EMAIL临时发送表 添加,删除,更新
        /// </summary>
        /// <param name="tempEmail"></param>
        /// <returns></returns>
        public bool TempEmailCreateDeleteUpdate(TempEmail tempEmail,UserAction ua)
        {
            bool result = false;
            string commandText = string.Empty;
            switch (ua)
            {
                case UserAction.Create:
                    commandText = "insert into TempEmail(TempEmailName,TempEmailIsSend,TempEmailCreateTime) values('"+tempEmail.TempEmailName+"',"+tempEmail.TempEmailIsSend.CompareTo(false).ToString()+",'"+tempEmail.TempEmailCreateTime.ToString()+"')";
                    break;
                case UserAction.Delete:
                    commandText = "delete from TempEmail where TempEmailID ="+tempEmail.TempEmailID.ToString();
                    break;
                case UserAction.Update:
                    commandText = "update TempEmail set TempEmailName='"+tempEmail.TempEmailName+"',TempEmailIsSend='"+tempEmail.TempEmailIsSend.CompareTo(false).ToString()+"',TempEmailCreateTime'"+tempEmail.TempEmailCreateTime.ToString()+"' where TempEmailID="+tempEmail.TempEmailID.ToString();
                    break;
            }
            using (SqlConnection conn = new SqlConnection(DataHelper2.SqlConnectionString))
            {
                using (SqlCommand comm = new SqlCommand())
                {
                    comm.CommandText = commandText;
                    comm.Connection = conn;
                    conn.Open();
                    try
                    {
                        comm.ExecuteNonQuery();
                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw new Exception(ex.Message);
                    }

                }
            }
            return result;
        }
Exemple #3
0
 /// <summary>
 /// 发送EMAIL临时存放表
 /// </summary>
 /// <param name="tempEmail"></param>
 /// <returns></returns>
 public static bool TempEmailCreateDeleteUpdate(TempEmail tempEmail,UserAction ua)
 {
     return ProviderFactory.GetUserDataProviderInstance().TempEmailCreateDeleteUpdate(tempEmail, ua);
 }