public void UpdateMenu(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); string UpdateSQL = ""; SFCDB.BeginTrain(); try { string m_name = Data["MENU_NAME"].ToString(); string m_desc = Data["MENU_DESC"].ToString(); string m_emp = Data["EDIT_EMP"].ToString(); string m_id = Data["ID"].ToString(); rcm = tcm.getC_MenubyID(m_id, SFCDB); rcm.MENU_NAME = m_name; rcm.PAGE_PATH = Data["PAGE_PATH"].ToString(); rcm.STYLE_NAME = Data["STYLE_NAME"].ToString(); rcm.CLASS_NAME = Data["CLASS_NAME"].ToString(); rcm.LANGUAGE_ID = Data["LANGUAGE_ID"].ToString(); rcm.MENU_DESC = m_desc; rcm.EDIT_TIME = DateTime.Now; rcm.EDIT_EMP = m_emp; UpdateSQL += rcm.GetUpdateString(this.DBTYPE) + ";\n"; MESDataObject.Module.T_C_PRIVILEGE tcp = new MESDataObject.Module.T_C_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_PRIVILEGE rcp = (MESDataObject.Module.Row_C_PRIVILEGE)tcp.NewRow(); rcp = tcp.getC_PrivilegebyMenuID(m_id, SFCDB); rcp.PRIVILEGE_NAME = m_name; rcp.PRIVILEGE_DESC = m_desc; rcp.EDIT_TIME = DateTime.Now; rcp.EDIT_EMP = m_emp; UpdateSQL += rcp.GetUpdateString(this.DBTYPE) + ";\n"; SFCDB.ExecSQL("Begin\n" + UpdateSQL + "End;"); SFCDB.CommitTrain(); this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "编辑菜單成功!!"; } catch (Exception ex) { SFCDB.RollbackTrain(); this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "编辑菜單失敗!!"; StationReturn.Data = ex.Message.ToString(); } }
public void DeletetMenu(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); string ID = Data["ID"].ToString(); string deleteSQL = ""; SFCDB.BeginTrain(); try { if (tcm.Check_PARENT(ID, SFCDB)) { rcm = tcm.getC_MenubyID(ID, SFCDB); deleteSQL += rcm.GetDeleteString(this.DBTYPE) + ";\n"; MESDataObject.Module.T_C_PRIVILEGE tcp = new MESDataObject.Module.T_C_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_PRIVILEGE rcp = (MESDataObject.Module.Row_C_PRIVILEGE)tcp.NewRow(); rcp = tcp.getC_PrivilegebyMenuID(ID, SFCDB); deleteSQL += rcp.GetDeleteString(this.DBTYPE) + ";\n"; SFCDB.ExecSQL("Begin\n" + deleteSQL + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "刪除菜單及其權限成功!!!"; StationReturn.Data = ID; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "要刪除的菜單存在子菜單!!不可刪除!"; } this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { SFCDB.RollbackTrain(); this.DBPools["SFCDB"].Return(SFCDB); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "刪除菜單失敗!"; StationReturn.Data = ex.Message.ToString(); } }
public void OrderbyMenu(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); string PARENTID = Data["PARENTID"].ToString(); int index = 10; string sql = ""; SFCDB.BeginTrain(); try { MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); foreach (string item in Data["MENUIDS"]) { rcm = tcm.getC_MenubyIDandPARENT(item.Trim('\'').Trim('\"'), PARENTID, SFCDB); if (rcm != null) { rcm.SORT = index; sql += rcm.GetUpdateString(this.DBTYPE) + ";\n"; index += 10; } } SFCDB.ExecSQL("Begin\n" + sql + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "排序菜单信息成功!"; this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { SFCDB.RollbackTrain(); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "排序菜单信息失败!"; StationReturn.Data = ex.Message.ToString(); this.DBPools["SFCDB"].Return(SFCDB); } }
public void CreatMenu(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); string m_name = Data["MENU_NAME"].ToString(); string m_desc = Data["MENU_DESC"].ToString(); string m_emp = Data["EDIT_EMP"].ToString(); string PARENT_CODE = Data["PARENT_CODE"].ToString(); string UpdateSQL = ""; SFCDB.BeginTrain(); try { if (tcm.Check_MENU_NAME(m_name, SFCDB)) { string m_id = tcm.GetNewID(BU, SFCDB); Dictionary <string, string> id = new Dictionary <string, string>(); id.Add("ID", m_id); rcm.ID = m_id; rcm.SYSTEM_NAME = SystemName; rcm.MENU_NAME = m_name; rcm.PAGE_PATH = Data["PAGE_PATH"].ToString(); rcm.PARENT_CODE = PARENT_CODE; rcm.SORT = tcm.GetmaxSORT(PARENT_CODE, SFCDB); rcm.STYLE_NAME = Data["STYLE_NAME"].ToString(); rcm.CLASS_NAME = Data["CLASS_NAME"].ToString(); rcm.LANGUAGE_ID = Data["LANGUAGE_ID"].ToString(); rcm.MENU_DESC = m_desc; rcm.EDIT_TIME = DateTime.Now; rcm.EDIT_EMP = m_emp; UpdateSQL += rcm.GetInsertString(this.DBTYPE) + ";\n"; MESDataObject.Module.T_C_PRIVILEGE tcp = new MESDataObject.Module.T_C_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_PRIVILEGE rcp = (MESDataObject.Module.Row_C_PRIVILEGE)tcp.NewRow(); rcp.ID = tcp.GetNewID(BU, SFCDB); rcp.MENU_ID = m_id; rcp.SYSTEM_NAME = SystemName; rcp.PRIVILEGE_NAME = m_name; rcp.PRIVILEGE_DESC = m_desc; rcp.EDIT_TIME = DateTime.Now; rcp.EDIT_EMP = m_emp; rcp.BASECONFIG_FLAG = "Y"; UpdateSQL += rcp.GetInsertString(this.DBTYPE) + ";\n"; SFCDB.ExecSQL("Begin\n" + UpdateSQL + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "添加菜單成功!!!"; StationReturn.Data = id; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "要建立的菜單已經存在!!"; } this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { this.DBPools["SFCDB"].Return(SFCDB); SFCDB.RollbackTrain(); StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "建立菜單失敗!"; StationReturn.Data = ex.Message.ToString(); } }
public void CreatUserPrivilege(Newtonsoft.Json.Linq.JObject requestValue, Newtonsoft.Json.Linq.JObject Data, MESStationReturn StationReturn) { MESDBHelper.OleExec SFCDB = _DBPools["SFCDB"].Borrow(); string GEMP_NO = Data["GEMP_NO"].ToString().ToUpper(); string SEMP_NO = Data["SEMP_NO"].ToString().ToUpper(); string EMP_ID = "", P_code = ""; SFCDB.BeginTrain(); try { MESDataObject.Module.T_c_user GetInformation = new MESDataObject.Module.T_c_user(SFCDB, this.DBTYPE); MESDataObject.Module.T_C_USER_PRIVILEGE tcup = new MESDataObject.Module.T_C_USER_PRIVILEGE(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_USER_PRIVILEGE rcup = (MESDataObject.Module.Row_C_USER_PRIVILEGE)tcup.NewRow(); MESDataObject.Module.T_C_MENU tcm = new MESDataObject.Module.T_C_MENU(SFCDB, this.DBTYPE); MESDataObject.Module.Row_C_MENU rcm = (MESDataObject.Module.Row_C_MENU)tcm.NewRow(); DataTable dt = GetInformation.SelectC_Userbyempno(SEMP_NO, SFCDB, this.DBTYPE); EMP_ID = dt.Rows[0]["ID"].ToString(); string insql = ""; if (dt.Rows.Count > 0) { foreach (string item in Data["ID_ITEMS"]) { string p_id = item.Trim('\'').Trim('\"'); rcup.ID = tcup.GetNewID(BU, SFCDB); rcup.SYSTEM_NAME = SystemName; rcup.USER_ID = EMP_ID; rcup.PRIVILEGE_ID = p_id; rcup.EDIT_EMP = GEMP_NO; rcup.EDIT_TIME = DateTime.Now; insql += rcup.GetInsertString(this.DBTYPE) + ";\n"; P_code += p_id + ","; do { rcm = tcm.getC_MenubyID(p_id, SFCDB); if (rcm.PARENT_CODE != "0") { p_id = rcm.PARENT_CODE; if (P_code.IndexOf(rcm.PARENT_CODE) < 0 && tcup.getC_PrivilegebyIDemp(rcm.PARENT_CODE, SEMP_NO, SFCDB) == null) { rcup.ID = tcup.GetNewID(BU, SFCDB); rcup.SYSTEM_NAME = SystemName; rcup.USER_ID = EMP_ID; rcup.PRIVILEGE_ID = rcm.PARENT_CODE; rcup.EDIT_EMP = GEMP_NO; rcup.EDIT_TIME = DateTime.Now; insql += rcup.GetInsertString(this.DBTYPE) + ";\n"; P_code += rcm.PARENT_CODE + ","; } } } while (rcm.PARENT_CODE != "0"); } SFCDB.ExecSQL("Begin\n" + insql + "End;"); SFCDB.CommitTrain(); StationReturn.Status = StationReturnStatusValue.Pass; StationReturn.Message = "保存成功!!"; } else { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "找不到用戶信息!"; StationReturn.Data = ""; } this.DBPools["SFCDB"].Return(SFCDB); } catch (Exception ex) { StationReturn.Status = StationReturnStatusValue.Fail; StationReturn.Message = "刪權限失敗!!"; StationReturn.Data = ex.Message.ToString(); this.DBPools["SFCDB"].Return(SFCDB); } }