private void dgUserStubs_Delete(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int StubId = int.Parse(e.Item.Cells[0].Text); WebStubs.Delete(StubId); BindDGUser(); }
protected void btnSubmit_Click(object sender, System.EventArgs e) { byte[] Icon = null; bool OpenInBrowser = false; if (lstOpenWindow.SelectedIndex == 0) { OpenInBrowser = true; } if (txtIcon.PostedFile != null && txtIcon.PostedFile.ContentLength > 0) { Icon = new byte[txtIcon.PostedFile.ContentLength]; txtIcon.PostedFile.InputStream.Read(Icon, 0, txtIcon.PostedFile.ContentLength); } ArrayList grp = new ArrayList(); string sGroups = iGroups.Value; while (sGroups.Length > 0) { grp.Add(Int32.Parse(sGroups.Substring(0, sGroups.IndexOf(",")))); sGroups = sGroups.Remove(0, sGroups.IndexOf(",") + 1); } if (StubID == 0) { if (Request["Group"] == "1") { WebStubs.CreateGroupStub(txtShort.Text, txtTitle.Text, txtUrl.Text, OpenInBrowser, int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), Icon, grp); } else { WebStubs.CreateUserStub(txtShort.Text, txtTitle.Text, txtUrl.Text, OpenInBrowser, int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), Icon); } } else if (Request["Group"] == "1") { WebStubs.UpdateGroupStub(StubID, txtShort.Text, txtTitle.Text, txtUrl.Text, OpenInBrowser, int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), Icon, grp, DeleteIconCheckBox.Checked); } else { WebStubs.UpdateUserStub(StubID, txtShort.Text, txtTitle.Text, txtUrl.Text, OpenInBrowser, int.Parse(txtWidth.Text), int.Parse(txtHeight.Text), Icon, DeleteIconCheckBox.Checked); } if (Request["Group"] == "1") { Response.Redirect("~/Admin/WebStubs.aspx"); } else { Response.Redirect("~/Directory/UserWebApps.aspx"); } }
private void BindSavedValues() { using (IDataReader rdr = WebStubs.GetStub(StubID)) { if (rdr.Read()) { txtTitle.Text = (string)rdr["ToolTip"]; txtUrl.Text = (string)rdr["Url"]; txtShort.Text = ((string)rdr["Abbreviation"]).Trim(); if ((int)rdr["HasIcon"] != 0) { imgIcon.Src = Page.ResolveUrl("~/Common/WebStub.aspx") + "?StubId=" + StubID; imgIcon.Style["display"] = ""; DeleteIconCheckBox.Visible = true; } else { lblShort.Text = (string)rdr["Abbreviation"]; lblShort.Style["display"] = ""; DeleteIconCheckBox.Visible = false; } if ((bool)rdr["OpenInBrowser"]) { lstOpenWindow.SelectedIndex = 0; txtWidth.Enabled = false; txtHeight.Enabled = false; } else { lstOpenWindow.SelectedIndex = 1; txtWidth.Enabled = true; txtHeight.Enabled = true; } txtWidth.Text = rdr["Width"].ToString(); txtHeight.Text = rdr["Height"].ToString(); } } using (IDataReader reader = WebStubs.GetListGroupsByStub(StubID)) { while (reader.Read()) { lbSelectedGroups.Items.Add(new ListItem(CommonHelper.GetResFileString(reader["GroupName"].ToString()), reader["GroupId"].ToString())); } } for (int i = 0; i < lbSelectedGroups.Items.Count; i++) { if (lbAvailableGroups.Items.FindByValue(lbSelectedGroups.Items[i].Value) != null) { lbAvailableGroups.Items.Remove(lbAvailableGroups.Items.FindByValue(lbSelectedGroups.Items[i].Value)); } iGroups.Value += lbSelectedGroups.Items[i].Value + ","; } }
private void BindDG() { dgStubs.Columns[1].HeaderText = LocRM.GetString("Icon"); dgStubs.Columns[2].HeaderText = LocRM.GetString("Title"); dgStubs.Columns[3].HeaderText = LocRM.GetString("Url"); dgStubs.Columns[4].HeaderText = LocRM.GetString("Groups"); dgStubs.Columns[5].HeaderText = LocRM.GetString("Status"); dgStubs.Columns[6].HeaderText = LocRM.GetString("Options"); dgStubs.DataSource = WebStubs.GetListGroupStubsForUser(); dgStubs.DataBind(); }
private void dgStubs_update(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { int StubID = int.Parse(e.Item.Cells[0].Text); if ((string)e.CommandArgument == "1") { WebStubs.Hide(StubID); } else { WebStubs.Show(StubID); } BindDG(); }
protected string GetGroups(int StubId) { StringBuilder sb = new StringBuilder(); using (IDataReader rdr = WebStubs.GetListGroupsByStub(StubId)) { while (rdr.Read()) { sb.Append(CommonHelper.GetGroupLink((int)rdr["GroupId"], CommonHelper.GetResFileString((string)rdr["GroupName"]))); sb.Append("<br>"); } } return(sb.ToString()); }
private void BindDGUser() { dgUserStubs.Columns[1].HeaderText = LocRM.GetString("Icon"); dgUserStubs.Columns[2].HeaderText = LocRM.GetString("Title"); dgUserStubs.Columns[3].HeaderText = LocRM.GetString("Url"); dgUserStubs.Columns[4].HeaderText = LocRM.GetString("Options"); dgUserStubs.DataSource = WebStubs.GetListStubsForUser(); dgUserStubs.DataBind(); foreach (DataGridItem dgi in dgUserStubs.Items) { ImageButton ib = (ImageButton)dgi.FindControl("ibDelete"); if (ib != null) { ib.Attributes.Add("onclick", "return confirm('" + LocRM.GetString("Warning") + "')"); } } }
protected void Page_Load(object sender, System.EventArgs e) { Response.ContentType = "image/jpeg"; int bufferSize = 100; byte[] outbyte = new byte[bufferSize]; long retVal; long startIndex = 0; using (IDataReader reader = WebStubs.GetStubIcon(StubID)) { if (reader.Read()) { startIndex = 0; retVal = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize); if (retVal == 0) { Response.Redirect("../layouts/images/blank.gif", true); } Stream stream = Response.OutputStream; while (retVal == bufferSize) { stream.Write(outbyte, 0, bufferSize); startIndex += bufferSize; retVal = reader.GetBytes(0, startIndex, outbyte, 0, bufferSize); } stream.Write(outbyte, 0, System.Convert.ToInt32(retVal)); } else { Response.Redirect("../layouts/images/blank.gif", true); } } }