Example #1
0
        private void GetBooksBought()
        {
            ELibraryDocumentBL docBL     = new ELibraryDocumentBL();
            UserDetails        userObj   = (UserDetails)Session["UserObj"];
            List <int>         docIDList = docBL.GetDocumentsBoughtBL(userObj.UserID);

            gvPurchased.DataSource = null;
            if (docIDList != 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("Price", typeof(string)));

                foreach (int docId in docIDList)
                {
                    DocumentDetails doc = docBL.GetDocumentByID(docId);
                    DataRow         dr  = dt.NewRow();
                    dr["Title"]       = doc.Title;
                    dr["Author"]      = doc.Author;
                    dr["Description"] = doc.DocumentDescription;
                    dr["Price"]       = doc.Price;
                    dt.Rows.Add(dr);
                }
                gvPurchased.DataSource = dt;
                gvPurchased.DataBind();
            }
        }
        private void GetFreebies()
        {
            ELibraryDocumentBL docBL = new ELibraryDocumentBL();

            gvFreebies.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("Download", typeof(Control)));
            dt.Columns.Add(new DataColumn("Path", typeof(string)));
            List <DocumentDetails> docList = docBL.AccessDocumentsByTypeBL("Freebie");

            if (docList != null)
            {
                foreach (DocumentDetails doc in docList)
                {
                    DataRow dr = dt.NewRow();
                    dr["Title"]       = doc.Title;
                    dr["Author"]      = doc.Author;
                    dr["Description"] = doc.DocumentDescription;
                    dr["Path"]        = doc.DocumentPath;
                    dt.Rows.Add(dr);
                }
            }
            gvFreebies.DataSource = dt;
            gvFreebies.DataBind();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserObj"] == null)
            {
                Response.Redirect("Home.aspx");
            }
            if (!IsPostBack)
            {
                try
                {
                    UserDetails user = (UserDetails)Session["UserObj"];
                    lblWelcome.Text = "Welcome " + user.FirstName + " " + user.LastName;
                    ELibraryDocumentBL  docBL      = new ELibraryDocumentBL();
                    ELibraryPurchasedBL purchaseBL = new ELibraryPurchasedBL();
                    ELibraryUserBL      userBL     = new ELibraryUserBL();

                    lblReg.Text  = userBL.GetRegisteredUserCountBL().ToString() + " Registered Users!!";
                    lblSub.Text  = userBL.GetSubscribedUserCountBL().ToString() + " Subscribed Users!!";
                    lblSold.Text = purchaseBL.GetPurchasedCountBL().ToString() + " Documents Sold!!";
                }
                catch (Exception ex)
                {
                    ErrorLogging erLog = new ErrorLogging();
                    erLog.LogError(ex.Message);
                }
            }
        }
        private void DisplayCart()
        {
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            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("Price", typeof(string)));
            dt.Columns.Add(new DataColumn("", typeof(Control)));
            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["DocumentID"] = doc.DocumentID;

                    dr["Price"] = doc.Price;

                    dt.Rows.Add(dr);
                }
            }
            gvShoppingCart.DataSource = dt;
            gvShoppingCart.DataBind();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserObj"] == null)
     {
         Response.Redirect("Home.aspx");
     }
     try
     {
         ELibraryDocumentBL docBL = new ELibraryDocumentBL();
         lblDisplay.Text = "";
         docIDList       = new List <int>();
         if (Session["DocList"] != null)
         {
             docIDList = (List <int>)Session["DocList"];
         }
         DisplayCart();
         if (!IsPostBack)
         {
             foreach (Disciplines disc in docBL.GetAllDisciplinesBL())
             {
                 chklasideBar.Items.Add(disc.DisciplineName.ToString());
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging erLog = new ErrorLogging();
         erLog.LogError(ex.Message);
     }
 }
Example #6
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            DocumentDetails    docObj   = new DocumentDetails();
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            try
            {
                if (cbnDocumentID.SelectedIndex == -1)
                {
                    throw new ELibraryException("Select Document ID");
                }
                docObj.DocumentID = Convert.ToInt32(cbnDocumentID.SelectedValue);
                if (docBLObj.DeleteDocumentBL(docObj))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Deleted')", true);
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Deletion Failed')", true);
                }
                InitializeCombo();
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
            }
        }
