Beispiel #1
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);
                }
            }
        }
Beispiel #2
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));
                }
            }
        }
        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);
            }
        }