Beispiel #1
0
    protected void btnSave_ServerClick(object sender, EventArgs e)
    {
        TFXK.Model.TestingStudent model = new TFXK.Model.TestingStudent();
        DateTime birthday;

        DateTime.TryParse(txtBirthday.Value + "", out birthday);
        model.Birthday       = birthday;
        model.ClassID        = int.Parse(ddlClass.SelectedValue);
        model.Country        = ddlCountry.SelectedValue;
        model.CreateTime     = DateTime.Now;
        model.EthnicGroup    = ddlMingzu.SelectedValue;
        model.IDNumber       = txtID.Value + "";
        model.IsPass         = 0;
        model.LevelNum       = ddlLevel.SelectedValue;
        model.OrgLevel       = ddlOrgLevel.SelectedValue;
        model.PlanID         = Int32.Parse(Request.QueryString["id"]);
        model.Score          = 0;
        model.Sex            = int.Parse(ddlSex.SelectedValue);
        model.UserHeadImage  = txtIDImg1.Value.ToString();
        model.UserWorkImage  = txtIDImg2.Value.ToString();
        model.UserName       = txtUserName.Value.ToString();
        model.UserNamePinyin = txtUserNamePinyin.Value.ToString();

        if (string.IsNullOrEmpty(model.UserName))
        {
            InitData(model.PlanID.Value);
            Msg.Show("名称不能为空!");
            return;
        }
        if (string.IsNullOrEmpty(model.UserNamePinyin))
        {
            InitData(model.PlanID.Value);
            Msg.Show("名称拼音不能为空!");
            return;
        }
        if (string.IsNullOrEmpty(model.IDNumber))
        {
            InitData(model.PlanID.Value);
            Msg.Show("身份证不能为空!");
            return;
        }
        if (model.Birthday == null)
        {
            InitData(model.PlanID.Value);
            Msg.Show("出生日期不能为空!");
            return;
        }
        int id = bllTestingStudent.Add(model);

        if (id > 0)
        {
            Response.Redirect("ExamPlanStudent.aspx?id=" + model.PlanID);
        }
    }
Beispiel #2
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(TFXK.Model.TestingStudent model)
 {
     return(dal.Update(model));
 }
Beispiel #3
0
    protected void btnImport_ServerClick(object sender, EventArgs e)
    {
        if (!fileImport.HasFile || fileImport.FileContent.Length == 0)
        {
            Jscript.Alert("请上传填写好内容的模板文件");
            return;
        }

        string fileName = "~/uploads/file/" + DateTime.Now.ToString("yyyy-MM-ddHHmmss") + ".xls";

        try
        {
            fileImport.SaveAs(Server.MapPath(fileName));
        }
        catch (Exception ex)
        {
            Response.Write("上传文件失败:" + ex.Message);
        }
        try
        {
            DataSet ds = TFXK.Common.ExcelImport.ExcelToDS(Server.MapPath(fileName));
            if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows != null && ds.Tables[0].Rows.Count > 0)
            {
                int recordCount = 0;
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    TFXK.Model.TestingStudent model = new TFXK.Model.TestingStudent();
                    model.UserName       = dr[0].ToString();
                    model.UserNamePinyin = dr[1].ToString();
                    model.Sex            = dr[2].ToString().Equals("男") ? 0 : 1;
                    model.IDNumber       = dr[3].ToString();
                    DateTime birthday;
                    DateTime.TryParse(dr[4] + "", out birthday);
                    model.Birthday = birthday;
                    var cmodel = bllCategory.GetModelByName(dr[5] + "");
                    if (cmodel == null)
                    {
                        continue;
                    }
                    model.ClassID  = cmodel.id;
                    model.LevelNum = dr[6] + "";
                    model.OrgLevel = dr[7] + "";
                    var countryModel = bllCategory.GetModelByName(dr[8] + "");
                    if (countryModel == null)
                    {
                        continue;
                    }
                    model.Country = countryModel.id + "";

                    var EthnicGroupModel = bllCategory.GetModelByName(dr[9] + "");
                    if (EthnicGroupModel == null)
                    {
                        continue;
                    }
                    model.EthnicGroup   = EthnicGroupModel.id + "";
                    model.CreateTime    = DateTime.Now;
                    model.IsPass        = 0;
                    model.PlanID        = Int32.Parse(Request.QueryString["id"]);
                    model.Score         = 0;
                    model.UserHeadImage = "";
                    model.UserWorkImage = "";
                    recordCount++;
                    bllTestingStudent.Add(model);
                }
                Jscript.Alert("已提交数据" + recordCount + "条");
            }
            else
            {
                Jscript.Alert("没有读取到数据");
            }
        }
        catch (Exception ex)
        {
            Jscript.Alert("读取导入数据错误:" + ex.Message);
        }
    }
Beispiel #4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(TFXK.Model.TestingStudent model)
 {
     return(dal.Add(model));
 }