コード例 #1
0
        private void setValues()
        {
            double     cartTotal        = 0;
            double     taxBase          = 0;
            double     tax              = 0;
            double     discount         = 0;
            double     delivery         = 0;
            double     total            = 0;
            double     userDiscount     = 0;
            CouponType discountType     = new CouponType(1, "Procentualni");
            double     totalForDiscount = 0;

            if (Page.User.Identity.IsAuthenticated)
            {
                eshopBE.User user = UserBL.GetUser(-1, Page.User.Identity.Name);
                userDiscount = user.Discount;
                discountType = new CouponBL().GetCouponType(user.DiscountTypeID);
            }

            for (int i = 0; i < _cart.Rows.Count; i++)
            {
                cartTotal        += double.Parse(_cart.Rows[i]["productPrice"].ToString()) * double.Parse(_cart.Rows[i]["quantity"].ToString());
                discount         += double.Parse(_cart.Rows[i]["productPrice"].ToString()) * double.Parse(_cart.Rows[i]["quantity"].ToString()) - double.Parse(_cart.Rows[i]["total"].ToString());
                totalForDiscount += !bool.Parse(ConfigurationManager.AppSettings["userDiscountOnlyOnProductNotOnPromotion"]) || double.Parse(_cart.Rows[i]["productPrice"].ToString()) == double.Parse(_cart.Rows[i]["userPrice"].ToString()) ? double.Parse(_cart.Rows[i]["productPrice"].ToString()) * double.Parse(_cart.Rows[i]["quantity"].ToString()) : 0;
            }
            lblNumberOfProducts.Text = _cart.Rows.Count.ToString();


            double userDiscountValue = (discountType.CouponTypeID == 1) ? (totalForDiscount) * (userDiscount / 100) : userDiscount;

            double totalWithDiscount = cartTotal - discount - userDiscountValue;

            taxBase = (cartTotal - discount - userDiscountValue) / 1.2;
            tax     = cartTotal - discount - userDiscountValue - taxBase;



            delivery = (cartTotal - discount - userDiscountValue > double.Parse(ConfigurationManager.AppSettings["freeDeliveryTotalValue"])) ? 0 : double.Parse(ConfigurationManager.AppSettings["deliveryCost"]);



            total = cartTotal - discount + delivery - userDiscountValue;



            lblTaxBase.Text      = string.Format("{0:N2}", taxBase);
            lblPdv.Text          = string.Format("{0:N2}", tax);
            lblTotalWithTax.Text = string.Format("{0:N2}", cartTotal);
            double totalDiscount = discount + userDiscountValue;

            lblDiscount.Text          = string.Format("{0:N2}", (0 - totalDiscount));
            lblTotalWithDiscount.Text = string.Format("{0:N2}", totalWithDiscount);
            //lblDiscount.Text = "42423424";
            lblDelivery.Text = string.Format("{0:N2}", delivery);
            lblTotal.Text    = string.Format("{0:N2}", total);
        }
コード例 #2
0
ファイル: account.aspx.cs プロジェクト: yoorke/pinshop
        protected void btnSave_Click(object sender, EventArgs e)
        {
            User user = new User();
            user.UserID = int.Parse(Membership.GetUser().ProviderUserKey.ToString());
            user.LastName = txtLastname.Text;
            user.FirstName = txtFirstname.Text;
            user.Email = txtEmail.Text;
            user.Address = txtAddress.Text;
            user.City = txtCity.Text;
            user.Zip = txtZip.Text;
            user.Phone = txtPhone.Text;

            new UserBL().UpdateUser(user);

            lblStatus.Text = "Podaci o korisniku uspešno izmenjeni.";
            divStatus.Visible = true;
            divStatus.Attributes["class"] = "status success";
        }
コード例 #3
0
        private void saveUser()
        {
            eshopBE.User user = new eshopBE.User();
            user.UserID         = int.Parse(lblUserID.Value);
            user.LastName       = txtLastName.Text;
            user.FirstName      = txtFirstName.Text;
            user.Email          = txtEmail.Text;
            user.Phone          = txtPhone.Text;
            user.Address        = txtAddress.Text;
            user.Zip            = txtZip.Text;
            user.City           = txtCity.Text;
            user.Discount       = double.Parse(txtDiscount.Text);
            user.DiscountTypeID = int.Parse(cmbDiscountType.SelectedValue);

            int status = new UserBL().UpdateUser(user);

            if (status > 0)
            {
                setCustomStatus("Korisnik uspešno sačuvan", "success");
            }
        }
コード例 #4
0
        public static User GetUser(int userID, string username)
        {
            User user = null;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("SELECT [user].userID, firstName, lastName, username, [password], email, [address], city, phone, userType.userTypeID, userType.name FROM [user] INNER JOIN userUserType ON [user].userID=userUserType.userID INNER JOIN userType ON userUserType.userTypeID=userType.userTypeID", objConn))
                {
                    objConn.Open();
                    if (userID > 0)
                    {
                        objComm.CommandText += " WHERE userID=@userID";
                        objComm.Parameters.Add("@userID", SqlDbType.Int).Value = userID;
                    }
                    else if (username != string.Empty)
                    {
                        objComm.CommandText += " WHERE username=@username";
                        objComm.Parameters.Add("@username", SqlDbType.NVarChar, 50).Value = username;
                    }

                    using (SqlDataReader reader = objComm.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            user = new User();
                            user.UserID = userID;
                            user.FirstName = reader.GetString(1);
                            user.LastName = reader.GetString(2);
                            user.Username = reader.GetString(3);
                            user.Password = reader.GetString(4);
                            user.Email = reader.GetString(5);
                            user.Address = reader.GetString(6);
                            user.City = reader.GetString(7);
                            user.Phone = reader.GetString(8);
                            user.UserType = new UserType(reader.GetInt32(9), reader.GetString(10));
                        }
                    }
                }
            }
            return user;
        }
コード例 #5
0
ファイル: UserBL.cs プロジェクト: yoorke/pinshop
 public int UpdateUser(User user)
 {
     return new UserDL().UpdateUser(user);
 }
コード例 #6
0
ファイル: UserDL.cs プロジェクト: yoorke/pinshop
        public int UpdateUser(User user)
        {
            int status = 0;
            using (SqlConnection objConn = new SqlConnection(WebConfigurationManager.ConnectionStrings["eshopConnectionString"].ConnectionString))
            {
                using (SqlCommand objComm = new SqlCommand("user_update", objConn))
                {
                    objConn.Open();
                    objComm.CommandType = CommandType.StoredProcedure;
                    objComm.Parameters.Add("@lastName", SqlDbType.NVarChar, 50).Value = user.LastName;
                    objComm.Parameters.Add("@firstName", SqlDbType.NVarChar, 50).Value = user.FirstName;
                    objComm.Parameters.Add("@email", SqlDbType.NVarChar, 50).Value = user.Email;
                    objComm.Parameters.Add("@phone", SqlDbType.NVarChar, 50).Value = user.Phone;
                    objComm.Parameters.Add("@address", SqlDbType.NVarChar, 100).Value = user.Address;
                    objComm.Parameters.Add("@zip", SqlDbType.NVarChar, 5).Value = user.Zip;
                    objComm.Parameters.Add("@city", SqlDbType.NVarChar, 50).Value = user.City;
                    objComm.Parameters.Add("@userID", SqlDbType.Int).Value=user.UserID;

                    status = objComm.ExecuteNonQuery();
                }
            }
            return status;
        }