Пример #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     clsSpeedo.Authenticate();
     if (!Page.IsPostBack)
     {
         clsCRS crs = new clsCRS();
         txtCrseCode.Text = Request.QueryString["crsecode"].ToString();
         using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Speedo"].ToString()))
         {
             SqlCommand cmd = cn.CreateCommand();
             cmd.CommandText = "SELECT crsettle,yearterm,currcode,datecomp,ordernum,pstatus FROM CM.CrsDetails WHERE crscode='" + Request.QueryString["crscode"] + "' AND crsecode='" + Request.QueryString["crsecode"] + "'";
             cn.Open();
             SqlDataReader dr = cmd.ExecuteReader();
             dr.Read();
             txtCrseTtle.Text     = dr["crsettle"].ToString();
             txtYearTerm.Text     = dr["yearterm"].ToString();
             txtAvailability.Text = clsCRS.ToCAStatusDesc(clsCRS.GetCAStatus(txtCrseCode.Text));
             txtNoReq.Text        = dr["ordernum"].ToString();
             txtStatus.Text       = clsCRS.ToCrsDetailsStatusDesc(dr["pstatus"].ToString());
             dr.Close();
         }
     }
 }
Пример #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        clsSpeedo.Authenticate();

        if (!Page.IsPostBack)
        {
            clsCRS.AuthenticateUser(clsCRS.CRSUserType.CoursewareCoordinator, Request.Cookies["Speedo"]["UserName"], Request.QueryString["crscode"]);

            bool blnReadOnly = true;
            txtCrsCode.Text = Request.QueryString["crscode"].ToString();
            txtCCName.Text  = clsUsers.GetName(Request.Cookies["Speedo"]["UserName"]);
            clsCRS crs = new clsCRS(txtCrsCode.Text);
            crs.Load();
            txtDateReq.Text = crs.DateRequested.ToString();
            txtRemarks.Text = crs.Remarks;
            txtCMHRem.Text  = crs.ChannelManagerHeadRemarks;
            txtCCRem.Text   = crs.CoursewareCoordinatorRemarks;

            txtCMName.Text   = clsUsers.GetName(crs.ChannelManager);
            txtCMHName.Text  = clsUsers.GetName(crs.ChannelManagerHead);
            txtSchlName.Text = clsSchool.GetSchoolName(crs.SchoolCode);

            DataTable tblAttachment = new DataTable();
            using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Speedo"].ToString()))
            {
                SqlCommand cmd = cn.CreateCommand();
                cmd.CommandText = "SELECT crsecode FROM CM.CrsDetails WHERE crscode='" + Request.QueryString["crscode"] + "' AND (pstatus='E' OR pstatus='P')";
                cn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                blnReadOnly = !dr.Read();
                dr.Close();

                cmd.CommandText = "SELECT filename,details,filecont FROM CM.CrsAttachment WHERE crscode='" + Request.QueryString["crscode"] + "'";
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(tblAttachment);
            }

            string strWrite   = "";
            string strPicture = "";
            foreach (DataRow drow in tblAttachment.Rows)
            {
                if (!File.Exists(Server.MapPath("~/UploadedFiles/CRS/") + drow["filename"]))
                {
                    Byte[] bytAttachment;
                    bytAttachment = drow["filecont"] as Byte[];

                    FileStream fsAttachment = new FileStream(Server.MapPath("~/UploadedFiles/CRS/") + drow["filename"], FileMode.OpenOrCreate, FileAccess.Write);
                    fsAttachment.Write(bytAttachment, 0, bytAttachment.Length);
                    fsAttachment.Close();
                }

                switch (Path.GetExtension(drow["filename"].ToString()).ToLower())
                {
                case ".jpg":
                case ".jpeg":
                    strPicture = "fsview22.png";
                    break;

                case ".doc":
                    strPicture = "word22.png";
                    break;

                case ".xls":
                    strPicture = "excel22.png";
                    break;

                case ".pdf":
                    strPicture = "pdf22.png";
                    break;

                default:
                    strPicture = "star22.png";
                    break;
                }

                strWrite += "<tr>" +
                            "<td><img src='../../Support/" + strPicture + "' /></td>" +
                            "<td>&nbsp;<a href='../../UploadedFiles/CRS/" + drow["filename"] + "' target='_blank'>" + drow["details"] + " [" + drow["filename"] + "]</a></td>" +
                            "</tr>";
            }
            if (strWrite != "")
            {
                lblAttachments.Text = "<table cellpadding='2'>" + strWrite + "</table>";
            }

            divButton.Visible = !blnReadOnly;
            txtCCRem.ReadOnly = blnReadOnly;
            if (blnReadOnly)
            {
                txtCCRem.BackColor = System.Drawing.Color.FromName("#f0f8ff");
            }
        }
    }