示例#1
0
        /// <summary>
        /// Ìí¼ÓÀÏʦ
        /// </summary>
        /// <returns></returns>
        public ActionResult AddTeacherMessage(string userName, string userCode, string userPassword)
        {
            try
            {
                string Message = "Ìí¼Ó³É¹¦";
                int    IsOk    = 0;
                IsOk = bull.AddDBase_UserTeacher(userName, userCode, DESEncrypt.Encrypt(userPassword));

                return(Content(new JsonMessage {
                    Success = true, Code = IsOk.ToString(), Message = Message
                }.ToString()));
            }
            catch (Exception ex)
            {
                Base_SysLogBll.Instance.WriteLog("", OperationType.Add, "-1", "Òì³£´íÎó£º" + ex.Message);
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// 添加Excel的数据
        /// </summary>
        /// <param name="xmlDate"></param>
        private string AddExcelData(DataTable xmlDate, string NK)
        {
            string errorMsg   = "";
            int    errorcount = 0;                  //错误的个数
            int    sumcount   = xmlDate.Rows.Count; //导入数据的总个数
            int    rowindex   = 1;                  //行标
            string comname    = string.Empty;
            int    i          = 1;
            string userName   = "";
            string userCode   = "";

            foreach (DataRow excelRow in xmlDate.Rows)
            {
                bool flg = true;//可添加入库的标识
                rowindex++;
                try
                {
                    userName = excelRow[0].ToString().Trim();
                    /**************老师姓名**********/
                    int userNameLength = excelRow[0].ToString().Trim().Length;
                    comname = excelRow[0].ToString().Trim();
                    if (userNameLength > 0 && userNameLength <= 100)
                    {
                        userName = excelRow[0].ToString().Trim();
                    }
                    else
                    {
                        if (flg)
                        {
                            errorcount++;
                        }
                        errorMsg = errorMsg + ErrorMsgTitle(rowindex, comname) + "为空,或者长度超过100个字符),添加失败\r\n";
                        flg      = false;
                    }

                    /**************老师代号**********/
                    int userCodeLength = excelRow[1].ToString().Trim().Length;
                    if (userCodeLength > 0 & userCodeLength <= 100)
                    {
                        userCode = excelRow[1].ToString().Trim();
                    }
                    else
                    {
                        if (flg)
                        {
                            errorcount++;
                        }
                        errorMsg = errorMsg + ErrorMsgTitle(rowindex, comname) + "为空,或者长度超过100个字符),添加失败\r\n";
                        flg      = false;
                    }
                }

                catch (Exception ex)
                {
                    if (flg)
                    {
                        errorcount++;
                    }
                    errorMsg = errorMsg + ErrorMsgTitle(rowindex, comname) + ",添加失败;失败原因:" + ex.Message + "<br/>";
                    flg      = false;
                }


                if (flg)
                {
                    int result = 1;
                    try
                    {
                        //导入信息返回的结果
                        result = bUsersBll.AddDBase_UserTeacher(userName, userCode, DESEncrypt.Encrypt(userCode));
                        if (result <= 0)
                        {
                            if (flg)
                            {
                                errorcount++;
                            }
                            errorMsg = errorMsg + ErrorMsgTitle(rowindex, comname) + "添加失败(原因:数据库已存在!)" + "<br/>";
                        }
                    }
                    catch (Exception ex)
                    {
                        errorcount++;
                        errorMsg = errorMsg + ErrorMsgTitle(rowindex, comname) + "添加失败;失败原因:" + ex.Message + "<br/>";
                    }
                }

                i++;
            }



            string importMsg = "共导入【" + sumcount + "】条记录<br/>" +
                               "导入成功【" + (sumcount - errorcount) + "】条记录<br/>" +
                               "导入失败【" + (errorcount) + "】条记录<br/>";

            return(importMsg + "<br><div style='color:blue' id='errorMsg'>" + errorMsg + "</div>");
        }