Example #7
0
        private void InitializeCombo()
        {
            ELibraryDocumentBL  docBL      = new ELibraryDocumentBL();
            ELibraryPurchasedBL purchaseBL = new ELibraryPurchasedBL();
            ELibraryUserBL      userBL     = new ELibraryUserBL();

            //lblRegUsers.Content = userBL.GetRegisteredUserCountBL().ToString() + " Registered Users!!";
            //lblSubUsers.Content = userBL.GetSubscribedUserCountBL().ToString() + " Subscribed Users!!";
            // lblSoldDocs.Content = purchaseBL.GetPurchasedCountBL().ToString() + " Documents Sold!!";

            cboDiscipline.Items.Clear();

            cboDocumentType.Items.Clear();
            //cbDocTypeUpd.Items.Clear();
            cbnDocumentID.Items.Clear();


            foreach (Disciplines disc in docBL.GetAllDisciplinesBL())
            {
                cboDiscipline.Items.Add(disc.DisciplineName.ToString());
            }
            foreach (DocumentTypeDetails docType in docBL.GetAllDocumentTypesBL())
            {
                cboDocumentType.Items.Add(docType.DocumentTypeName.ToString());
            }
            if (docBL.GetAllDocumentIDBL() != null)
            {
                foreach (int i in docBL.GetAllDocumentIDBL())
                {
                    cbnDocumentID.Items.Add(Convert.ToString(i));
                }
            }
        }
Example #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ELibraryDocumentBL docBL = new ELibraryDocumentBL();

            if (!IsPostBack)
            {
                foreach (Disciplines disc in docBL.GetAllDisciplinesBL())
                {
                    chklAreasofInterest.Items.Add(disc.DisciplineName.ToString());
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserObj"] == null)
            {
                Response.Redirect("Home.aspx");
            }
            if (!IsPostBack)
            {
                ValidationSettings.UnobtrusiveValidationMode = UnobtrusiveValidationMode.None;

                UserDetails        user   = new UserDetails();
                ELibraryDocumentBL bllobj = new ELibraryDocumentBL();
                //Session["userid"] = user.UserID;
                UserDetails userobj = (UserDetails)Session["UserObj"];
                //UserDetails entityobj = bllobj.GetDetailsUserBL(userobj.UserID);
                lblwelcome.Text   = "Welcome " + userobj.FirstName;
                txtfirstname.Text = userobj.FirstName;
                txtlastname.Text  = userobj.LastName;
                txtpwd.Text       = userobj.Pasword;

                txtlandnum.Text = userobj.LandLineNumber;
                txtmblnum.Text  = userobj.MobileNumber;
                txtadress.Text  = userobj.UserAddress.ToString();


                foreach (Disciplines disc in bllobj.GetAllDisciplinesBL())
                {
                    chklAreasofInterest.Items.Add(disc.DisciplineName.ToString());
                }

                string   AreaOfInterest      = userobj.AreaOfInterest;
                string[] AreaOfInterestArray = AreaOfInterest.Split(',');
                foreach (string str in AreaOfInterestArray)
                {
                    for (int i = 0; i < chklAreasofInterest.Items.Count; i++)
                    {
                        if (chklAreasofInterest.Items[i].Text == str)
                        {
                            chklAreasofInterest.Items[i].Selected = true;
                        }
                    }
                }
            }
        }
        public void Button1_Click(object sender, EventArgs e)

        {
            StringBuilder sb = new StringBuilder();

            ELibraryUserBL     bllobj        = new ELibraryUserBL();
            UserDetails        userUpdateObj = new UserDetails();
            ELibraryDocumentBL docBl         = new ELibraryDocumentBL();
            UserDetails        userobj       = (UserDetails)Session["UserObj"];

            userUpdateObj.UserID         = userobj.UserID;
            userUpdateObj.Pasword        = txtpwd.Text;
            userUpdateObj.FirstName      = txtfirstname.Text;
            userUpdateObj.LastName       = txtlastname.Text;
            userUpdateObj.LandLineNumber = txtlandnum.Text;
            userUpdateObj.MobileNumber   = txtmblnum.Text;
            userUpdateObj.UserAddress    = txtadress.Text;
            for (int i = 0; i < chklAreasofInterest.Items.Count; i++)
            {
                if (chklAreasofInterest.Items[i].Selected)
                {
                    int j = 0;
                    j = i + 1;
                    var name = docBl.GetDisciplineNameBL(j);
                    sb.Append(name + ",");
                }
                userUpdateObj.AreaOfInterest = sb.ToString();



                //userUpdateObj.AreaOfInterest = chklAreasofInterest.SelectedValue.ToString();
                bool isUpdated = bllobj.UpdateDetailsUserBL(userUpdateObj);
                if (isUpdated)
                {
                    lblupdatestatus.Text = "Successfully Updated";
                    Session["UserObj"]   = userUpdateObj;
                }
                else
                {
                    lblupdatestatus.Text = "Not Updated Properly";
                }
            }
        }
        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();
        }
