Example #1
0
 protected bool DoUpdate(Model.CCOM.Examination_subject_score Fl)
 {
     try
     {
         BLL.CCOM.Examination_subject_score Bss = new BLL.CCOM.Examination_subject_score();
         Bss.Update(Fl);
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
        public void ProcessRequest(HttpContext context)
        {
            long    Id;
            int     Id1, Id2;
            string  result = "";
            decimal Score  = 0;

            try
            {
                Id    = Convert.ToInt64(DESEncrypt.Decrypt(context.Request.Params["id"].ToString()));
                Id1   = Convert.ToInt32(DESEncrypt.Decrypt(context.Request.Params["id1"].ToString()));
                Id2   = Convert.ToInt32(DESEncrypt.Decrypt(context.Request.Params["id2"].ToString()));
                Score = Convert.ToDecimal(context.Request.Params["txtScore"].ToString());

                var model  = new Model.CCOM.Examination_subject_score();
                var _model = new Model.CCOM.Examination_subject_score();
                BLL.CCOM.Examination_subject_score Bess = new BLL.CCOM.Examination_subject_score();

                model                   = new BLL.CCOM.Examination_subject_score().GetModel(" Esn_id = " + Id1 + " AND User_id=" + Id + " AND Judge_id=" + Id2);
                _model.Esn_id           = Id1;
                _model.Ess_score        = Score;
                _model.Judge_id         = Id2;
                _model.User_id          = Id;
                _model.Ess_score_status = true;
                _model.Ess_order_status = true;
                if (model != null)
                {
                    _model.Ess_id = model.Ess_id;
                    Bess.Update(_model);
                }
                else
                {
                    Bess.Add(_model);
                }
                new Calculation().calculateSubjectXu(Id1.ToString(), Id2.ToString());
                result += "添加成功";
            }
            catch (Exception ex)
            {
                ILog LOGGER = LogManager.GetLogger("quanquan");
                LOGGER.Debug(ex.Message, ex);
                result += "添加失败,请重新尝试";
            }
            context.Response.ContentType = "text/plain";
            context.Response.Write(result);
        }
Example #3
0
        protected void btnUpload_Click(object sender, EventArgs e)
        {
            string result = "";

            if (this.txtFraUpload.PostedFile.FileName == "")
            {
                JscriptMsg("请选择上传文件", "", "Error");
                return;
            }
            DataSet ds   = new DataSet();
            string  path = "/upload/excel/";

            #region 解决360获取绝对路径导致出错的问题
            string   AbsolutePath = this.txtFraUpload.PostedFile.FileName;
            string[] pathList     = new string[] { };

            pathList     = AbsolutePath.Split('\\');
            AbsolutePath = pathList[pathList.Length - 1];
            #endregion

            string fileName = DateTime.Now.ToFileTime() + "_" + AbsolutePath;
            string FexName  = fileName.Substring(fileName.LastIndexOf(".") + 1);
            if (FexName != "xls" && FexName != "xlsx")
            {
                JscriptMsg("请上传Excel文件", "", "Error");
                return;
            }

            string filePath = Server.MapPath(path + fileName);

            this.txtFraUpload.SaveAs(filePath);
            int success = 0, error = 0;
            try
            {
                var excel = new Common.ExcelToData();
                ds = excel.GetExcelData(filePath);

                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    if (ds.Tables[0].Rows[i]["考生号"].ToString().Trim() == "")
                    {
                        result += "×第" + (i + 1).ToString() + "行添加失败,考生号不能为空;<br/>";
                        error++;
                        continue;
                    }

                    var __model = new BLL.CCOM.User_property().GetModel(" UP_CCOM_number='" + ds.Tables[0].Rows[i]["考生号"].ToString().Trim() + "'");
                    if (__model == null)
                    {
                        result += "×第" + (i + 1).ToString() + "行添加失败,考生号错误;<br/>";
                        error++;
                        continue;
                    }
                    long user_id = __model.User_id;

                    var model  = new Model.CCOM.Examination_subject_score();
                    var _model = new Model.CCOM.Examination_subject_score();
                    model = new BLL.CCOM.Examination_subject_score().GetModel(" Esn_id = " + id1 + " AND User_id=" + user_id + " AND Judge_id=" + id2);

                    _model.Esn_id           = Convert.ToInt32(id1);
                    _model.Judge_id         = Convert.ToInt32(id2);
                    _model.User_id          = user_id;
                    _model.Ess_score        = (ds.Tables[0].Rows[i]["科目成绩"].ToString().Trim() == "" ? 0 : Convert.ToDecimal(ds.Tables[0].Rows[i]["科目成绩"].ToString().Trim()));
                    _model.Ess_score_status = true;
                    _model.Ess_order_status = true;
                    bool isOK = false;
                    if (model != null)
                    {
                        _model.Ess_id = model.Ess_id;
                        isOK          = DoUpdate(_model);
                    }
                    else
                    {
                        isOK = DoAdd(_model);
                    }

                    if (isOK)
                    {
                        success++;
                    }
                    else
                    {
                        result += "×第" + (i + 1).ToString() + "行‘" + ds.Tables[0].Rows[i]["考生号"].ToString().Trim() + "’信息异常,导入失败。<br/>";
                        error++;
                    }
                }
            }
            catch (Exception ex)
            {
                ILog LOGGER = LogManager.GetLogger("quanquan");
                LOGGER.Debug("导入分数线异常" + ex.Message, ex);
                result = "导入分数线异常,请联系客服";
            }

            try
            {
                new Calculation().calculateSubjectXu(id1.ToString(), id2.ToString());
            }
            catch
            {
            }
            string divinfo = "<div class=\"alert alert-block alert-info fade in\">";
            divinfo += "<button data-dismiss=\"alert\" class=\"close\" type=\"button\">×</button>";
            divinfo += "<h4 class=\"alert-heading\">导入结果</h4>";
            divinfo += "<p>";
            if (success != ds.Tables[0].DefaultView.Count)
            {
                divinfo += "部分导入成功,您可以按照提示修改Excel并重新提交<br>";
            }
            else
            {
                divinfo += "全部导入成功,请您进入下一步确认导入信息<br>";
            }
            divinfo += "*共有" + ds.Tables[0].DefaultView.Count + "条数据,成功" + success + "条,失败" + error + "条;<br/>";
            if (result != "")
            {
                divinfo += "详细信息如下:<br><font color='red'>" + result;
            }
            divinfo           += "</font></p>";
            divinfo           += "</div>";
            this.lblError.Text = divinfo;

            //显示下一步
            if (success > 0)
            {
                this.btnSubmit.Visible = true;
            }
            //删除上传的文件
            File.Delete(filePath);
        }