protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "assignDataToEdit") { int docID; var currentRow = ((LinkButton)e.CommandSource).NamingContainer as GridViewRow; var docIDField = (currentRow.FindControl("DocumentID") as TextBox); if (docIDField == null) { return; } if (string.IsNullOrEmpty(docIDField.Text)) { (e.CommandSource as LinkButton).CssClass = "findDoc"; return; } if (!int.TryParse(docIDField.Text, out docID)) { (e.CommandSource as LinkButton).CssClass = "notFoundDoc"; Session.Remove("assignedDocID"); return; } var ctx = new ESodaDataContext(); DataForCentralRegistry data = ctx.GetDataForCentralRegistry(docID).FirstOrDefault(); if (data == null) { (e.CommandSource as LinkButton).CssClass = "notFoundDoc"; Session.Remove("assignedDocID"); return; } var targetDateField = (currentRow.Cells[1].Visible) ? currentRow.Cells[1].Controls[0] as TextBox : null; var targetOrganizationalUnitField = (currentRow.Cells[5].Visible) ? currentRow.Cells[5].Controls[0] as TextBox : null; var targetReferenceNumberField = (currentRow.Cells[3].Visible) ? currentRow.Cells[3].Controls[0] as TextBox : null; if (targetDateField != null) { targetDateField.Text = data.ItemDate; } if (targetOrganizationalUnitField != null) { targetOrganizationalUnitField.Text = data.OrganizationalUnit; } if (targetReferenceNumberField != null) { targetReferenceNumberField.Text = data.ItemReferenceNumber; } Session["assignedDocID"] = docID; (e.CommandSource as LinkButton).CssClass = "foundDoc"; } }
protected void registryDS_Selecting(object sender, LinqDataSourceSelectEventArgs e) { var ctx = new ESodaDataContext(); var criteria = currentSearchCriteria; IQueryable <CentralRegistry> results; results = ctx.CentralRegistries .Where(r => r.RegistryTypeID.ToString() == (registryType.SelectedValue == "" ? "1" : registryType.SelectedValue)) .Where(r => r.RegistryYear.ToString() == registryYear.Text || string.IsNullOrEmpty(registryYear.Text)); if (registryOrder.SelectedValue == "asc") { results = results.OrderBy(r => r.PositionNumber); } else { results = results.OrderByDescending(r => r.PositionNumber); } if (criteria.AreEmpty) { e.Result = results; return; } if (criteria.PositionNumber > 0) { results = results.Where(r => r.PositionNumber == criteria.PositionNumber); } if (criteria.DateFrom.HasValue) { results = results.Where(r => r.ItemDate >= criteria.DateFrom.Value.Date); } if (criteria.DateTo.HasValue) { results = results.Where(r => r.ItemDate <= criteria.DateTo.Value.Date); } if (!string.IsNullOrEmpty(criteria.Side)) { results = results.Where(r => r.ItemSide.Contains(criteria.Side)); } if (!string.IsNullOrEmpty(criteria.Subject)) { results = results.Where(r => r.ItemSubject.Contains(criteria.Subject)); } if (!string.IsNullOrEmpty(criteria.ReferenceNumber)) { results = results.Where(r => r.ItemReferenceNumber.Contains(criteria.ReferenceNumber)); } if (!string.IsNullOrEmpty(criteria.OrganizationalUnit)) { results = results.Where(r => r.OrganizationalUnit.Contains(criteria.OrganizationalUnit)); } if (!string.IsNullOrEmpty(criteria.Remarks)) { results = results.Where(r => r.Remarks.Contains(criteria.Remarks)); } e.Result = results; }
protected void assignData(object sender, CommandEventArgs e) { var fv = (sender as Control).NamingContainer as FormView; int docID; var docIDField = (fv.FindControl("fDocumentID") as TextBox); var showDocLink = (fv.FindControl("showDocLink") as HyperLink); if (showDocLink != null) { showDocLink.NavigateUrl = ""; showDocLink.Visible = false; } if (docIDField == null) { return; } if (string.IsNullOrEmpty(docIDField.Text)) { (sender as LinkButton).CssClass = "findDoc"; return; } if (!int.TryParse(docIDField.Text, out docID)) { (sender as LinkButton).CssClass = "notFoundDoc"; Session.Remove("assignedDocID"); return; } var ctx = new ESodaDataContext(); DataForCentralRegistry data = ctx.GetDataForCentralRegistry(docID).FirstOrDefault(); if (data == null) { (sender as LinkButton).CssClass = "notFoundDoc"; Session.Remove("assignedDocID"); return; } if (showDocLink != null) { showDocLink.NavigateUrl = string.Format("~/Dokumenty/SkladnikiDokumentu.aspx?id={0}", docID); showDocLink.Visible = true; } var targetDateField = fv.FindControl("ItemDateTextBox") as TextBox; var targetOrganizationalUnitField = fv.FindControl("ItemOrganizationalUnitTextBox") as TextBox; var targetReferenceNumberField = fv.FindControl("ItemReferenceNumberTextBox") as TextBox; if (targetDateField != null) { targetDateField.Text = data.ItemDate; } if (targetOrganizationalUnitField != null) { targetOrganizationalUnitField.Text = data.OrganizationalUnit; } if (targetReferenceNumberField != null) { targetReferenceNumberField.Text = data.ItemReferenceNumber; } Session["assignedDocID"] = docID; (sender as LinkButton).CssClass = "foundDoc"; }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { UserDAO dao = new UserDAO(); var depts = dao.GetDepartments(); depts.RemoveAt(0); depts.Sort(delegate(SimpleLookupDTO d1, SimpleLookupDTO d2) { return(d1.Description.CompareTo(d2.Description)); } ); D1OUID.DataSource = depts; D1OUID.DataTextField = "description"; D1OUID.DataValueField = "ID"; D1OUID.DataBind(); D2OUID.DataSource = depts; D2OUID.DataTextField = "description"; D2OUID.DataValueField = "ID"; D2OUID.DataBind(); D3OUID.DataSource = depts; D3OUID.DataTextField = "description"; D3OUID.DataValueField = "ID"; D3OUID.DataBind(); D5OUID.DataSource = depts; D5OUID.DataTextField = "description"; D5OUID.DataValueField = "ID"; D5OUID.DataBind(); D6OUID.DataSource = depts; D6OUID.DataTextField = "description"; D6OUID.DataValueField = "ID"; D6OUID.DataBind(); var ctx = new ESodaDataContext(); var ouid = ctx.GetOrganizationalUnitID((Guid)Membership.GetUser().ProviderUserKey); D1OUID.SelectedValue = D2OUID.SelectedValue = D3OUID.SelectedValue = D5OUID.SelectedValue = D6OUID.SelectedValue = ouid.ToString(); if (Roles.IsUserInRole("Naczelnicy") && !Roles.IsUserInRole("Raporty")) { D1OUID.Enabled = D2OUID.Enabled = D3OUID.Enabled = D5OUID.Enabled = D6OUID.Enabled = false; } List <string> reportTypes = new List <string>(); reportTypes.Add("PDF"); reportTypes.Add("Excel"); D1ReportType.DataSource = reportTypes; D1ReportType.DataBind(); D2ReportType.DataSource = reportTypes; D2ReportType.DataBind(); D3ReportType.DataSource = reportTypes; D3ReportType.DataBind(); D4ReportType.DataSource = reportTypes; D4ReportType.DataBind(); D5ReportType.DataSource = reportTypes; D5ReportType.DataBind(); D6ReportType.DataSource = reportTypes; D6ReportType.DataBind(); } }