Example #12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["UserObj"] == null)
     {
         Response.Redirect("Home.aspx");
     }
     try
     {
         if (!IsPostBack)
         {
             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("Download", typeof(Control)));
             dt.Columns.Add(new DataColumn("Path", typeof(string)));
             List <DocumentDetails> docList = docBL.AccessDocumentsByTypeBL("Freebie");
             if (docList != null)
             {
                 foreach (DocumentDetails doc in docList)
                 {
                     DataRow dr = dt.NewRow();
                     dr["Title"]       = doc.Title;
                     dr["Author"]      = doc.Author;
                     dr["Description"] = doc.DocumentDescription;
                     dr["Path"]        = doc.DocumentPath;
                     dt.Rows.Add(dr);
                 }
                 gvFreebies.DataSource = dt;
                 gvFreebies.DataBind();
             }
         }
     }
     catch (Exception ex)
     {
         ErrorLogging erLog = new ErrorLogging();
         erLog.LogError(ex.Message);
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            ELibraryDocumentBL docBL = new ELibraryDocumentBL();

            List <int> docIDList = new List <int>();

            try
            {
                if (!IsPostBack)
                {
                    foreach (Disciplines disc in docBL.GetAllDisciplinesBL())
                    {
                        chklasideBar.Items.Add(disc.DisciplineName.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
            }
        }
Example #14
0
        private void GetRecentDocumentByDiscipline()
        {
            ELibraryDocumentBL docBL          = new ELibraryDocumentBL();
            UserDetails        userObj        = (UserDetails)Session["UserObj"];
            string             AreaOfInterest = userObj.AreaOfInterest;

            string[] AreaOfInterestArray   = AreaOfInterest.Split(',');
            List <DocumentDetails> docList = new List <DocumentDetails>();

            for (int i = 0; i < AreaOfInterestArray.Count(); i++)
            {
                string discName = AreaOfInterestArray[i];
                if (discName == "")
                {
                    continue;
                }
                docList.AddRange(docBL.GetRecentDocumentByDisciplineBL(discName));
            }
            gvBooksInterested.DataSource = null;
            if (docList.Count != 0)
            {
                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("Price", typeof(string)));
                foreach (DocumentDetails doc in docList)
                {
                    DataRow dr = dt.NewRow();
                    dr["Title"]  = doc.Title;
                    dr["Author"] = doc.Author;
                    //dr["Description"] = doc.DocumentDescription;
                    dr["Price"] = doc.Price;
                    dt.Rows.Add(dr);
                }
                gvBooksInterested.DataSource = docList;
                gvBooksInterested.DataBind();
            }
        }
Example #15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserObj"] == null)
            {
                Response.Redirect("Home.aspx");
            }
            ELibraryDocumentBL docBL = new ELibraryDocumentBL();

            lblDisplay.Text = "";
            docIDList       = new List <int>();
            if (Session["DocList"] != null)
            {
                docIDList = (List <int>)Session["DocList"];
            }
            DisplayCart();
            if (!IsPostBack)
            {
                foreach (Disciplines disc in docBL.GetAllDisciplinesBL())
                {
                    cboDiscipline.Items.Add(disc.DisciplineName.ToString());
                }
            }
        }
Example #16
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);
            }
        }
