protected void Btn_LicenseUpdate_Click(object sender, EventArgs e) { string access = ""; string page_project_access = ""; string[] modulename = Utility.Unitlist.ModuleList(); string dbname = DAL.SuperSystemManage.Get_dbname_by_CompanyID(int.Parse(DDL_Company.SelectedValue)); string[] projectcode_name = DAL.SystemManage.Get_ProjectName_Code_New(dbname); string[] project_code = projectcode_name[0].Split(','); string[] project_name = projectcode_name[1].Split(','); int UID = int.Parse(DDL_User.SelectedValue); string[] page = new string[2]; string[] PPA = DAL.SystemManage.Get_ProjectCodePageID_Access_by_UserID(dbname, UID); string[] PPAparta = PPA[1].Split(','); string[] PPApartb = PPA[0].Split(','); string[] PPAlist = new string[PPAparta.Length]; for (int i = 0; i < PPAparta.Length; i++) { PPAlist[i] = PPAparta[i] + "_" + PPApartb[i]; } string[] page_id = new string[2]; string[] main_page = DAL.SystemManage.Get_Page_ID_by_Module(dbname, "Main"); string[] main_list = main_page[0].Split(','); string[] main_id = main_page[1].Split(','); int main_search = -1; CheckBox CB = new CheckBox(); CheckBox CBP = new CheckBox(); for (int i = 0; i < modulename.Length; i++) { CB = (CheckBox)PH_Access.FindControl("CB" + i.ToString()); if (CB.Checked) { access += CB.ID.Substring(2) + ","; } page = DAL.SystemManage.Get_Page_ID_by_Module(dbname, modulename[i]); if (page[0] == "") { main_search = Array.IndexOf(main_list, modulename[i]); if (main_search >= 0) { for (int j = 0; j < project_code.Length; j++) { CBP = (CheckBox)PH_Access.FindControl("CBP" + i.ToString() + "_" + main_id[main_search] + "_" + project_code[j]); if (CBP != null) { if (CBP.Checked) { page_project_access += main_id[main_search] + "," + project_code[j] + ","; } } } } } else { string[] pagelist = page[0].Split(','); string[] idlist = page[1].Split(','); for (int k = 0; k < idlist.Length; k++) { for (int j = 0; j < project_code.Length; j++) { CBP = (CheckBox)PH_Access.FindControl("CBP" + i.ToString() + "_" + idlist[k] + "_" + project_code[j]); if (CBP != null) { if (CBP.Checked) { page_project_access += idlist[k] + "," + project_code[j] + ","; } } } } } } if (access.Length != 0) { access = access.Substring(0, access.Length - 1); } if (page_project_access.Length != 0) { page_project_access = page_project_access.Substring(0, page_project_access.Length - 1); } bool result = DAL.SystemManage.Update_Module_Access(dbname, UID, access); //bool result2 = DAL.SystemManage.Update_UPP_Access(Session["DatabaseName"].ToString(), UID, page_project_access); bool result2 = DAL.SystemManage.Update_UPP_Access_New(dbname, UID, page_project_access); result = result & result2; if (result) { Response.Write("<script>alert('更新成功');location.href='SystemManage.aspx';</script>"); } else { Response.Write("<script>alert('更新失敗');location.href='SystemManage.aspx';</script>"); } }
protected void Btn_LicenseUpdate_Click(object sender, EventArgs e) { string access = ""; string page_project_access = ""; int UID = 0; int PID = 0; //string[] modulename = Utility.Unitlist.ModuleList(); string[] modulename = Utility.Unitlist.ModuleListNew(); string[] projectcode_name = DAL.SystemManage.Get_ProjectName_Code_New(Session["DatabaseName"].ToString()); if (projectcode_name[0] != null && projectcode_name[1] != null) { string[] project_code = projectcode_name[0].Split(','); string[] project_name = projectcode_name[1].Split(','); } if (DDL_UserSelect.SelectedValue != "") { UID = int.Parse(DDL_UserSelect.SelectedValue); } if (DDL_Project.SelectedValue != "") { PID = int.Parse(DDL_Project.SelectedValue); } string[] page = new string[2]; CheckBox CB = new CheckBox(); CheckBox CBP = new CheckBox(); for (int i = 0; i < modulename.Length; i++) { CB = (CheckBox)PH_Access.FindControl("CB" + i.ToString()); if (CB.Checked) { access += CB.ID.Substring(2) + ","; } page = DAL.SystemManage.Get_Page_ID_by_Module(Session["DatabaseName"].ToString(), modulename[i]); if (page[0] == "") { } else { string[] pagelist = page[0].Split(','); string[] idlist = page[1].Split(','); for (int k = 0; k < idlist.Length; k++) { CBP = (CheckBox)PH_Access.FindControl("CBP" + i.ToString() + "_" + idlist[k] + "_" + PID.ToString()); if (CBP != null) { if (CBP.Checked) { page_project_access += idlist[k] + ","; } } } } } if (access.Length != 0) { access = access.Substring(0, access.Length - 1); } if (page_project_access.Length != 0) { page_project_access = page_project_access.Substring(0, page_project_access.Length - 1); } bool result = DAL.SystemManage.Update_Module_Access(Session["DatabaseName"].ToString(), UID, access); bool result2 = DAL.SystemManage.Update_UPP_Access_New2(Session["DatabaseName"].ToString(), UID, PID, page_project_access); result = result & result2; if (result) { Response.Write("<script>alert('更新成功');</script>"); } else { Response.Write("<script>alert('更新失敗');</script>"); } }