Exemplo n.º 1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "InitPwd")
        {
            //  InitPwd
            string Xh = e.CommandArgument.ToString().Trim();
            ;
            MembershipUser user = Membership.GetUser(Xh);
            if (user == null)
            {
                user = Membership.CreateUser(Xh, Xh);
            }

            if (!Roles.IsUserInRole(Xh, "Students"))
            {
                Roles.AddUserToRole(Xh, "Students");
            }
            if (user.IsLockedOut)
            {
                user.UnlockUser();
            }
            string pwd = user.ResetPassword();
            if (user.ChangePassword(pwd, Xh))
            {
                //      Response.Write("<script language='javascript'>alert('初始化密码为用户名成功!');</script>");

                //       DataBinder();
                //LogUtil.Add(
                //    String.Format("事件:用户{0}成功初始化了学生{1}的密码", Page.User.Identity.Name, user.UserName)
                //    );
                JsUtil.MessageBox(this, "初始化密码为用户名成功!");
            }
            else
            {
                //       Response.Write("<script language='javascript'>alert('初始化密码为用户名失败!');</script>");
                //LogUtil.Add(
                //    String.Format("事件:用户{0}初始化了学生{1}的密码失败", Page.User.Identity.Name, user.UserName)
                //    );
                JsUtil.MessageBox(this, "初始化密码为用户名失败!");
            }

            this.BindData();
        }
    }
Exemplo n.º 2
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        if (!fileUpload.HasFile)
        {
            JsUtil.MessageBox(this, "请选择指定格式的Excel文件,或json格式文本文件");
            return;
        }
        if (fileUpload.FileContent.Length == 0)
        {
            JsUtil.MessageBox(this, "文件的内容为空");
            return;
        }
        string fileExt = Path.GetExtension(fileUpload.FileName);

        fileExt = fileExt.ToLower();
        string[] fileExtAllow = new[] { ".xls;", ".xlsx", ".txt" };
        if (!fileExtAllow.Contains(fileExt))
        {
            JsUtil.MessageBox(this, "只能上传指定格式文件");
            return;
        }
        string filepath = Path.Combine(Server.MapPath("~/tmp/"), System.DateTime.Now.ToString("yyyyMMdd") + fileExt);

        try
        {
            fileUpload.SaveAs(filepath);
            if (fileExt == ".txt")
            {
                string strContent = File.ReadAllText(filepath);
                ImportFromJson(strContent);
            }
            else
            {
                ImportFromExcel(filepath);
            }
            this.Succeed();
        }
        catch (Exception ex)
        {
            Fail(ex.Message);
        }
    }
Exemplo n.º 3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.CurBmk != null)
        {
            if (this.ddlZy11.SelectedIndex > 0)
            {
                this.CurBmk.zy11 = this.ddlZy11.SelectedValue;
            }
            else
            {
                this.CurBmk.zy11 = string.Empty;
            }

            if (this.ddlZy12.SelectedIndex > 0)
            {
                this.CurBmk.zy12 = this.ddlZy12.SelectedValue;
            }
            else
            {
                this.CurBmk.zy12 = string.Empty;
            }

            if (this.ddlZy21.SelectedIndex > 0)
            {
                this.CurBmk.zy21 = this.ddlZy21.SelectedValue;
            }
            else
            {
                this.CurBmk.zy21 = string.Empty;
            }

            if (this.ddlZy22.SelectedIndex > 0)
            {
                this.CurBmk.zy22 = this.ddlZy22.SelectedValue;
            }
            else
            {
                this.CurBmk.zy22 = string.Empty;
            }

            if (this.ddlZy31.SelectedIndex > 0)
            {
                this.CurBmk.zy31 = this.ddlZy31.SelectedValue;
            }
            else
            {
                this.CurBmk.zy31 = string.Empty;
            }

            if (this.ddlZy32.SelectedIndex > 0)
            {
                this.CurBmk.zy32 = this.ddlZy32.SelectedValue;
            }
            else
            {
                this.CurBmk.zy32 = string.Empty;
            }

            if (this.ddlZy33.SelectedIndex > 0)
            {
                this.CurBmk.zy33 = this.ddlZy33.SelectedValue;
            }
            else
            {
                this.CurBmk.zy33 = string.Empty;
            }

            if (this.rblJb.SelectedIndex >= 0)
            {
                this.CurBmk.jb = this.rblJb.SelectedValue;
            }
            else
            {
                this.CurBmk.jb = "0";
            }

            if (this.rblFc.SelectedIndex >= 0)
            {
                this.CurBmk.fc = this.rblFc.SelectedValue;
            }
            else
            {
                this.CurBmk.fc = "0";
            }
            this.CurBmk.bz5 = txtBeizhu5.Text;
            this.CurBmk.Save();
            BindData();

            JsUtil.MessageBox(this, "数据保存成功!");
        }
    }
