Example #1
0
        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";
            }
        }
Example #2
0
        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";
        }