/// <summary> /// 页面出错,记录出错的日志 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected virtual void Page_Error(object sender, EventArgs e) { string errMsg; //得到系统上一个异常 Exception currentError = Server.GetLastError(); errMsg = "<link rel=\"stylesheet\" href=\"/default.css\">"; errMsg += "<h1>" + (String)GetGlobalResourceObject("WebGlobalResource", "Error") + "</h1>" + (String)GetGlobalResourceObject("WebGlobalResource", "ErrorPosition") + Request.Url.ToString() + "<br/><hr/>" + (String)GetGlobalResourceObject("WebGlobalResource", "ErrorMessage") + " <font class=\"ErrorMessage\">" + currentError.Message.ToString() + "</font><hr/>" + "<b>Stack Trace:</b><br/>" + currentError.ToString(); //如果发生致命应用程序错误 //if (!(currentError is ApplicationException)) //{ //向Windows事件日志中写入错误日志 // LogEvent(currentError.ToString(), EventLogEntryType.Error); //} //在页面中显示错误 Response.Write(errMsg); //记录错误到日志中 WebLog.InsertLog("错误", "", "网页名:" + Request.Url.ToString() + " ; 错误信息:" + currentError.Message.ToString() + "; 错误发生地点:" + currentError.StackTrace); //清除异常 Server.ClearError(); }
protected void btnAdd_Click(object sender, EventArgs e) { uint max = DBOpt.dbHelper.GetMaxNum("T_ZDH_自动化值班记事", "TID"); _sql = "insert into T_ZDH_自动化值班记事(TID,值班日期,发生时间,记录人) values(" + max.ToString() + ",TO_DATE('" + wdlDate.getTime().ToString("dd-MM-yyyy") + "','DD-MM-YYYY')," + "TO_DATE('" + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss") + "','DD-MM-YYYY HH24:MI:SS'),'" + ViewState["系统值班人"].ToString() + "')"; if (DBOpt.dbHelper.ExecuteSql(_sql) > 0) { btnQuery_Click(null, null); int rowID; for (rowID = 0; rowID < grvList.Rows.Count; rowID++) { if (grvList.DataKeys[rowID].Value.ToString() == max.ToString()) { break; } } GridViewEditEventArgs arg = new GridViewEditEventArgs(rowID); grv_RowEditing(grvList, arg); } else { JScript.Alert("添加自动化值班记事失败,请联系管理员!"); WebLog.InsertLog("", "失败", _sql); return; } }
protected virtual void btnSave_Click(object sender, EventArgs e) { string ret, sql; ret = ControlWebValidator.Validate(this.Page, Session["TableName"].ToString()); if (ret.Length > 0) { info.InnerText = ret; return; } ret = CustomControlSave.CustomControlSaveByTableNameReturnS(this.Page, Session["TableName"].ToString(), out sql); if (ret.Length > 0) { info.InnerText = ret; return; } else { info.InnerText = ""; WebLog.InsertLog("", "成功", sql); } //JScript.CloseWin("refreshPage"); Response.Redirect(Session["URL"].ToString()); }
protected void grvUpFileList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "del") { string path, fileName, mapname; path = grvUpFileList.Rows[Convert.ToInt16(e.CommandArgument)].Cells[2].Text; fileName = grvUpFileList.Rows[Convert.ToInt16(e.CommandArgument)].Cells[3].Text; _sql = "delete from T_FILE_ACCESSORIES where TID=" + grvUpFileList.Rows[Convert.ToInt16(e.CommandArgument)].Cells[0].Text; if (DBOpt.dbHelper.ExecuteSql(_sql) > 0) { mapname = Page.MapPath(path); if (File.Exists(mapname + fileName)) { File.Delete(mapname + fileName); } _sql = "select * from T_FILE_ACCESSORIES where FILE_ID=" + txtTID.Text; _dt = DBOpt.dbHelper.GetDataTable(_sql); grvUpFileList.DataSource = _dt; grvUpFileList.DataBind(); } else { WebLog.InsertLog("", "失败", _sql); detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "DeleteFailMessage").ToString(); //数据删除失败 return; } } }
protected void imgExit_Click(object sender, ImageClickEventArgs e) { WebLog.InsertLog("退出", "成功", "退出系统"); Session["MemberID"] = null; Session["MemberName"] = null; Session["DepartID"] = null; Session["RoleIDs"] = null; Response.Write("<script>parent.window.close();</script>"); }
protected void imgZhuxiao_Click(object sender, ImageClickEventArgs e) { WebLog.InsertLog("注销", "成功", "注销系统"); Session["MemberID"] = null; Session["MemberName"] = null; Session["DepartID"] = null; Session["RoleIDs"] = null; Response.Write("<script>parent.window.close();</script>"); Response.Write("<script>parent.window.open('frmlogin.aspx');</script>"); }
protected void lbnRelogin_Click(object sender, EventArgs e) { WebLog.InsertLog("注销", "成功", "注销系统"); Session["MemberID"] = null; Session["MemberName"] = null; Session["DepartID"] = null; Session["RoleIDs"] = null; //Response.Write("<script>parent.window.close();</script>"); //Response.Write("<script>parent.window.open('frmlogin.aspx');</script>"); Response.Write("<script>parent.window.location='frmlogin.aspx';</script>"); }
protected void btnUpload_Click(object sender, EventArgs e) { //上传之前先保存,否则有孤立的文件存在 btnSave_Click(null, null); if (info.InnerText != "") { return; } if (Session["FilePath"] == null) { info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileNoPath").ToString(); // "没有设置上传文件的存入路径,请联系管理员!"; return; } if (fulFile.FileName == "") { info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileNoAccessories").ToString(); // "请先选择要上传的文件!"; return; } //上传文件 string mapname = Page.MapPath(Session["FilePath"].ToString()); string fileName = fulFile.FileName.Substring(fulFile.FileName.LastIndexOf(@"\") + 1); if (File.Exists(mapname + fileName)) { info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileIterativeMessage").ToString();// "服务器上存在同名的文件,请更改文件名!"; return; } try { fulFile.SaveAs(mapname + fileName); txtFILE_NAME.Text = fulFile.FileName.Substring(fulFile.FileName.LastIndexOf(@"\") + 1); if (txtDESCR.Text.Trim() == "") { txtDESCR.Text = txtFILE_NAME.Text; } txtFILE_SUFFIX.Text = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower(); //统一为小写 btnSave_Click(null, null); } catch (Exception ex) { WebLog.InsertLog("上传文件", "失败", "失败原因:" + ex.Message); info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileUploadFailMessage").ToString(); //上传文件失败,请联系管理员 return; } }
protected override void btnSave_Click(object sender, EventArgs e) { string ret, sql; ret = ControlWebValidator.Validate(this.Page, Session["TableName"].ToString()); if (ret.Length > 0) { info.InnerText = ret; return; } ret = CustomControlSave.CustomControlSaveByTableNameReturnS(this.Page, Session["TableName"].ToString(), out sql); if (ret.Length > 0) { info.InnerText = ret; return; } else { info.InnerText = ""; WebLog.InsertLog("", "成功", sql); } }
protected void btnUpload_Click(object sender, EventArgs e) { if (Session["FilePath"] == null) { detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileNoPath").ToString(); // "没有设置上传文件的存入路径,请联系管理员!" return; } if (fulFile.FileName == "") { detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileNoAccessories").ToString(); //没有上传的附件! return; } //if (fulFile.PostedFile.ContentLength > 4096000) //{ // JScript.Alert(this.Page, "上传文件大小不允许超过4M!"); // return; //} uint maxTID; int type; string fileName, fileSuffix; object obj; maxTID = DBOpt.dbHelper.GetMaxNum("T_FILE_ACCESSORIES", "TID"); fileName = fulFile.FileName.Substring(fulFile.FileName.LastIndexOf(@"\") + 1); fileSuffix = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower(); //统一为小写 _sql = "select TID from T_FILE_TYPE where SUFFIX like '%" + fileSuffix + "%'"; obj = DBOpt.dbHelper.ExecuteScalar(_sql); if (obj == null) { type = 1; //其它文件 } else { type = Convert.ToInt16(obj); } if (txtDESCR.Text.Trim() == "") { txtDESCR.Text = fileName; } //上传之前先保存,否则有孤立的文件存在 btnSave_Click(null, null); if (detail_info.InnerText != "") { return; } //上传文件 string mapname; mapname = Page.MapPath(Session["FilePath"].ToString()); if (File.Exists(mapname + fileName)) { detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileIterativeMessage").ToString(); //服务器上存在同名的文件,请更改文件名 return; } try { fulFile.SaveAs(mapname + fileName); } catch (Exception ex) { WebLog.InsertLog("上传文件", "失败", "失败原因:" + ex.Message); detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "FileUploadFailMessage").ToString(); //上传文件失败,请联系管理员 return; } //保存上传文件参数 if (DBHelper.databaseType == "Oracle") { _sql = "insert into T_FILE_ACCESSORIES(TID,FILE_ID,FILE_NAME,FILE_PATH,TYPE_ID,FILE_SUFFIX,UP_DATE) values(" + maxTID + "," + txtTID.Text + ",'" + fileName + "','" + Session["FilePath"].ToString() + "'," + type + ",'" + fileSuffix.ToLower() + "',TO_DATE('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "','YYYY-MM-DD HH24:MI'))"; } else { _sql = "insert into T_FILE_ACCESSORIES(TID,FILE_ID,FILE_NAME,FILE_PATH,TYPE_ID,FILE_SUFFIX,UP_DATE) values(" + maxTID + "," + txtTID.Text + ",'" + fileName + "','" + Session["FilePath"].ToString() + "'," + type + ",'" + fileSuffix.ToLower() + "','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "')"; } if (DBOpt.dbHelper.ExecuteSql(_sql) == -1) { WebLog.InsertLog("", "失败", _sql); detail_info.InnerText = GetGlobalResourceObject("WebGlobalResource", "SaveFailMessage").ToString();//数据保存失败,请联系管理员! return; } _sql = "select * from T_FILE_ACCESSORIES where FILE_ID=" + txtTID.Text; _dt = DBOpt.dbHelper.GetDataTable(_sql); grvUpFileList.DataSource = _dt; grvUpFileList.DataBind(); }
protected void btnUpload_Click(object sender, EventArgs e) { if (MyFileInput.PostedFile != null) { string fileName, fileSuffix, path; fileName = MyFileInput.FileName.Substring(MyFileInput.FileName.LastIndexOf(@"\") + 1); fileSuffix = fileName.Substring(fileName.LastIndexOf(".") + 1).ToLower(); //统一为小写 //判断上传的文件在服务器是否存在 path = Server.MapPath("..\\upload\\"); if (File.Exists(path + fileName)) { JScript.Alert(this.Page, "服务器存在同名的文件,请修改文件名再上传!"); return; } uint iMaxNo; uint iFileNo; iMaxNo = 0; iFileNo = DBOpt.dbHelper.GetMaxNum("DMIS_SYS_WK_FILE", "F_NO"); try { MyFileInput.PostedFile.SaveAs(path + fileName); } catch (Exception ex) { WebLog.InsertLog("上传文件", "失败", "失败原因:" + ex.Message); JScript.Alert("上传文件时失败,已保存失败信息,请联系管理员"); return; } if (txtTitle.Text.Trim() == "") { txtTitle.Text = fileName.Substring(0, fileName.IndexOf('.')); } if (txtDesc.Text.Trim() == "") { txtDesc.Text = fileName.Substring(0, fileName.IndexOf('.')); } sql = "INSERT INTO DMIS_SYS_WK_FILE(F_NO,F_CAPTION,F_FILETYPE,F_FILENAME,F_DESC,F_PACKNO) VALUES(" + iFileNo + ",'" + txtTitle.Text + "'" + ",'" + fileSuffix + "','" + fileName + "','" + txtDesc.Text + "'," + ViewState["PackNo"] + ")"; DBOpt.dbHelper.ExecuteSql(sql); //感觉没有必要插数据到DMIS_SYS_DOC中。 //iMaxNo = DBOpt.dbHelper.GetMaxNum("DMIS_SYS_DOC", "F_NO"); //sql = "INSERT INTO DMIS_SYS_DOC(F_NO,F_PACKNO,F_DOCTYPENO,F_DOCNAME," // + "F_CREATEMAN,F_CREATEDATE,F_TABLENAME,F_RECNO) " // + " VALUES(" + iMaxNo + "," + Session["PackNo"] + "," + Session["DocTypeNo"] // + ",'" + txtTitle.Text + "','" + Session["MemberName"] + "','" + DateTime.Now.ToString("yyyy-MM-dd") // + "','DMIS_SYS_WK_FILE'," + iFileNo + ")"; //DBOpt.dbHelper.ExecuteSql(sql); } else { JScript.Alert("请先选择要上传的文件!"); return; } Response.Write(webfun.CloseWin("refreshPage")); }
protected void btnOk_Click(object sender, EventArgs e) { if (txtCode.Value.Trim() == "" || txtPwd.Value.Trim() == "") { lblMessage.Text = GetGlobalResourceObject("WebGlobalResource", "ItemNotNull").ToString(); return; } string sql = "select ID,NAME,DEPART_ID,THEME,FLAG,PASSWORD from DMIS_SYS_MEMBER where CODE = '" + txtCode.Value.Trim() + "' and PASSWORD='******' and flag=0"; DataTable dt = DBOpt.dbHelper.GetDataTable(sql); if (dt == null) { lblMessage.Text = GetGlobalResourceObject("WebGlobalResource", "DbFail").ToString(); return; } if (dt.Rows.Count < 1) { lblMessage.Text = GetGlobalResourceObject("WebGlobalResource", "UserOrPwdWrong").ToString(); WebLog.InsertLog("登录", "失败", "以用户名:" + txtCode.Value + "登录失败"); return; } lblMessage.Text = ""; Session["code"] = txtCode.Value.Trim(); Session["name"] = dt.Rows[0]["NAME"].ToString(); Session["MemberName"] = dt.Rows[0]["NAME"].ToString(); Session["DepartID"] = dt.Rows[0]["DEPART_ID"]; //登录人员所属部门ID Session["MemberID"] = dt.Rows[0]["ID"]; //登录人员ID //2010-7-30 封掉外观主题 //if (dt.Rows[0][3] == Convert.DBNull || dt.Rows[0][3].ToString().Trim() == "") //主题 Session["THEME"] = "default"; //else // Session["THEME"] = dt.Rows[0][3]; //找登录人员的岗位 System.Text.StringBuilder sbRole = new System.Text.StringBuilder(); sql = "SELECT ROLE_ID FROM DMIS_SYS_MEMBER_ROLE WHERE MEMBER_ID=" + Session["MemberID"].ToString(); DataTable dtRole = DBOpt.dbHelper.GetDataTable(sql); for (int i = 0; i < dtRole.Rows.Count; i++) { sbRole.Append(dtRole.Rows[i][0].ToString()); sbRole.Append(","); } if (sbRole.Length > 0) { Session["RoleIDs"] = sbRole.Remove(sbRole.Length - 1, 1); //把最后一个逗号去掉 } else { Session["RoleIDs"] = ""; } if (Session["RoleIDs"].ToString().Trim() == "") { //lblMessage.Text = "没有授权,不能登录!"; WebLog.InsertLog("登录", "失败", "用户没有授权,不能登录!"); return; } WebLog.InsertLog("登录", "成功", "登录成功"); //Response.Write("<script> winobj=window.open('MainFrame.htm','','toolbar=no,menubar=no,titlebar=yes,directories=no,resizable=yes,status=yes');" + // "winobj.moveTo(0,0);winobj.resizeTo(screen.width,screen.height);parent.window.opener=null;self.window.close();" + // "</script>"); Response.Redirect("MainFrame.htm"); }