Exemplo n.º 4
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        StringBuilder errMsg = new StringBuilder();

        if (this.CurBmk != null)
        {
            string oldBmkJson = this.CurBmk.Json();
            this.CurBmk.bj = this.txtBj.Text.Trim();
            this.CurBmk.xh = this.txtBnbh.Text.Trim();
            if (IDCardChecker.CheckIDCard(this.txtsfzh.Text) && this.txtsfzh.Text != null)
            {
                if (this.txtsfzh.Text.Substring(6, 8) != this.txtCsny.Text)
                {
                    errMsg.Append("身份证号码中的出生年月日与你所填写的出生年月日不一致!");
                }
                string sexIDCard = this.txtsfzh.Text.Substring(16, 1);
                if ("02468Xx".Contains(sexIDCard) && (this.ddlSex.SelectedValue != "2"))
                {
                    errMsg.Append("身份证号码与所选性别不一致!");
                }
                else if ("13579".Contains(sexIDCard) && (this.ddlSex.SelectedValue != "1"))
                {
                    errMsg.Append("身份证号码与所选性别不一致!");
                }
                this.CurBmk.sfzh = this.txtsfzh.Text.Trim();
            }
            else
            {
                this.CurBmk.sfzh = this.txtsfzh.Text.Trim();//身份证错误也允许录入
                errMsg.Append("身份证号码已经保存但有错误!");
            }
            this.CurBmk.xstbh = this.txtXstbh.Text.Trim();
            this.CurBmk.xm    = this.txtXm.Text.Trim();
            this.CurBmk.Bm    = this.txtBm.Text.Trim();
            if (this.ddlSex.SelectedIndex > 0)
            {
                this.CurBmk.xb = this.ddlSex.SelectedValue;
            }
            else
            {
                errMsg.Append("性别没选择,");
            }

            if (Bmk.ValidateCsny(this.txtCsny.Text))
            {
                this.CurBmk.csny = this.txtCsny.Text.Trim();
            }
            else
            {
                errMsg.Append("出生年月日有误!必须是8位数字(如:19910805),");
            }

            if (this.ddlTy.SelectedIndex > 0)
            {
                this.CurBmk.ty = this.ddlTy.SelectedValue;//团员
            }
            else
            {
                errMsg.Append("是否团员未选择,");
            }

            if (this.ddlMz.SelectedIndex > 0)
            {
                this.CurBmk.mz = this.ddlMz.SelectedValue;//民族
            }
            else
            {
                errMsg.Append("民族未选择,");
            }

            if (this.ddlKslb.SelectedIndex > 0)
            {
                this.CurBmk.kslb = this.ddlKslb.SelectedValue;//考生类别
            }
            else
            {
                errMsg.Append("考生类别未选择,");
            }

            if (this.ddlHk.SelectedIndex > 0)
            {
                this.CurBmk.hk = this.ddlHk.SelectedValue;
            }
            else
            {
                errMsg.Append("户口未选择,");
            }

            if (this.txtTel.Text.IsNullOrEmpty())
            {
                errMsg.Append("联系电话未填写,");
            }
            else
            {
                this.CurBmk.tel = this.txtTel.Text.Trim();
            }

            if (this.txtJtzz.Text.IsNullOrEmpty())
            {
                errMsg.Append("家庭地址未填写,");
            }
            else
            {
                this.CurBmk.jtzz = this.txtJtzz.Text.Trim();
            }

            if (this.txtPost.Text.IsNullOrEmpty())
            {
                errMsg.Append("邮政编码未填写,");
            }
            else
            {
                this.CurBmk.post = this.txtPost.Text.Trim();
            }


            if (this.ddlSyqk.SelectedIndex > 0)
            {
                this.CurBmk.syqk = this.ddlSyqk.SelectedValue;
            }
            else
            {
                errMsg.Append("生源情况未选择,");
            }
            if (this.ddlHk.SelectedValue == "25" && this.ddlSyqk.SelectedValue != "0")
            {
                errMsg.Append("鹿城户籍学生只能选0,");
            }
            else if (this.ddlHk.SelectedValue != "25" && this.ddlSyqk.SelectedValue == "0")
            {
                errMsg.Append("非鹿城户籍学生只能选1或7,1表现在鹿城报考,7表示回原籍报考,报考幼师的同学只能回原籍报考,");
            }
            else if ("89".Contains(this.ddlSyqk.SelectedValue))
            {
                errMsg.Append("我们不能选择8或9,");
            }

            this.CurBmk.czhj = this.txtCzhj.Text.Trim();
            this.CurBmk.xqah = this.txtXqah.Text.Trim();

            this.CurBmk.father    = this.txtFather.Text.Trim();
            this.CurBmk.fatherdw  = this.txtFatherdw.Text.Trim();
            this.CurBmk.fatherzw  = this.txtFatherzw.Text.Trim();
            this.CurBmk.fathertel = this.txtFathertel.Text.Trim();
            this.CurBmk.mother    = this.txtMother.Text.Trim();
            this.CurBmk.motherdw  = this.txtMotherdw.Text.Trim();
            this.CurBmk.motherzw  = this.txtMotherzw.Text.Trim();
            this.CurBmk.mothertel = this.txtMothertel.Text.Trim();

            this.CurBmk.bz1 = this.txtBeizhu1.Text.Trim();
            this.CurBmk.bz2 = this.txtBeizhu2.Text.Trim();
            this.CurBmk.bz3 = this.txtBeizhu3.Text.Trim();
            this.CurBmk.bz4 = this.txtBeizhu4.Text.Trim();
            this.CurBmk.bz5 = this.txtBeizhu5.Text.Trim();
            this.CurBmk.bz6 = this.txtBeizhu6.Text.Trim();

            this.CurBmk.Bm = this.txtBm.Text.Trim();//别名

            //体测项目

            if (this.ddlTcxm1.SelectedIndex > 0 && this.ddlTcxm2.SelectedIndex > 0)
            {
                char tcxm1 = this.ddlTcxm1.SelectedValue[0];
                char tcxm2 = this.ddlTcxm2.SelectedValue[0];
                if (tcxm1 == tcxm2)
                {
                    errMsg.Append("体育两项选考必须不一样,");
                }
                else
                {
                    if (tcxm1 > tcxm2)
                    {
                        char temp = tcxm1;
                        tcxm1 = tcxm2;
                        tcxm2 = temp;
                    }
                    this.CurBmk.tcxm = tcxm1.ToString() + tcxm2.ToString();
                }
            }
            else
            {
                this.CurBmk.tcxm = "";
            }

            string byxxdm = this.txtByxxdm.Text;
            if (byxxdm.IsNullOrEmpty())
            {
                errMsg.Append("毕业学校代码未填写,");
            }
            else
            {
                string    dbfPath  = Server.MapPath("~/Data/Dbf/sysdbf/");
                string    dbfTable = "schools.DBF";
                DataTable dt       = DbfHelper.ToDataTable(dbfPath, dbfTable);
                var       rows     = dt.Select(string.Format("school = '{0}'", byxxdm));
                if (rows.Length == 1)
                {
                    this.CurBmk.byxxmc = rows[0]["mc"].ToString();
                    this.CurBmk.byxxdm = byxxdm;
                }
                else
                {
                    errMsg.Append("你所填写的就读学校代码有误");
                }
            }

            string newBmkJson = this.CurBmk.Json();
            if (newBmkJson == oldBmkJson)
            {
                JsUtil.MessageBox(this, "您没有改动任何数据!提示:" + errMsg.ToString());
            }
            else
            {
                ValidateHandler vh = new ValidateHandler(true);
                if (vh.ValidateObject(this.CurBmk))
                {
                    if (this.CurBmk.RecordGuid == Guid.Empty.ToString())
                    {
                        this.CurBmk.RecordGuid = Guid.NewGuid().ToString();
                    }
                    if (this.CurBmk.CurHistoryGuid == Guid.Empty.ToString())
                    {
                        this.CurBmk.CurHistoryGuid = Guid.NewGuid().ToString();
                    }
                    else
                    {
                        this.CurBmk.PreHistoryGuid = this.CurBmk.CurHistoryGuid;
                        this.CurBmk.CurHistoryGuid = Guid.NewGuid().ToString();
                    }
                    this.CurBmk.Save();
                    this.Save2File(this.CurBmk);
                    JsUtil.MessageBox(this, "数据保存成功!提示:" + errMsg.ToString());

                    BindData();
                }
                else
                {
                    JsUtil.MessageBox(this, "数据保存失败!提示:" + vh.ErrorMessages + errMsg.ToString());
                }
            }
        }
        else
        {
            throw new Exception("学生信息不存在!");
        }
    }
