protected void btnUpload_Click(object sender, EventArgs e) { string strInfoId = this.hidInfoId.Value; int infoId = 0; if (!string.IsNullOrEmpty(strInfoId)) { infoId = XYECOM.Core.MyConvert.GetInt32(strInfoId); } if (infoId > 0) { info = caseManager.GetItem(infoId); } if (info == null) { info = new Model.CaseInfo(); } info.CaseName = this.txtCaseName.Text.Trim(); info.Description = this.txtDescription.Text.Trim(); if (info.Id > 0) { caseManager.Update(info); } else { string selType = this.ddlType.SelectedValue; if (!string.IsNullOrEmpty(selType)) { info.CaseTypeName = ddlType.SelectedItem.Text; info.CaseTypeId = XYECOM.Core.MyConvert.GetInt32(selType); } else { info.CaseTypeId = 0; info.CaseTypeName = "默认分类"; } string filePath = CaseUploadManager.UpLoadFile(userinfo.CompanyId, userinfo.userid, info.CaseTypeId); if (!string.IsNullOrEmpty(filePath)) { int id = 0; info.PartId = userinfo.userid; info.CompanyId = userinfo.CompanyId; info.PartName = userinfo.LayerName; info.CompanyName = userinfo.CompanyName; info.CreateDate = DateTime.Now; info.FilePath = filePath; caseManager.Insert(info, out id); } else { GotoMsgBoxPageForDynamicPage("档案文件上传失败!", 1, "/Creditor/CaseList.aspx"); return; } } Response.Redirect("/Creditor/CaseList.aspx"); }
protected override void BindData() { int infoid = XYECOM.Core.XYRequest.GetQueryInt("id", 0); if (infoid > 0) { info = caseManager.GetItem(infoid); } if (info != null) { this.txtCaseName.Text = info.CaseName; this.txtDescription.Text = info.Description; this.ddlType.SelectedValue = info.CaseTypeId.ToString(); this.hidInfoId.Value = infoid.ToString(); this.ddlType.Visible = false; this.tbFile.Visible = false; } else { DataTable table = pt.GetListByUserId(userinfo.userid); this.ddlType.DataSource = table; this.ddlType.DataTextField = "PtName"; this.ddlType.DataValueField = "Id"; this.ddlType.DataBind(); this.ddlType.Items.Insert(0, new ListItem("默认分类", "0")); this.tbFile.Visible = true; } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string action = context.Request["Action"]; string id = context.Request["Uid"]; int uid = 0; if (!string.IsNullOrEmpty(action)) { if (action == "add") { string title = context.Request.Form["title"]; string content = context.Request.Form["hidContent"]; string uploadFile = context.Request.Form["hidImgPath"]; bool b = true; CheckEmpty(out b, title, content, uploadFile); if (!b) { context.Response.Write("empty"); return; } Mc.Model.CaseInfo caseInfo = new Model.CaseInfo() { Title = title, Content = content, ImgPath = uploadFile }; try { int count = CaseInfoManage.Add(caseInfo); if (count > 0) { context.Response.Write("ok"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } else if (action == "modify") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { string title = context.Request.Form["title"]; string content = context.Request.Form["content"]; string uploadFile = context.Request.Form["hidImgPath"]; Mc.Model.CaseInfo caseInfo = CaseInfoManage.GetById(uid); if (caseInfo != null) { caseInfo.Title = title; caseInfo.Content = content; caseInfo.ImgPath = uploadFile; try { int count = CaseInfoManage.Modify(caseInfo); if (count > 0) { context.Response.Write("yes"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } } } else if (action == "detail") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { Mc.Model.CaseInfo caseInfo = CaseInfoManage.GetById(uid); if (caseInfo != null) { context.Response.Write(new JavaScriptSerializer().Serialize(caseInfo)); } } } else if (action == "delete") { if (string.IsNullOrEmpty(id)) { context.Response.Write("参数有误"); return; } if (int.TryParse(id, out uid)) { try { int count = CaseInfoManage.Delete(uid); if (count > 0) { context.Response.Write("ok"); } } catch (Exception ex) { LogHelper.WriteLog(typeof(ProcessCase), ex.Message); } } } else { context.Response.Write("action参数有误"); } } else { context.Response.Write("action参数有误"); } }