Wednesday, 1 April 2015

notes



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Notes.aspx.cs" Inherits="Client_Notes" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="../Content/css/style.css" rel="stylesheet" type="text/css" />
    <link id="icon" runat="server" rel="shortcut icon" href="~/Content/images/USA.ico" />
    <script src="../Content/js/jquery-latest.js"></script>
    <script src="../Content/js/script.js"></script>
    <script src="../Content/js/autoadvance.js"></script>
    <style type="text/css">
        body, td, th
        {
            color: #999;
        }
        .odd
        {
            border-left: 1px solid #F8F8F8;
            border-right: 1px solid #F8F8F8;
        }
        .even
        {
            background: #D6D6D6;
            border-left: 1px solid #F8F8F8;
            border-right: 1px solid #F8F8F8;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div align="center">
        <asp:GridView ID="CandNote" runat="server" AutoGenerateColumns="false" ShowFooter="true"
            ShowHeader="true" GridLines="None">
            <RowStyle CssClass="gvlines" />
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <div style="width: 600px; padding: 10px; height: auto; float: left; border: 1px solid #ddd;
                            color: #7CB40C; font-family: Verdana;">
                            <div style="float: left; width: 30px; text-align: center;">
                                S.NO</div>
                            <div style="float: left; width: 300px; padding-left: 80px; text-align: center;">
                                Note</div>
                            <div style="float: right; width: 100px; padding-right: 30px; text-align: left;">
                                File</div>
                        </div>
                    </HeaderTemplate>
                    <ItemTemplate>
                        <div style="width: 600px; padding: 10px; height: auto; float: left" class="<%# Container.DisplayIndex % 2 == 0 ? "even" : "odd" %>">
                            <div style="float: left; width: 30px; text-align: center; color: #000; font-family: Verdana">
                                <%# ((GridViewRow)Container).RowIndex + 1%></div>
                            <div style="float: right; width: 400px; text-align: left">
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("Note") %>' Style="font-family: Verdana;
                                    color: #000"></asp:Label></div>
                            <div style="float: right; width: 200px; text-align: left; vertical-align: super;">
                                <asp:LinkButton ID="lnkfile" runat="server" Text='<%# Eval("File") %>' Style="font-family: Verdana;"
                                    CommandArgument='<%# Eval("File") %>' OnClick="DownloadFile"></asp:LinkButton>
                            </div>
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
    <%--<asp:UpdatePanel runat="server">
        <ContentTemplate>--%>
            <div align="center">
                <div style="width: 500px;">
                    <div style="padding-top: 20px; width: 500px; float: left; padding-left: 10px">
                        <asp:TextBox ID="txtnote" TextMode="MultiLine" runat="server" CssClass="textbox"
                            Height="70px" Width="500px"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
                            ControlToValidate="txtnote" ValidationGroup="vg3" SetFocusOnError="True" ForeColor="Red"
                            meta:resourcekey="RequiredFieldValidator2Resource1" Display="None" /></div>
                    <div style="padding-top: 20px; width: 500px; float: left; padding-left: 10px">
                       <%-- <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>--%>

                                <asp:FileUpload ID="uploadfiles" runat="server" CssClass="textbx" />
                                <asp:Label ID="lblfup1Err" runat="server" Font-Size="Small" ForeColor="Red" meta:resourcekey="lblfup1ErrResource1"></asp:Label>
                                <asp:Button ID="btnupload" runat="server" Text="Upload" CssClass="button bigrounded small green"
                                    CommandName="Upload" OnClick="btnupload_Click" /><asp:HiddenField ID="hf" runat="server" />
                           <%-- </ContentTemplate>
                        </asp:UpdatePanel>--%>
                    </div>
                    <div style="margin-top: 20px; float: left; text-align: center; width: 500px">
                        <asp:Button ID="btnsubmit" runat="server" Text="Submit" CommandName="AddNew" CssClass="button bigrounded medium green"
                            ValidationGroup="vg3" OnClick="btnsubmit_Click" />
                        <asp:Button ID="btncancel" runat="server" Text="Cancel" CommandName="Cancel" CssClass="button bigrounded medium green"
                            OnClick="btncancel_Click" /></div>
                </div>
            </div>
     <%--   </ContentTemplate>
    </asp:UpdatePanel>--%>
    </form>
</body>
</html>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using iQmsoft.SD.Utils;
using System.Data;

public partial class Client_Notes : BasePage, INotes
{
    private ViewAquiredResultsPres _vPres;
    string folderPath = "../Content/images/Files/";
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        _vPres = new ViewAquiredResultsPres(this);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["CID"] != null)
            {
                int cid = Convert.ToInt16(Request.QueryString["CID"]);
                List<NotesDTO> dto = _vPres.getNotes(cid);
                if (dto.Count != 0)
                {
                    CandNote.DataSource = dto;
                    CandNote.DataBind();
                }
                else
                {
                    NotesDTO d = new NotesDTO();
                    dto.Add(d);
                    CandNote.DataSource = dto;
                    CandNote.DataBind();
                    int columncount = CandNote.Rows[0].Cells.Count;
                    CandNote.Rows[0].Cells.Clear();
                    CandNote.Rows[0].Cells.Add(new TableCell());
                    CandNote.Rows[0].Cells[0].ColumnSpan = columncount;
                    CandNote.Rows[0].Cells[0].Text = "No Notes Found";
                }
            }
        }
    }

  
    protected void btnupload_Click(object sender, EventArgs e)
    {
        string Img = null;
        if (!string.IsNullOrEmpty(uploadfiles.FileName))
        {
            string Extension = System.IO.Path.GetExtension(uploadfiles.FileName);
            if (Extension.ToLower() == ".txt" || Extension.ToLower() == ".doc" || Extension.ToLower() == ".csv")
            {

                Img = FileUtil.Uploadfile(uploadfiles, hf, Server.MapPath(folderPath));
                hf.Value = Img;
                lblfup1Err.Text = " ";
            }

            else
            {
                CulturePage page = new CulturePage();
                if (page.CurrentCulture == CulturePage.enUS || page.CurrentCulture == CulturePage.enGB)
                {
                    lblfup1Err.Text = "Invalid file format";
                }
                else if (page.CurrentCulture == CulturePage.ptBR)
                {
                    lblfup1Err.Text = "Formato de ficheiro inválido";
                }
                else if (page.CurrentCulture == CulturePage.esES)
                {
                    lblfup1Err.Text = "Formato de archivo no válido";
                }
            }
        }
        else
        {
            CulturePage page = new CulturePage();
            if (page.CurrentCulture == CulturePage.enUS || page.CurrentCulture == CulturePage.enGB)

                lblfup1Err.Text = "Browse file to upload";

            else if (page.CurrentCulture == CulturePage.ptBR)

                lblfup1Err.Text = "Pesquisar ficheiro para carregar";

            else if (page.CurrentCulture == CulturePage.esES)

                lblfup1Err.Text = "Vaya archivo para cargar";


        }
    }
    protected void btncancel_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closescript", "<script language='javascript'>window.opener.focus();window.opener.__doPostBack(); window.close();</script>", false);
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {              
            int cid = Convert.ToInt16(Request.QueryString["CID"]);
            _vPres.SaveNote(cid, txtnote.Text,hf.Value);
            //    Response.Write("<script>javascript:window.close()</script>");
            ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closescript", "<script language='javascript'>window.opener.focus();window.opener.__doPostBack(); window.close();</script>", false);
      
    }

    protected void DownloadFile(object sender, EventArgs e)
    {
        string file = Convert.ToString(((LinkButton)sender).CommandArgument);
        string resumepath = "../Content/images/Files/" + file;
        if (!string.IsNullOrEmpty(file))
            FileUtil.DownloadFile(resumepath, true);
    }
}

No comments:

Post a Comment