Exemplo n.º 5
0
 /// <summary>
 /// 显示信息框
 /// </summary>
 /// <param name="msg"></param>
 protected void MessageBox(string msg)
 {
     JsUtil.MessageBox(this, msg);
 }
Exemplo n.º 6
0
    /// <summary>
    /// 从excel文件导入
    /// </summary>
    /// <param name="filepath"></param>
    private void ImportFromExcel(string filepath)
    {
        var    list      = ExcelHelper.GetSheetNameList(filepath);
        string sheetName = "Sheet1";

        if (list.Count == 0)
        {
            throw new Exception("Excel文件中不存在任何表格");
        }
        else
        {
            bool flag = false;
            foreach (var item in list)
            {
                if (item.Name == sheetName)
                {
                    flag = true;
                    break;
                }
            }
            if (flag == false)
            {
                sheetName = list[0].Name;
            }
        }
        DataTable datatable = ExcelHelper.ExcelToDataTable(filepath, sheetName);

        //报名序号	学籍主号    姓名	 班级	班内编号	 性别	出生日期	 民族
        //政治面貌	户籍类别	 家庭电话	监护人手机	现居住地址	家庭邮码	 学籍辅号
        int total  = 0; //总共
        int import = 0; //导入数据

        if (datatable.Columns.Contains("学籍辅号") && datatable.Columns.Contains("姓名") &&
            datatable.Columns.Contains("班级"))
        {
            foreach (DataRow row in datatable.Rows)
            {
                total++;
                string xstbh = row["学籍辅号"].ToString();
                string xm    = row["姓名"].ToString();
                string bj    = row["班级"].ToString();
                if (!xstbh.IsNullOrEmpty())
                {
                    var stu = Bmk.FindOne(p => p.xstbh == xstbh);
                    if (stu == null)
                    {
                        stu       = new Bmk();
                        stu.xstbh = xstbh;
                    }
                    stu.xm = xm;
                    if (bj.IsNullOrEmpty() == false)
                    {
                        stu.bj = bj.Substring(bj.IndexOf('(') + 1).TrimEnd(')').PadLeft(2, '0');
                    }
                    ;
                    stu.Save();
                    import++;
                }
            }
            JsUtil.MessageBox(this, string.Format("学生总共{0}人,导入{1}", total, import));
        }
        else
        {
            JsUtil.MessageBox(this, "学籍辅号 姓名 班级 这3列必须存在");
        }
    }
