<%@ WebHandler Language="C#" Class="EditData" %> using System; using System.Collections.Generic; using System.Web; using System.Data; using System.Data.Common; using System.Web.SessionState; using System.Text; using eMIS; public class EditData : IHttpHandler , IRequiresSessionState { public void ProcessRequest (HttpContext context) { string wwwroot = context.Request.ApplicationPath; if (wwwroot == "/") wwwroot = ""; string themePath = wwwroot + "/Themes/" + context.Session["Theme"].ToString(); string menuId = context.Request["proid"].ToString(); string recordId = context.Request["varSign"].ToString(); string recordId2 = (context.Request["mrid"] == null ? "" : context.Request["mrid"].ToString()); bool isIP = (context.Session["ismobile"].ToString() == "1"); int i; string userId = context.Session["userid"].ToString(); string userCnName = context.Session["usercnname"].ToString(); string rndstr = DateTime.Now.ToString(); bool multiRowEdit = false; if (recordId2 != "") { multiRowEdit = true; } DataManager dm = new DataManager(); InstanceManager inst = new InstanceManager(context, dm, menuId); inst.PrimaryKeyValue = recordId; string popedomUserId = inst.PopedomUserID; if (recordId =="" && context.Request["position"] != null) { inst.RecordPosition = int.Parse(context.Request["position"].ToString()); recordId = inst.PrimaryKeyValue; if (recordId == null) recordId = ""; } string mini = inst.GetStateValue("emn"); bool allowEdit = true; if (mini == "") { allowEdit = inst.AllowEdit(); } else { inst.FieldPopedom.Priority = 2; } if (!allowEdit) { context.Response.Write("没有访问的权限!"); context.Response.End(); } string s; //set pri = aco.GetPrivilegeObject() //pri.init aco.sysconn,proid,2 //'if not pri.Permission(session("renyuan_id")) then '验证有没有编辑的权限 //' s = "false" //'end if //if s = "" and recid <> "" and aco.ParentValue="" then '验证有没有访问该记录的权限 // s = pri.GetListCondition(session("renyuan_id")) // if s <> "" then // aco.openuc() // set rs = aco.getrs("select count(" & aco.mt.gjzd & ") from " & aco.mt.fwb & " where " & aco.mt.gjzd & "=" & recid & s,0) // if rs(0) = 0 then // s = "false" // end if // aco.closeuc // end if //end if //if s = "false" then //aco.closesc //set aco = nothing //response.redirect "Error_Display.asp?ReturnUrl=0&Error_Text=" & server.urlencode("没有权限打开该页面!") //end if ProgramManager program = inst.Program; DataTable elements = program.EditElements; int elementsCount = elements.Rows.Count; FieldPopedomManager fpm = new FieldPopedomManager(inst); string programId = program.ID; string customUi =(multiRowEdit ? "" : program.Properties["DZBJYM"].ToString()); bool isTab = (inst.Program.EditPageTabName != ""); if (elementsCount == 0) { string path = customUi; if (path == "") { context.Response.Redirect("Error_Display.asp?ReturnUrl=0&Error_Text=" + context.Server.UrlEncode("请定义维护字段!")); } else { path = program.GetTemplatePath(path); if (path.IndexOf("?") == -1) path += "?"; else path += "&"; } context.Response.Redirect(wwwroot + path + "id=" + recordId + "&proid=" + menuId + "&position=" + inst.RecordPosition.ToString() + "&count=" + inst.RecordCount.ToString() + "&recid=" + recordId); } string pagetitle = program.Properties["bt"].ToString(); StringBuilder sb = new StringBuilder(); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine("" + pagetitle + ""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); if (customUi=="") { sb.AppendLine(""); } else { sb.AppendLine(""); } sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); // //================================================================================== //================================================================================== sb.AppendLine(""); sb.AppendLine(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); //========================================================================== sb.AppendLine(""); //sb.Append("
"); sb.Append(""); ControlManager cm = null; int controlCount = inst.EditControls.Count; string controlIdList = ""; for (i = 0; i < controlCount; i++) { cm = inst.EditControls[i]; controlIdList += ",'" + cm.ControlID + "'"; if (cm.IsHidden) { sb.Append(""); } } sb.Append(""); // if (mini != "1") { sb.Append("
"); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("
"); ToolBar toolbar = new ToolBar(dm); if (recordId == "") s = "新增"; else s = inst.RecordPosition.ToString() + "/" + inst.RecordCount.ToString(); s = "关闭 " + s; sb.Append(toolbar.GetHtml(inst.ButtonGroupID, "编辑", s, wwwroot, inst.MenuID, userId)); sb.Append("
"); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append(""); sb.Append("
"); sb.Append("" + pagetitle + "  
"); } //
// sb.Append(""); sb.Append("
"); sb.Append("
"); sb.Append(""); sb.Append(""); sb.Append("
"); sb.Append("
"); // inst.Tag.BusinessDataRow = inst.EditDataRow ; if (isTab) { inst.AppendSubprogramsHtml(sb, "tab"); sb.Append("
"); } if (customUi!="") { //if (isIP) // oPage.WriteCustomPageRO; //else s = context.Server.MapPath(wwwroot + program.GetTemplatePath(customUi)); inst.AppendCustomPageHtml(s, sb); } else { sb.Append("
"); sb.Append("
"); sb.Append(""); if (!multiRowEdit) { for (i = 0; i < controlCount; i++) { cm = inst.EditControls[i]; if (!cm.IsHidden) { sb.Append(""); sb.Append(""); sb.Append(""); } } } else { for (i = 0; i < controlCount; i++) { cm = inst.EditControls[i]; cm.ControlStyle += ";border:1px solid #9FBDDC;"; if (!cm.IsHidden && !cm.IsReadonly) { sb.Append(""); sb.Append(""); sb.Append(""); } } } sb.Append("
"); sb.Append(cm.ControlDescription); sb.Append(":"); if (!cm.AllowNull) sb.Append(" *"); sb.Append(""); sb.Append(cm.GetHtml()); sb.Append("
"); sb.Append(cm.ControlDescription); sb.Append(":"); if (!cm.AllowNull) sb.Append(" *"); sb.Append(""); sb.Append(cm.GetHtml()); sb.Append("
"); //if (isIP) //oPage.WriteSubprogramsRO("全部"); //else if(!isTab) inst.AppendSubprogramsHtml(sb, "all"); sb.Append("
"); } if (isTab) sb.Append("
"); inst.Dispose(); // sb.Append("
"); sb.Append("
"); sb.Append(""); // //sb.Append(""); sb.Append(""); sb.Append(""); //str = aco.mt.bjymjb //if str <> "" and recid <> "" then // str = aco.GetCustomProgram(str) // set o = aco.GetTagObject() // o.init(oElements) // str = o.ReplaceExpression(str,"colval") // set o = nothing // response.write str //end if sb.AppendLine(""); sb.AppendLine(""); sb.AppendLine(""); context.Response.Write(sb.ToString()); } public void setDisplayFormat(int idx,string s) { //dim s1,fn,ft,i,k //if s= "" then // fn = "" //else // i = instr(s,"displayformat") // if i <1 then // fn= "" // else // i = i + 14 // k = instr(i,s,"(") // fn = mid(s,i,k-i) // i = instr(k,s,")") - 1 // ft = mid(s,k+1,i-k) // end if //end if //displayFormat(idx,0) = fn //displayFormat(idx,1) = ft } private string getDisplay(int idx,string v) { string r=v; //if displayFormat(idx,0) = "" then // r = v //else // select case displayFormat(idx,0) // case "date" // r = emisformatdate(displayFormat(idx,1),v) // case "money" // r = emisformatmoney(displayFormat(idx,1),v) // end select //end if return r; } private string emisformatmoney(string ft,string v) { string r; r = v; if (v != "") { string f = ft + ",,,"; string[] a = f.Split(','); if (a[0] == "") a[0] = "¥"; if (a[1] == "") a[1] = "1"; if (a[2] == "") a[2] = "-1"; if (a[1] == "1") r = Math.Round(Convert.ToDecimal(r),Convert.ToInt16(a[1])).ToString(); r = a[0] + r; } return r; } private string GetItemValue(string itemsString,string itemName) { int i = itemsString.IndexOf("\"" + itemName + "\" : \"") + itemName.Length + 6; int j = itemsString.IndexOf("\"",i); return itemsString.Substring(i, j - i); } public bool IsReusable { get { return false; } } }