Example #17
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            DocumentDetails    docObj   = new DocumentDetails();
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            try
            {
                string folderPath = Server.MapPath("~/Files/");
                if (!Directory.Exists(folderPath))
                {
                    //If Directory (Folder) does not exists. Create it.
                    Directory.CreateDirectory(folderPath);
                }

                string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                if (fileName == "")
                {
                    throw new ELibraryException("Select File");
                }
                FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName));
                docObj.DocumentPath = folderPath + Path.GetFileName(FileUpload1.FileName);


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


                if (cboDocumentType.SelectedIndex == -1)
                {
                    throw new ELibraryException("Invalid Document Type");
                }
                docObj.DocumentTypeID = docBLObj.GetDocumentTypeIDBL(cboDocumentType.SelectedItem.ToString());

                if (cboDiscipline.SelectedIndex == -1)
                {
                    throw new ELibraryException("Invalid Discipline");
                }
                docObj.DisciplineID = docBLObj.GetDisciplineIDBL(cboDiscipline.SelectedItem.ToString());

                docObj.Title  = txtTitle.Text;
                docObj.Author = txtAuthor.Text;
                double price;
                bool   isValidPrice = double.TryParse(txtPrice.Text, out price);
                if (!isValidPrice)
                {
                    throw new ELibraryException("Invalid price");
                }
                docObj.Price      = price;
                docObj.UploadDate = DateTime.Today;

                if (docBLObj.AddNewDocumentBL(docObj))
                {
                    lblDisplay.Text = "Added";      //.Show("Added");
                }
                else
                {
                    lblDisplay.Text = "Failed";
                }
                InitializeCombo();
            }
            catch (ELibraryException ex)
            {
                lblDisplay.Text = ex.Message;
            }
        }
Example #18
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            DocumentDetails    docObj   = new DocumentDetails();
            ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();

            try
            {
                InitializeCombo();
                if (cbnDocumentID.SelectedIndex == -1)
                {
                    throw new ELibraryException("Select Document ID");
                }

                if (cboDocumentType.SelectedIndex == -1)
                {
                    throw new ELibraryException("Select Discipline");
                }
                if (cboDiscipline.SelectedIndex == -1)
                {
                    throw new ELibraryException("Select Document Type");
                }

                docObj.DocumentID = Convert.ToInt32(cbnDocumentID.SelectedValue);
                //Session["DocumentId"] = cbnDocumentID.SelectedValue;
                string folderPath = Server.MapPath("~/Files/");
                if (!Directory.Exists(folderPath))
                {
                    //If Directory (Folder) does not exists. Create it.
                    Directory.CreateDirectory(folderPath);
                }

                string fileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
                if (fileName == "")
                {
                    throw new ELibraryException("Select File");
                }
                FileUpload1.SaveAs(folderPath + Path.GetFileName(FileUpload1.FileName));
                docObj.DocumentPath = folderPath + Path.GetFileName(FileUpload1.FileName);

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

                docObj.DocumentTypeID = docBLObj.GetDocumentTypeIDBL(cboDocumentType.SelectedItem.ToString());
                docObj.DisciplineID   = docBLObj.GetDisciplineIDBL(cboDiscipline.SelectedItem.ToString());
                docObj.Title          = txtTitle.Text;
                docObj.Author         = txtAuthor.Text;
                double price;
                bool   isValidPrice = double.TryParse(txtPrice.Text, out price);
                if (!isValidPrice)
                {
                    throw new ELibraryException("Invalid price");
                }
                docObj.Price      = price;
                docObj.UploadDate = DateTime.Today;

                if (docBLObj.UpdateDocumentBL(docObj))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Successfully Updated')", true);
                    //string str = "<script>alert(\"Updated Successfully\");</script>";
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Updation Failed')", true);
                }
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
            }
        }
