void SetBackImg() { string sBackImg = Request["BackImg"]; if (string.IsNullOrEmpty(sBackImg)) { return; } CUser user = (CUser)Session["User"]; CDesktop desktop = (CDesktop)user.DesktopMgr.GetFirstObj(); if (desktop == null) { desktop = new CDesktop(); desktop.Ctx = Global.GetCtx(); desktop.B_User_id = user.Id; desktop.Creator = user.Id; user.DesktopMgr.AddNew(desktop); } else { desktop.Updator = user.Id; user.DesktopMgr.Update(desktop); } desktop.BackImg = sBackImg; if (!user.DesktopMgr.Save(true)) { Response.Write("保存失败!"); return; } m_sBackImg = string.Format("../{0}/DesktopImg/{1}", Global.GetDesktopIconPathName(), desktop.BackImg); }
private void MenuItemBackground_Click(object sender, EventArgs e) { SelBgForm frm = new SelBgForm(); if (frm.ShowDialog() != DialogResult.OK) { return; } CDesktop desktop = (CDesktop)Program.User.DesktopMgr.GetFirstObj(); if (desktop == null) { desktop = new CDesktop(); desktop.Ctx = Program.Ctx; desktop.B_User_id = Program.User.Id; Program.User.DesktopMgr.AddNew(desktop); } FileInfo fi = new FileInfo(frm.m_sBgUrl); desktop.BackImg = fi.Name; if (!Program.User.DesktopMgr.Save(true)) { MessageBox.Show("保存失败!"); return; } this.flowLayoutPanel.BackgroundImage = Image.FromFile(frm.m_sBgUrl); }
protected void Page_Load(object sender, EventArgs e) { if (Session["User"] == null) { //Response.Redirect("../Login.aspx"); //Response.End(); return; } m_DesktopGroupMgr = Global.GetCtx(Session["TopCompany"].ToString()).DesktopGroupMgr; string GroupId = Request["GroupId"]; if (!string.IsNullOrEmpty(GroupId)) { m_guidCurGroupId = new Guid(GroupId); m_CurGroup = (CDesktopGroup)m_DesktopGroupMgr.Find(m_guidCurGroupId); } if (Request.Params["Action"] == "DelDesktopApp") { DelDesktopApp(); Response.End(); } else if (Request.Params["Action"] == "SetBackImg") { SetBackImg(); Response.End(); } else if (Request.Params["Action"] == "UpdateOnlineState") { UpdateOnlineState(); Response.End(); } //桌面背景 m_sBackImg = string.Format("../{0}/DesktopImg/default.jpg", Global.GetDesktopIconPathName()); CUser user = (CUser)Session["User"]; m_Company = (CCompany)Global.GetCtx(Session["TopCompany"].ToString()).CompanyMgr.Find(user.B_Company_id); CDesktop desktop = (CDesktop)user.DesktopMgr.GetFirstObj(); if (desktop != null && desktop.BackImg != "") { m_sBackImg = string.Format("../{0}/DesktopImg/{1}", Global.GetDesktopIconPathName(), desktop.BackImg); } m_UserMenuMgr = user.UserMenuMgr; m_DesktopAppMgr = user.DesktopAppMgr; }
void LoadDesktop() { string sBackImg = Application.StartupPath + "\\DesktopImg\\default.jpg"; CDesktop desktop = (CDesktop)Program.User.DesktopMgr.GetFirstObj(); if (desktop != null && desktop.BackImg != "") { sBackImg = Application.StartupPath + "\\DesktopImg\\" + desktop.BackImg; } if (File.Exists(sBackImg)) { this.BackgroundImage = Image.FromFile(sBackImg); } }