Exemplo n.º 7
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        this.lblMsg.Text = string.Empty;
        for (int i = 0; i < this.GridView1.Rows.Count; i++)
        {
            Bmk bmk = Bmk.FindById((long)this.GridView1.DataKeys[i].Value);

            TextBox txtKm61 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm61");
            TextBox txtKm62 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm62");
            TextBox txtKm63 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm63");

            TextBox txtKm71 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm71");
            TextBox txtKm72 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm72");
            TextBox txtKm73 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm73");
            TextBox txtKm74 = (TextBox)this.GridView1.Rows[i].FindControl("txtKm74");

            DropDownList ddlKm81 = (DropDownList)this.GridView1.Rows[i].FindControl("ddlKm81");

            switch (this.Xm.ToLower())
            {
            case "km61":
                if (!string.IsNullOrWhiteSpace(txtKm61.Text))
                {
                    bmk.km61 = decimal.Parse(txtKm61.Text);
                }
                break;

            case "km62":
                if (!string.IsNullOrWhiteSpace(txtKm62.Text))
                {
                    bmk.km62 = decimal.Parse(txtKm62.Text);
                }
                break;

            case "km63":
                if (!string.IsNullOrWhiteSpace(txtKm63.Text))
                {
                    bmk.km63 = decimal.Parse(txtKm63.Text);
                }
                break;


            case "km71":
                if (!string.IsNullOrWhiteSpace(txtKm71.Text))
                {
                    bmk.km71 = txtKm71.Text.Trim().ToUpper();
                }
                break;

            case "km72":
                if (!string.IsNullOrWhiteSpace(txtKm72.Text))
                {
                    bmk.km72 = txtKm72.Text.Trim().ToUpper();
                }
                break;

            case "km73":
                if (!string.IsNullOrWhiteSpace(txtKm73.Text))
                {
                    bmk.km73 = txtKm73.Text.Trim().ToUpper();
                }
                break;

            case "km74":
                if (!string.IsNullOrWhiteSpace(txtKm74.Text))
                {
                    bmk.km74 = txtKm74.Text.Trim().ToUpper();
                }
                break;

            case "km81":
                if (ddlKm81.SelectedIndex > 0)
                {
                    bmk.km81 = ddlKm81.SelectedValue;
                }
                break;

            default:
                break;
            }
            bmk.Save();
        }
        JsUtil.MessageBox(this, "操作完成!");
        BindData();

        //    if (!string.IsNullOrEmpty(this.lblMsg.Text))
        {
            //       JsUtil.MessageBox(this,this.lblMsg.Text);
        }
    }