Example #19
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;
            }
        }
        protected void btnpay_Click(object sender, EventArgs e)
        {
            PaymentDetails paymentObj = new PaymentDetails();
            UserDetails    userObj    = new UserDetails();

            userObj.UserID = Session["UserId"].ToString();
            try
            {
                paymentObj.CreditCardNumber = txtcreditcard.Text;
                paymentObj.CreditCardName   = txtname.Text;
                paymentObj.CVV = txtcvv.Text;


                if (ddlexpmonth.SelectedValue == null)
                {
                    throw new ELibraryException("enter valid month");
                }
                paymentObj.ExpiryMonth = Convert.ToInt32(ddlexpmonth.SelectedValue);
                int  year;
                bool isYear = int.TryParse(txtexpyear.Text, out year);
                if (!isYear)
                {
                    throw new ELibraryException("Enter Valid Year");
                }
                paymentObj.ExpiryYear = year;
                ELibraryUserBL     userBL   = new ELibraryUserBL();
                ELibraryPaymentBL  payBLObj = new ELibraryPaymentBL();
                ELibraryDocumentBL docBLObj = new ELibraryDocumentBL();
                if (payBLObj.VerifyPaymentBL(paymentObj))
                {
                    if ((bool)Session["Subscribe"])
                    {
                        userBL.UpdateUserSubscriptionBL(userObj, paymentObj);
                        userObj.UserType = "Subscriber";
                        if (Session["UserObj"] != null)
                        {
                            UserDetails user = (UserDetails)Session["UserObj"];
                            user.UserType      = "Subscriber";
                            Session["UserObj"] = user;
                        }
                    }
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Payment successful\nPurchased documents will be in downloads.\nHappy Reading!!')", true);
                }
                List <int> docIDList = null;
                if (Session["DocList"] != null)
                {
                    docIDList = (List <int>)Session["DocList"];
                }

                if (docIDList != null)
                {
                    ELibraryPurchasedBL purchaseBL = new ELibraryPurchasedBL();
                    foreach (int doc in docIDList)
                    {
                        PurchasedDetails purchase = new PurchasedDetails();
                        purchase.DocumentID    = doc;
                        purchase.UserID        = userObj.UserID;
                        purchase.PurchasedDate = DateTime.Today;
                        purchaseBL.PurchaseDocumentBL(purchase);
                    }
                    Response.Redirect("Download.aspx");
                }
                else
                {
                    Response.Redirect("Home.aspx");
                }
            }
            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);
            }
        }
Example #22
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            ELibraryDocumentBL docBL   = new ELibraryDocumentBL();
            UserDetails        userObj = new UserDetails();
            StringBuilder      sb      = new StringBuilder();

            try
            {
                userObj.UserID    = txtUserId.Text;
                Session["UserId"] = userObj.UserID;
                userObj.FirstName = txtFirstName.Text;
                userObj.LastName  = txtLastName.Text;
                DateTime dob;
                bool     isValidDate = DateTime.TryParse(txtDateOfBirth.Text, out dob);
                if (isValidDate)
                {
                    userObj.DateOfBirth = dob;
                }
                else
                {
                    throw new ELibraryException("Please enter date of birth");
                }

                if (rblGender.SelectedValue == "Male")
                {
                    userObj.Gender = "M";
                }

                else
                {
                    userObj.Gender = "F";
                }
                userObj.UserAddress    = txtAddress.Text;
                userObj.LandLineNumber = txtLandlineNumber.Text;
                userObj.MobileNumber   = txtboxMobileNumber.Text;
                userObj.Pasword        = txtPassword.Text;



                for (int i = 0; i < chklAreasofInterest.Items.Count; i++)
                {
                    if (chklAreasofInterest.Items[i].Selected)
                    {
                        int j = 0;
                        j = i + 1;
                        var name = docBL.GetDisciplineNameBL(j);
                        sb.Append(name + ",");
                    }
                }
                int itemsSelected = 0;
                foreach (ListItem li in chklAreasofInterest.Items)
                {
                    if (li.Selected)
                    {
                        itemsSelected = itemsSelected + 1;
                    }
                }
                if (itemsSelected == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('Please select atleast one checkbox')", true);
                    //Response.Write("<script>alert('Please select atleast one checkbox')</script>");
                }



                userObj.AreaOfInterest = sb.ToString();

                userObj.DateOfRegistration = DateTime.Now;
                userObj.UserType           = "Non Scubscriber";

                ELibraryUserBL userBL = new ELibraryUserBL();

                bool isAdded = userBL.RegisterBL(userObj);
                if (isAdded)
                {
                    lblException.Text = "Registered";
                }
                if (chksubscribe.Checked == true)
                {
                    Session["Amount"]    = 1000;
                    Session["Subscribe"] = true;
                    PaymentForm payForm = new PaymentForm();
                    Response.Redirect("PaymentForm.aspx");
                }
            }
            catch (ELibraryException ex)
            {
                ErrorLogging erLog = new ErrorLogging();
                erLog.LogError(ex.Message);
                ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + ex.Message + "')", true);
            }
        }