/// <summary> /// 获取主配置的信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public WEB_PAGECONFIG GetParentInfo(string id) { WEB_PAGECONFIG en = new WEB_PAGECONFIG(); string sqlStr = "select * from web_pageconfig t1 where t1.id='{0}'"; sqlStr = string.Format(sqlStr, id); DataTable dt = DBMgr.GetDataTable(sqlStr); if (dt != null && dt.Rows.Count > 0) { en.ID = Convert.ToInt32(dt.Rows[0]["ID"].ToString()); en.CODE = dt.Rows[0]["CODE"].ToString(); en.NAME = dt.Rows[0]["NAME"].ToString(); en.PAGENAME = dt.Rows[0]["PAGENAME"].ToString(); en.CONFIGCONTENT = dt.Rows[0]["CONFIGCONTENT"].ToString(); string[] array = en.CONFIGCONTENT.Split(';'); en.BUSITYPE = array[0].Split('=')[1]; en.BUSIDETAIL = array[1].Split('=')[1]; en.CUSTOMERCODE = dt.Rows[0]["CUSTOMERCODE"].ToString(); return(en); } else { return(null); } }
/// <summary> /// 判断是否可以将此条记录放入数据库中 /// </summary> /// <returns></returns> public string CanUpdateOrInsert(WEB_PAGECONFIG en) { string result = ""; string strWhere = ""; if (en.ID > 0) { strWhere = " and t1.id not in ('" + en.ID + "') "; } string sqlStr = "select * from web_pageconfig t1 where t1.customercode='{0}' and (t1.code='{1}' or t1.name='{2}') " + strWhere; sqlStr = string.Format(sqlStr, en.CUSTOMERCODE, en.CODE, en.NAME); DataTable dt = DBMgr.GetDataTable(sqlStr); if (dt != null && dt.Rows.Count > 0) { result += "同一客户代码下配置的代码或名称发生了重复"; } sqlStr = "select * from web_pageconfig t1 where t1.customercode='{0}' and t1.pagename='{1}' and t1.configcontent='{2}' " + strWhere; sqlStr = string.Format(sqlStr, en.CUSTOMERCODE, en.PAGENAME, en.CONFIGCONTENT); dt = DBMgr.GetDataTable(sqlStr); if (dt != null && dt.Rows.Count > 0) { result += "同一客户代码下相同页面存在重复"; } return(result); }
public int UpdateConfig(WEB_PAGECONFIG en) { string sqlStr = @"update web_pageconfig set code='{0}',name='{1}',pagename='{2}',configcontent='{3}',customercode='{4}', enabled='{5}',userid='{6}',username='******' where id='{8}'"; sqlStr = string.Format(sqlStr, en.CODE, en.NAME, en.PAGENAME, en.CONFIGCONTENT, en.CUSTOMERCODE, en.ENABLED, en.USERID, en.USERNAME, en.ID); int i = DBMgr.ExecuteNonQuery(sqlStr); return(i); }
/// <summary> /// 新增一笔记录 /// </summary> /// <param name="en"></param> /// <returns></returns> public int AddConfig(WEB_PAGECONFIG en) { string sqlStr = @"insert into web_pageconfig (ID,code,name,pagename,configcontent,customercode,createtime,enabled,userid,username) values (web_pageconfig_id.nextval,'{0}','{1}','{2}','{3}','{4}',sysdate,'{5}','{6}','{7}')"; sqlStr = string.Format(sqlStr, en.CODE, en.NAME, en.PAGENAME, en.CONFIGCONTENT, en.CUSTOMERCODE, en.ENABLED, en.USERID, en.USERNAME); int i = DBMgr.ExecuteNonQuery(sqlStr); return(i); }
public void GetParentInfoForSeach() { parentid = Request["parentid"]; string parentinfo = "[]"; parentInfo = GetParentInfo(parentid); parentinfo = JsonConvert.SerializeObject(parentInfo); Response.Write("{" + "parentinfo:" + parentinfo + "}"); Response.End(); }
/// <summary> /// 复制新增 /// </summary> public void Copy() { string repeat = ""; string response = ""; string parentid = Request["parentid"]; string formdata = Request["formdata"]; JObject json = (JObject)JsonConvert.DeserializeObject(formdata); WEB_PAGECONFIG en = JsonToEntity(json); if (en == null) { repeat = "保存失败,JSON数据转换出现问题"; } else { repeat = CanUpdateOrInsert(en); if (string.IsNullOrEmpty(repeat)) { int i = AddConfig(en); if (i > 0) { string getParentid = "select * from web_pageconfig t1 where t1.customercode='" + en.CUSTOMERCODE + "' and t1.code='" + en.CODE + "'"; DataTable dt = DBMgr.GetDataTable(getParentid); string newParentid = dt.Rows[0]["ID"].ToString(); string getConfigDetail = "select * from web_pageconfig_detail t1 where t1.parentid='" + parentid + "'"; DataTable dtDetail = DBMgr.GetDataTable(getConfigDetail); if (dtDetail != null && dtDetail.Rows.Count > 0) { for (int j = 0; j < dtDetail.Rows.Count; j++) { string insertDetail = @"insert into web_pageconfig_detail (id,parentid,orderno,name,controltype,isselect,selectcontent,configtype,tablecode,fieldcode,tablename,fieldname,createtime,userid,username,enabled) select web_pageconfig_detail_id.nextval,'" + newParentid + @"',orderno,name,controltype,isselect,selectcontent,configtype,tablecode,fieldcode,tablename,fieldname,sysdate,userid,username,enabled from web_pageconfig_detail where id='" + dtDetail.Rows[j]["id"].ToString() + "'"; DBMgr.ExecuteNonQuery(insertDetail); } repeat = "5"; } } else { repeat = "复制新增失败"; } } } response = "{\"success\":\"" + repeat + "\"}"; Response.Write(response); Response.End(); }
public WEB_PAGECONFIG JsonToEntity(JObject json) { WEB_PAGECONFIG en = new WEB_PAGECONFIG(); try { if (!string.IsNullOrEmpty(json.Value <string>("ID"))) { en.ID = Convert.ToInt32(json.Value <string>("ID")); } else { en.ID = -1; } en.CODE = json.Value <string>("CODE"); en.NAME = json.Value <string>("NAME"); en.PAGENAME = json.Value <string>("PAGENAME"); en.CUSTOMERCODE = json.Value <string>("CUSTOMERCODE"); if (!string.IsNullOrEmpty(json.Value <string>("ENABLED"))) { en.ENABLED = Convert.ToInt32(json.Value <string>("ENABLED")); } else { en.ENABLED = 1; } en.BUSITYPE = json.Value <string>("BUSITYPE"); en.BUSIDETAIL = json.Value <string>("BUSIDETAIL"); en.CONFIGCONTENT = "业务类型=" + en.BUSITYPE + ";业务细项=" + en.BUSIDETAIL; FormsIdentity identity = HttpContext.Current.User.Identity as FormsIdentity; string userName = identity.Name; JObject json_user = Extension.Get_UserInfo(userName); en.USERID = (Int32)json_user.GetValue("ID"); en.USERNAME = (string)json_user.GetValue("REALNAME"); en.REASON = json.Value <string>("REASON"); return(en); } catch { return(null); } }
/// <summary> /// 保存或更新数据 /// </summary> /// <param name="formdata"></param> public void save(string formdata) { string response = ""; string repeat = ""; JObject json = (JObject)JsonConvert.DeserializeObject(formdata); WEB_PAGECONFIG en = JsonToEntity(json); if (en == null) { repeat = "保存失败,JSON数据转换出现问题"; } else if (en.ID < 0) { //新增 repeat = CanUpdateOrInsert(en); if (string.IsNullOrEmpty(repeat)) { int i = AddConfig(en); if (i > 0) { repeat = "5";//代表成功 } } } else { //更新 repeat = CanUpdateOrInsert(en); if (string.IsNullOrEmpty(repeat)) { int i = UpdateConfig(en); if (i > 0) { repeat = "5";//代表成功 } } } response = "{\"success\":\"" + repeat + "\"}"; Response.Write(response); Response.End(); }
protected void Page_Load(object sender, EventArgs e) { parentid = Request["parentid"]; parentInfo = GetParentInfo(parentid); if (!IsPostBack) { string action = Request["action"]; iso.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; switch (action) { case "loadData": loadData(); break; case "save": save(Request["formdata"]); break; case "export": //export(); break; case "add": //ImportExcelData(); break; case "Ini_Base_Data": //Ini_Base_Data(); break; case "loadbasebusitype": GetBusitype(); break; case "loadbasebusidetail": GetBusiDetail(); break; case "loadbasecustomercode": GetCustomerCode(); break; case "loadparentinfo": GetParentInfoForSeach(); break; case "gettablename": GetTableName(); break; case "getfieldname": GetFieldName(); break; case "getorderno": GetOrderNo(); break; case "delete": Delete(); break; case "moveup": MoveUp(); break; case "movedown": MoveDown(); break; } } }