private void DisplayCartItems()
        {
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            amount                    = 0;
            discountedAmount          = 0;
            gvShoppingCart.DataSource = null;
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Author", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));
            dt.Columns.Add(new DataColumn("Type", typeof(string)));
            dt.Columns.Add(new DataColumn("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("", typeof(Control)));
            dt.Columns.Add(new DataColumn("Path", typeof(string)));
            dt.Columns.Add(new DataColumn("DocumentID", typeof(string)));
            if (Session["DocList"] != null)
            {
                docIDList = (List <int>)Session["DocList"];
                foreach (int docID in docIDList)
                {
                    DocumentDetails doc = docBLObj.GetDocumentByID(docID);
                    DataRow         dr  = dt.NewRow();
                    dr["Title"]       = doc.Title;
                    dr["Author"]      = doc.Author;
                    dr["Type"]        = docBLObj.GetDocumentTypeBL(doc.DocumentTypeID);
                    dr["Description"] = doc.DocumentDescription;
                    dr["Path"]        = doc.DocumentPath;
                    dr["Price"]       = doc.Price;
                    dr["DocumentID"]  = doc.DocumentID;
                    dt.Rows.Add(dr);
                    amount           += doc.Price;
                    discountedAmount += .8 * doc.Price;
                }
            }
            gvShoppingCart.DataSource = dt;
            gvShoppingCart.DataBind();
            lblTotalAmountDisplay.Text = amount.ToString();
            lblDiscountAvail.Text      = discountedAmount.ToString();
        }
Ejemplo n.º 2
0
        protected void cbnDocumentID_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList       cb       = (DropDownList)sender;
            DocumentDetails    docObj   = null;
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            try
            {
                if (cb.SelectedIndex == -1)
                {
                    throw new ELibraryException("Please select Document ID");
                }
                docObj = docBLObj.GetDocumentByID(Convert.ToInt32(cb.SelectedValue));
                if (docObj == null)
                {
                    throw new ELibraryException("Document doesnt exist");
                }

                txtDocumentName.Text = docObj.DocumentName;
                txtDescription.Text  = docObj.DocumentDescription;

                txtTitle.Text  = docObj.Title;
                txtAuthor.Text = docObj.Author;
                cboDocumentType.SelectedValue = docBLObj.GetDocumentTypeBL(docObj.DocumentTypeID).ToString();
                cboDiscipline.SelectedValue   = docBLObj.GetDisciplineNameBL(docObj.DisciplineID);


                txtPrice.Text = docObj.Price.ToString();
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
            }
        }
        protected void btnFilter_Click(object sender, EventArgs e)
        {
            gvGlance.DataSource = null;
            lblDisplay.Text     = "";
            List <DocumentDetails> documentList = new List <DocumentDetails>();
            ELibraryDocumentBL     docBL        = new ELibraryDocumentBL();
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Author", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));
            dt.Columns.Add(new DataColumn("Type", typeof(string)));
            dt.Columns.Add(new DataColumn("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("", typeof(Control)));
            dt.Columns.Add(new DataColumn("Path", typeof(string)));
            dt.Columns.Add(new DataColumn("DocumentID", typeof(string)));

            try
            {
                int itemsSelected = 0;
                foreach (ListItem li in chklasideBar.Items)
                {
                    if (li.Selected)
                    {
                        itemsSelected = itemsSelected + 1;
                    }
                }
                if (itemsSelected == 0)
                {
                    throw new ELibraryException("Please select a check box");
                }
                for (int i = 0; i < chklasideBar.Items.Count; i++)
                {
                    List <DocumentDetails> documentDiscList = null;

                    if (chklasideBar.Items[i].Selected)
                    {
                        documentDiscList = null;
                        string discipline = chklasideBar.Items[i].Text;
                        documentDiscList = docBL.ViewDocumentsByDisciplineBL(discipline);
                        if (documentDiscList != null)
                        {
                            foreach (DocumentDetails doc in documentDiscList)
                            {
                                documentList.Add(doc);
                            }
                        }
                    }
                }
                if (documentList.Count > 0)
                {
                    foreach (DocumentDetails doc in documentList)
                    {
                        DataRow dr = dt.NewRow();
                        dr["Title"]       = doc.Title;
                        dr["Author"]      = doc.Author;
                        dr["Type"]        = docBL.GetDocumentTypeBL(doc.DocumentTypeID);
                        dr["Description"] = doc.DocumentDescription;
                        dr["Path"]        = doc.DocumentPath;
                        dr["Price"]       = doc.Price;
                        dr["DocumentID"]  = doc.DocumentID;
                        dt.Rows.Add(dr);
                    }
                    gvGlance.DataSource = dt;
                    gvGlance.DataBind();
                }
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select atleast one checkbox')", true);
            }
            catch (Exception ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
            }
        }
Ejemplo n.º 4
0
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            ELibraryDocumentBL     docBL        = new ELibraryDocumentBL();
            List <DocumentDetails> documentList = null;

            try
            {
                if (cboSearchBy.SelectedItem.Text == "Name")
                {
                    gvSearch.DataSource = null;
                    string name = txtName.Text;
                    if (name == "")
                    {
                        throw new ELibraryException("Please enter the name");
                    }
                    documentList = docBL.ViewDocumentsByNameBL(name);
                    if (documentList != null)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add(new DataColumn("Title", typeof(string)));
                        dt.Columns.Add(new DataColumn("Author", typeof(string)));
                        dt.Columns.Add(new DataColumn("Description", typeof(string)));
                        dt.Columns.Add(new DataColumn("Type", typeof(string)));
                        dt.Columns.Add(new DataColumn("Price", typeof(string)));
                        dt.Columns.Add(new DataColumn("", typeof(Control)));
                        dt.Columns.Add(new DataColumn("Path", typeof(string)));
                        dt.Columns.Add(new DataColumn("DocumentID", typeof(string)));
                        foreach (DocumentDetails doc in documentList)
                        {
                            DataRow dr = dt.NewRow();
                            dr["Title"]       = doc.Title;
                            dr["Author"]      = doc.Author;
                            dr["Type"]        = docBL.GetDocumentTypeBL(doc.DocumentTypeID);
                            dr["Description"] = doc.DocumentDescription;
                            dr["Path"]        = doc.DocumentPath;
                            dr["Price"]       = doc.Price;
                            dr["DocumentID"]  = doc.DocumentID;
                            dt.Rows.Add(dr);
                        }
                        gvSearch.DataSource = dt;
                        gvSearch.DataBind();
                    }
                }
                else if (cboSearchBy.SelectedItem.Text == "Discipline")
                {
                    gvSearch.DataSource = null;
                    string discipline = cboDiscipline.SelectedItem.Text;

                    documentList = docBL.ViewDocumentsByDisciplineBL(discipline);
                    if (documentList != null)
                    {
                        DataTable dt = new DataTable();
                        dt.Columns.Add(new DataColumn("Title", typeof(string)));
                        dt.Columns.Add(new DataColumn("Author", typeof(string)));
                        dt.Columns.Add(new DataColumn("Description", typeof(string)));
                        dt.Columns.Add(new DataColumn("Type", typeof(string)));
                        dt.Columns.Add(new DataColumn("Price", typeof(string)));
                        dt.Columns.Add(new DataColumn("", typeof(Control)));
                        dt.Columns.Add(new DataColumn("Path", typeof(string)));
                        dt.Columns.Add(new DataColumn("DocumentID", typeof(string)));
                        foreach (DocumentDetails doc in documentList)
                        {
                            DataRow dr = dt.NewRow();
                            dr["Title"]       = doc.Title;
                            dr["Author"]      = doc.Author;
                            dr["Type"]        = docBL.GetDocumentTypeBL(doc.DocumentTypeID);
                            dr["Description"] = doc.DocumentDescription;
                            dr["Path"]        = doc.DocumentPath;
                            dr["Price"]       = doc.Price;
                            dr["DocumentID"]  = doc.DocumentID;
                            dt.Rows.Add(dr);
                        }
                        gvSearch.DataSource = dt;
                        gvSearch.DataBind();
                    }
                }
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                lblDisplay.Text = ex.Message;
            }
        }