Ejemplo n.º 1
0
    /// <summary>
    /// 处理消息
    /// </summary>
    /// <param name="nID"></param>
    /// <returns></returns>
    public bool updateDo(string nID)
    {
        string sql = "update ML_NewsClassMain  set sid2=1 where nID=" + nID;


        string    sqlto = @"select c.tTitle,c.tMemo,b.tRealName,b.MemberPhone
                        from ML_NewsClassMain a
                        inner join  ML_Member b
                        on a.sid1=b.nID
                        inner join ML_News c 
                        on a.sid0=c.nID where a.nID=" + nID;
        DataTable dt    = her.ExecuteDataTable(sqlto);

        if (dt.Rows.Count > 0)
        {
            if (AjaxAlert.SendMsg(dt.Rows[0]["tTitle"].ToString(), dt.Rows[0]["tMemo"].ToString(), dt.Rows[0]["tRealName"].ToString(), dt.Rows[0]["MemberPhone"].ToString()))
            {
                return(her.ExecuteNonQuery(sql));
            }
            else
            {
                return(false);
            }
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 发送给全部用户
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSendAll_Click(object sender, EventArgs e)
    {
        string    sql = string.Format(@"select * from dbo.ML_Member a 
                                           left join
                                           (
                                             select * from ML_NewsClassMain 
                                             where sid0={0}
                                           ) b
                                           on a.nID=b.sid1
                                           where b.sid1 is null", _ID);
        DataTable dt  = her.ExecuteDataTable(sql);

        if (dt.Rows.Count > 0)
        {
            U_ShowDivPic(this.Page, "正在导入中…");
            foreach (DataRow dr in dt.Rows)
            {
                XueYuan_Add(dr["nID"].ToString());
            }

            GridBind();
            Pagination1.Refresh();

            this.Page.Response.Write("<script language=javascript>;HideWait();</script>");
        }
        else
        {
            AjaxAlert.AlertMsgAndNoFlush(this, "无未发送学员");
            //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('无未发送学员')</script>");
        }
    }
Ejemplo n.º 3
0
 protected void gridField_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "del")
     {
         bool success = news.updateDo(e.CommandArgument.ToString());
         if (success)
         {
             AjaxAlert.AlertMsgAndNoFlush(this, "发送成功");
             GridBind();
             Pagination2.Refresh();
         }
         else
         {
             AjaxAlert.AlertMsgAndNoFlush(this, "发送失败");
         }
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 选中发送
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void imgdelete_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < gridField.Rows.Count; i++)
     {
         CheckBox ckb = (CheckBox)gridField.Rows[i].FindControl("CheckSel");
         if (ckb.Checked)
         {
             bool success = XueYuan_Add(gridField.DataKeys[i].Value.ToString());
             //if (!success)
             //{
             //    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('发生未知错误!请重试')</script>");
             //}
             //else
             //{
             //    ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('添加成功')</script>");
             //}
         }
     }
     GridBind();
     Pagination1.Refresh();
     AjaxAlert.AlertMsgAndNoFlush(this, "发送成功");
     //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('发送成功')</script>");
 }
Ejemplo n.º 5
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        //确保已经选择了待导入的文件,首先上传,然后在服务器端完成导入
        if (this.fuOpen.PostedFile.FileName != "")
        {
            //确保文件是excel格式
            //Response.Write(this.fuOpen.FileName.Substring(this.fuOpen.FileName.LastIndexOf('.')));
            if (this.fuOpen.FileName.Substring(this.fuOpen.FileName.LastIndexOf('.') + 1) == "xls")
            {
                Random rd = new Random(1);

                string filename = DateTime.Now.Date.ToString("yyyymmdd") + DateTime.Now.ToLongTimeString().Replace(":", "") + rd.Next(9999).ToString() + ".xls";


                try
                {
                    this.fuOpen.PostedFile.SaveAs(@Server.MapPath("../Upload/file/") + filename);
                }
                catch (HttpException he)
                {
                    Response.Write("文件上传不成功,请检查文件是否过大,是否有写权限!");
                    return;
                }
                #region --------读取文件内容到服务器内存----------
                string          conn           = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source =" + Server.MapPath("../Upload/file") + "/" + filename + ";Extended Properties=Excel 8.0";
                OleDbConnection thisconnection = new OleDbConnection(conn);
                thisconnection.Open();
                //要保证字段名和excel表中的字段名相同
                string           Sql       = @"select 姓名,学校,年级,班级,联系电话,家长姓名,备注,缴费金额 from [Sheet1$]";
                OleDbDataAdapter mycommand = new OleDbDataAdapter(Sql, thisconnection);
                DataSet          ds        = new DataSet();
                mycommand.Fill(ds, "[Sheet1$]");
                thisconnection.Close();

                #endregion


                allCount = ds.Tables[0].Rows.Count;
                U_ShowDivPic(this.Page, "正在导入中…");
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    string exception = "";
                    if (string.IsNullOrEmpty(dr["联系电话"].ToString()))
                    {
                        missCount++;
                    }
                    else
                    {
                        // string sql = "select count(*) from ML_Member where MemberPhone=" + dr["手机号码"].ToString();
                        // if (hp.ExecuteScalar(sql) != null && Convert.ToInt32(hp.ExecuteScalar(sql)) > 0)//已经注册的用户不需要再添
                        if (Member.Verification(dr["联系电话"].ToString()))
                        {
                            exception = "该号码已被注册";
                            missCount++;
                            continue;
                        }
                        else
                        {
                            //导入用户
                            InsertPerson(dr, out exception);//exception可以考虑写入日志
                        }
                    }
                }

                this.Page.Response.Write("<script language=javascript>;HideWait();</script>");
                //ClientScript.RegisterStartupScript(GetType(), "", string.Format("<script>alert('总共{0}条数据,成功{1},失败{2},过滤{3}')</script>", allCount, successCount, errorCount, missCount));
                //Response.Redirect("Member_Main.aspx");

                string alert = string.Format("总共{0}条数据,成功{1},失败{2},过滤{3}", allCount, successCount, errorCount, missCount);
                AjaxAlert.AlertAndRedirect(this, alert, "Member_Main.aspx");
            }
            else
            {
                AjaxAlert.AlertMsgAndNoFlush(this, "导入文件的格式不正确!");
                // ClientScript.RegisterStartupScript(GetType(), "", "导入文件的格式不正确!");
            }
        }
        else
        {
            AjaxAlert.AlertMsgAndNoFlush(this, "您还没有选择要导入的文件!");
            // ClientScript.RegisterStartupScript(GetType(), "", "您还没有选择要导入的文件!");
        }
    }