Example #1
0
        public bool DeleteMessage(int messageId, int userId, int deletedBy)
        {
            bool success = false;

            SqlParameter[] messageParamater = new SqlParameter[] { new SqlParameter("@message_id", DbType.Int32) };
            messageParamater[0].Value = messageId;
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("Message", "SP_DELETE_STD_MESSAGE"), messageParamater);
                        success = (noOfRecords > 0);
                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.MessageManagement, messageId.ToString(), "Deleted message",
                                                                       userId, deletedBy);
                        AuditTrail.WriteEntry(auditEntry, sqlTran);
                        sqlTran.Commit();
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            return(success);
        }
Example #2
0
        public bool InsertCartItem(ShoppingCartItemInfo cartInfo, int ownerId)
        {
            bool success = false;

            SqlParameter[] messageParameters = GetCartItemParams();
            messageParameters[0].Value = cartInfo.UserId;
            messageParameters[1].Value = cartInfo.ProductId;
            messageParameters[2].Value = cartInfo.Quantity;

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("ShoppingCart", "SP_INSERT_CARTITEM"), messageParameters);
                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ShoppingCart, cartInfo.ProductId,
                                                                       "Inserted cart item", cartInfo.UserId, ownerId);
                        AuditTrail.WriteEntry(auditEntry, sqlTran);
                        success = (noOfRecords > 0);
                        sqlTran.Commit();
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            return(success);
        }
Example #3
0
        /// <summary>
        /// Updates the credit card details of the specified registration account.
        /// </summary>
        /// <param name="userId">Internal identifier of the user.</param>
        /// <param name="creditCard">Credit Card Information of the user.</param>
        public void UpdateCreditCard(int userId, CreditCardInfo creditCard)
        {
            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        UpdateCreditCard(userId, ref creditCard, transaction);

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.UpdateCreditCard, creditCard.Number, "Updated Credit Card", userId, userId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #4
0
        public bool DeleteProduct(string productId, int userId)
        {
            bool success = false;

            SqlParameter[] sqlParam = new SqlParameter[] { new SqlParameter("@product_id", SqlDbType.NVarChar, 30) };
            sqlParam[0].Value = productId;

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("Product", "SP_DELETE_PRODUCT"), sqlParam);
                        success = (noOfRecords > 0);
                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ProductCatalog, productId, "Deleted product", userId, userId);
                        AuditTrail.WriteEntry(auditEntry, sqlTran);
                        sqlTran.Commit();
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            return(success);
        }
Example #5
0
        /// <summary>
        /// Deletes the specified design.
        /// </summary>
        /// <param name="designId">Internal identifier of the design to delete.</param>
        /// <param name="userId">Internal identifier of the user.</param>
        public void Delete(int designId, int userId)
        {
            // Get the design details.
            DesignInfo design = Get(designId);

            SqlParameter[] parameters = SQLHelper.GetCachedParameters("SP_DELETE_DESIGN");

            if (parameters == null)
            {
                parameters = new SqlParameter[] {
                    new SqlParameter("@design_id", SqlDbType.Int)
                };

                SQLHelper.CacheParameters("SP_DELETE_DESIGN", parameters);
            }

            parameters[0].Value = designId;

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction,
                                                  CommandType.StoredProcedure,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SP_DELETE_DESIGN"),
                                                  parameters);

                        // Write entry into audit trail.
                        string action = string.Empty;

                        if (design.Status.LookupId == 23)
                        {
                            action = "Rejected design";
                        }
                        else
                        {
                            action = "Deleted design";
                        }

                        AuditEntryInfo auditEntry = new AuditEntryInfo(
                            Module.DesignManagement, design.Category.Name,
                            action, design.UserId, userId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #6
0
        /// <summary>
        /// Inserts a registration account with user Work Space Area.
        /// </summary>
        /// <param name="registration">Registration Information of the user.</param>
        /// <param name="workSpacePath">String Path in which Workspase Directory</param>
        public int InsertWithWorkSpaceDirectory(RegistrationInfo registration, string workSpacePath)
        {
            int UserId = 0;

            SqlParameter[] registrationparameters = GetRegistrationParameters();

            SqlParameter[] registrationAddressParameters;

            SetRegistrationParameters(registrationparameters, registration);

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SQL_INSERT_ACCOUNT"),
                                                  registrationparameters);

                        UserId = (int)registrationparameters[12].Value;

                        registrationAddressParameters = GetRegistrationAddressParameters();
                        SetRegistrationAddressParameters(UserId, registrationAddressParameters, registration);

                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SQL_INSERT_ACCOUNT_SHIPPINGADDRESS"),
                                                  registrationAddressParameters);

                        if (registration.CreditCard != null)
                        {
                            CreditCardInfo creditCard = registration.CreditCard;

                            UpdateCreditCard(UserId, ref creditCard,
                                             transaction);
                        }

                        workSpacePath += UserId.ToString();
                        System.IO.Directory.CreateDirectory(workSpacePath);

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.Registration, registration.UserName, "User Registered", UserId, UserId);
                        AuditTrail.WriteEntry(auditEntry, transaction);
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
            return(UserId);
        }
Example #7
0
        public List <AccaInfo> UpdateEventInfo(List <AccaInfo> eventsInfo)
        {
            bool           success = false;
            AuditEntryInfo auditEntry;

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        List <AccaInfo> completedEvents = new List <AccaInfo>();
                        foreach (AccaInfo eventInfo in eventsInfo)
                        {
                            Order order = new Order();
                            if (eventInfo.EventStatus == ScheduleEventStatus.InProgress)
                            {
                                bool isEventPresent = false;
                                foreach (AccaInfo completedEvent in completedEvents)
                                {
                                    if (completedEvent.EventId == eventInfo.EventId)
                                    {
                                        eventInfo.AccaOrderInfo.OrderId = completedEvent.AccaOrderInfo.OrderId;
                                        isEventPresent = true;
                                        break;
                                    }
                                }
                                if (!isEventPresent)
                                {
                                    eventInfo.AccaOrderInfo.OrderId = order.Insert(eventInfo.UserId, eventInfo.AccaOrderInfo, eventInfo.UserId);
                                    UpdateInventory(eventInfo.AccaDesignCategory.ToString(), eventInfo.ContactCount, eventInfo.UserId, sqlTran);
                                    auditEntry = new AuditEntryInfo(Module.AccaProcess, eventInfo.EventId.ToString(), "Updated Inventory",
                                                                    eventInfo.UserId, eventInfo.UserId);
                                    AuditTrail.WriteEntry(auditEntry, sqlTran);
                                }
                                completedEvents.Add(eventInfo);
                            }
                            UpdateEventInfoInDB(eventInfo, conn, sqlTran);
                            auditEntry = new AuditEntryInfo(Module.AccaProcess, eventInfo.EventId.ToString(), "Updated event status",
                                                            eventInfo.UserId, eventInfo.UserId);
                            AuditTrail.WriteEntry(auditEntry, sqlTran);
                        }
                        sqlTran.Commit();
                        success = true;
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            return(eventsInfo);
        }
Example #8
0
        public ShoppingCartInfo DeleteCartItem(int userId, string productId, IProduct product, int ownerId)
        {
            ShoppingCartInfo            cartInfo  = new ShoppingCartInfo();
            List <ShoppingCartItemInfo> cartItems = new List <ShoppingCartItemInfo>();
            ShoppingCartItemInfo        cartItem;

            SqlParameter[] messageParamater = new SqlParameter[] { new SqlParameter("@product_id", SqlDbType.NVarChar, 30),
                                                                   new SqlParameter("@user_id", SqlDbType.Int) };
            messageParamater[0].Value = productId;
            messageParamater[1].Value = userId;
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        using (SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.CONNECTION_STRING, CommandType.StoredProcedure,
                                                                              SQLHelper.GetSQLStatement("ShoppingCart", "SP_DELETE_CARTITEM"), messageParamater))
                        {
                            AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ShoppingCart, productId, "deleted shopping cart item", userId,
                                                                           ownerId);
                            AuditTrail.WriteEntry(auditEntry, sqlTran);
                            while (reader.Read())
                            {
                                cartItem             = new ShoppingCartItemInfo();
                                cartItem.ProductId   = (string)reader["product_id"];
                                cartItem.Price       = Math.Round((decimal)reader["price"], 2);
                                cartItem.Quantity    = (int)reader["quantity"];
                                cartItem.Description = product.GetProductDetails(cartItem.ProductId).BriefDescWithQuantity;
                                cartItem.TotalPrice  = cartItem.Quantity * cartItem.Price;
                                cartItem.UserId      = userId;
                                cartItems.Add(cartItem);
                                cartInfo.Tax = Math.Round((decimal)reader["Tax"], 2);
                            }
                        }
                        sqlTran.Commit();
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            cartInfo.CartItems = cartItems;
            return(cartInfo);
        }
Example #9
0
        public bool InsertMessage(MessageInfo messageInfo, int userId)
        {
            bool success = false;

            SqlParameter[] messageParameters = GetStdMessageParams();
            messageParameters[0].Value = messageInfo.MessageId;
            messageParameters[1].Value = (int)messageInfo.MessageType;
            messageParameters[2].Value = messageInfo.ShortDesc;
            messageParameters[3].Value = messageInfo.MessageText;
            messageParameters[4].Value = messageInfo.Status;
            messageParameters[5].Value = userId;
            messageParameters[6].Value = messageInfo.IsImage;
            messageParameters[8].Value = messageInfo.IsDefaultMessage;
            if (messageInfo.FileName != string.Empty)
            {
                messageParameters[7].Value = messageInfo.FileName;
            }

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    try
                    {
                        int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("Message", "SP_INSERT_MESSAGE"), messageParameters);
                        success = (noOfRecords > 0);
                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.MessageManagement, messageInfo.ShortDesc, "Inserted message",
                                                                       userId, userId);
                        AuditTrail.WriteEntry(auditEntry, sqlTran);
                        sqlTran.Commit();
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        throw;
                    }
                }
            }
            return(success);
        }
Example #10
0
        /// <summary>
        /// Updates security details of the registration account.
        /// </summary>
        /// <param name="registration">Registration Information of the user.</param>
        public void UpdateSecretDetails(RegistrationInfo registration)
        {
            SqlParameter[] parameters = SQLHelper.GetCachedParameters("SQL_UPDATE_SECURITYQUESTION");

            if (parameters == null)
            {
                parameters = new SqlParameter[] {
                    new SqlParameter("@passwordQuestion", SqlDbType.NVarChar, 255),
                    new SqlParameter("@passwordAnswer", SqlDbType.NVarChar, 256),
                    new SqlParameter("@UserId", SqlDbType.Int)
                };
            }
            parameters[0].Value = registration.PasswordQuestion;
            parameters[1].Value = registration.PasswordAnswer;
            parameters[2].Value = registration.UserId;

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SQL_UPDATE_SECURITYQUESTION"),
                                                  parameters);

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ChangeSecretQuestion, registration.UserName, "Updated Security Details", registration.UserId, registration.UserId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #11
0
        public bool UpdateCartItem(List <ShoppingCartItemInfo> cartItems, int ownerId)
        {
            bool success = false;

            SqlParameter[] messageParamater = new SqlParameter[] { new SqlParameter("@product_id", SqlDbType.NVarChar, 30),
                                                                   new SqlParameter("@user_id", SqlDbType.Int),
                                                                   new SqlParameter("@quantity", SqlDbType.Int) };
            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    foreach (ShoppingCartItemInfo cartItem in cartItems)
                    {
                        try
                        {
                            messageParamater[0].Value = cartItem.ProductId;
                            messageParamater[1].Value = cartItem.UserId;
                            messageParamater[2].Value = cartItem.Quantity;

                            int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                        SQLHelper.GetSQLStatement("ShoppingCart", "SP_UPDATE_CARTITEM"), messageParamater);
                            AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ShoppingCart, cartItem.ProductId,
                                                                           "Inserted cart item", cartItem.UserId, ownerId);
                            AuditTrail.WriteEntry(auditEntry, sqlTran);
                            success = (noOfRecords > 0);
                        }
                        catch
                        {
                            sqlTran.Rollback();
                            throw;
                        }
                    }
                    sqlTran.Commit();
                }
            }
            return(success);
        }
Example #12
0
        /// <summary>
        /// Updates the status of the specified registration account.
        /// </summary>
        /// <param name="userId">Internal identifier of the user.</param>
        /// <param name="status">Status of the user.</param>
        public void UpdateStatus(int userId, RegistrationStatus status, int userLoginId)
        {
            string statusText = "";

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        UpdateStatus(userId, status, transaction);

                        if (status == RegistrationStatus.Active)
                        {
                            statusText = "User Activated or Approved";
                        }
                        else
                        if (status == RegistrationStatus.Inactive)
                        {
                            statusText = "User Inactivated";
                        }

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.UserManagement, userId.ToString(), statusText, userId, userLoginId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #13
0
        /// <summary>
        /// Inserts an order for the specified user.
        /// </summary>
        /// <param name="userId">Internal identifier of the user.</param>
        /// <param name="order">Order Information for the user.</param>
        public int Insert(int userId, OrderInfo order, int ownerId)
        {
            int orderId = 0;

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        // Get the  details of the credit card.
                        Registration registration = new DAL.Registration();

                        // Insert Order Details.
                        SqlParameter[] parameters = SQLHelper.GetCachedParameters("SQL_INSERT_ORDER");

                        if (parameters == null)
                        {
                            parameters = new SqlParameter[] {
                                new SqlParameter("@OrderId", SqlDbType.Int),
                                new SqlParameter("@OrderNumber", SqlDbType.Int),
                                new SqlParameter("@OrderType", SqlDbType.Int),
                                new SqlParameter("@OrderDate", SqlDbType.DateTime),
                                new SqlParameter("@Amount", SqlDbType.Decimal),
                                new SqlParameter("@TransactionCode", SqlDbType.Int),
                                new SqlParameter("@TransactionMessage", SqlDbType.NVarChar, 255),
                                new SqlParameter("@CreditCardTypeId", SqlDbType.Int),
                                new SqlParameter("@CreditCardNo", SqlDbType.NVarChar, 20),
                                new SqlParameter("@CVVNo", SqlDbType.NVarChar, 4),
                                new SqlParameter("@HolderName", SqlDbType.NVarChar, 50),
                                new SqlParameter("@ExpirationMonth", SqlDbType.Int),
                                new SqlParameter("@ExpirationYear", SqlDbType.Int),
                                new SqlParameter("@BillingAddress1", SqlDbType.NVarChar, 255),
                                new SqlParameter("@BillingAddress2", SqlDbType.NVarChar, 255),
                                new SqlParameter("@BillingCity", SqlDbType.NVarChar, 100),
                                new SqlParameter("@BillingStateId", SqlDbType.Int),
                                new SqlParameter("@BillingZip", SqlDbType.NVarChar, 15),
                                new SqlParameter("@BillingCountryId", SqlDbType.Int),
                                new SqlParameter("@UserId", SqlDbType.Int)
                            };

                            SQLHelper.CacheParameters("SQL_INSERT_ORDER", parameters);
                        }

                        parameters[0].Direction = ParameterDirection.Output;
                        parameters[1].Value     = order.Number;
                        parameters[2].Value     = order.Type;
                        parameters[3].Value     = order.Date;
                        parameters[4].Value     = order.Amount;
                        parameters[5].Value     = order.TransactionCode;
                        parameters[6].Value     = order.TransactionMessage;
                        parameters[7].Value     = order.CreditCard.Type.LookupId;
                        parameters[8].Value     = order.CreditCard.Number;
                        parameters[9].Value     = order.CreditCard.CvvNumber;
                        parameters[10].Value    = order.CreditCard.HolderName;
                        parameters[11].Value    = order.CreditCard.ExpirationMonth;
                        parameters[12].Value    = order.CreditCard.ExpirationYear;
                        parameters[13].Value    = order.CreditCard.Address.Address1;
                        parameters[14].Value    = order.CreditCard.Address.Address2;
                        parameters[15].Value    = order.CreditCard.Address.City;
                        parameters[16].Value    = order.CreditCard.Address.State.StateId;
                        parameters[17].Value    = order.CreditCard.Address.Zip;
                        parameters[18].Value    = order.CreditCard.Address.Country.CountryId;
                        parameters[19].Value    = userId;

                        SQLHelper.ExecuteNonQuery(transaction, CommandType.Text,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SQL_INSERT_ORDER"),
                                                  parameters);
                        orderId = (int)parameters[0].Value;

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.OrderManagement, orderId.ToString(), "Inserted order header",
                                                                       userId, ownerId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        if (order.Items != null)
                        {
                            parameters = SQLHelper.GetCachedParameters("SQL_INSERT_ORDER_DETAIL");

                            if (parameters == null)
                            {
                                parameters = new SqlParameter[] {
                                    new SqlParameter("@OrderId", SqlDbType.Int),
                                    new SqlParameter("@line_number", SqlDbType.Int),
                                    new SqlParameter("@ItemId", SqlDbType.NVarChar, 30),
                                    new SqlParameter("@Quantity", SqlDbType.Int),
                                    new SqlParameter("@Rate", SqlDbType.Decimal)
                                };

                                SQLHelper.CacheParameters("SQL_INSERT_ORDER_DETAIL", parameters);
                            }
                            int lineNumber = 1;
                            foreach (OrderItemInfo orderItem in order.Items)
                            {
                                parameters[0].Value = orderId;
                                parameters[1].Value = lineNumber;
                                parameters[2].Value = orderItem.ItemId;
                                parameters[3].Value = orderItem.Quantity;
                                parameters[4].Value = orderItem.Rate;

                                SQLHelper.ExecuteNonQuery(transaction, CommandType.Text,
                                                          SQLHelper.GetSQLStatement(MODULE_NAME, "SQL_INSERT_ORDER_DETAIL"),
                                                          parameters);

                                auditEntry = new AuditEntryInfo(Module.OrderManagement, orderId.ToString(), "Inserted order detail",
                                                                userId, ownerId);
                                AuditTrail.WriteEntry(auditEntry, transaction);

                                Product product = new Product();
                                if (order.Type == OrderType.ShoppingCart && order.TransactionStatus)
                                {
                                    ProductInfo productInfo = product.GetProductDetails(orderItem.ItemId);
                                    foreach (ProductItemInfo productItemInfo in productInfo.ProductItems)
                                    {
                                        SqlParameter[] messageParameters = GetCartItemParams();
                                        messageParameters[0].Value = userId;
                                        messageParameters[1].Value = productItemInfo.ProductTypeId;
                                        messageParameters[2].Value = orderItem.Quantity * productItemInfo.Quantity;
                                        SQLHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure,
                                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SP_INSERT_UPDATE_INVENTORY"), messageParameters);
                                        auditEntry = new AuditEntryInfo(Module.OrderManagement, productItemInfo.ProductTypeId.ToString(),
                                                                        "Updated inventory", userId, ownerId);
                                        AuditTrail.WriteEntry(auditEntry, transaction);
                                    }
                                }
                            }
                        }

                        // Update the user status if the type of payment is Membership Fees.
                        if (order.Type == OrderType.MembershipFee)
                        {
                            //registration.UpdateStatus(userId,
                            //    RegistrationStatus.MembershipPaid, transaction);
                        }
                        if (order.Type == OrderType.ShoppingCart)
                        {
                            ShoppingCart cart = new ShoppingCart();
                            cart.DeleteCartItem(userId, string.Empty, new Product(), ownerId);
                        }
                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
            return(orderId);
        }
Example #14
0
        /// <summary>
        /// Updates the design of the specified user.
        /// </summary>
        /// <param name="userId">Internal identifier of the user.</param>
        /// <param name="design">Design of the user.</param>
        public void Update(int userId, DesignInfo design)
        {
            SqlParameter[] parameters = SQLHelper.GetCachedParameters("SP_UPDATE_DESIGN");

            if (parameters == null)
            {
                parameters = new SqlParameter[] {
                    new SqlParameter("@design_id", SqlDbType.Int),
                    new SqlParameter("@user_id", SqlDbType.Int),
                    new SqlParameter("@category", SqlDbType.Int),
                    new SqlParameter("@type", SqlDbType.Int),
                    new SqlParameter("@length", SqlDbType.Decimal),
                    new SqlParameter("@width", SqlDbType.Decimal),
                    new SqlParameter("@gender", SqlDbType.NVarChar, 50),
                    new SqlParameter("@on_design_name", SqlDbType.NVarChar, 50),
                    new SqlParameter("@justification", SqlDbType.Int),
                    new SqlParameter("@gutter", SqlDbType.NVarChar, 50),
                    new SqlParameter("@msg_locn_x", SqlDbType.Decimal),
                    new SqlParameter("@msg_locn_y", SqlDbType.Decimal),
                    new SqlParameter("@msg_size_length", SqlDbType.Decimal),
                    new SqlParameter("@msg_size_width", SqlDbType.Decimal),
                    new SqlParameter("@low_res_file", SqlDbType.NVarChar, 255),
                    new SqlParameter("@high_res_file", SqlDbType.NVarChar, 255),
                    new SqlParameter("@extra_file", SqlDbType.NVarChar, 255),
                    new SqlParameter("@status", SqlDbType.Int),
                    new SqlParameter("@last_modify_by", SqlDbType.Int),
                    new SqlParameter("@approve_by", SqlDbType.Int),
                    new SqlParameter("@comments", SqlDbType.Text)
                };

                SQLHelper.CacheParameters("SP_UPDATE_DESIGN", parameters);
            }

            parameters[0].Value  = design.DesignId;
            parameters[1].Value  = design.UserId;
            parameters[2].Value  = design.Category.LookupId;
            parameters[3].Value  = design.Type.LookupId;
            parameters[4].Value  = design.Size.Width;
            parameters[5].Value  = design.Size.Height;
            parameters[6].Value  = design.Gender;
            parameters[7].Value  = design.OnDesignName;
            parameters[8].Value  = design.Justification;
            parameters[9].Value  = design.Gutter;
            parameters[10].Value = design.MessageRectangle.X;
            parameters[11].Value = design.MessageRectangle.Y;
            parameters[12].Value = design.MessageRectangle.Width;
            parameters[13].Value = design.MessageRectangle.Height;
            parameters[14].Value = design.LowResolutionFile;
            parameters[15].Value = design.HighResolutionFile;
            parameters[16].Value = design.ExtraFile;
            parameters[17].Value = design.Status.LookupId;
            parameters[18].Value = design.LastModifyBy;
            parameters[19].Value = design.ApproveBy;
            parameters[20].Value = design.Comments;

            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction,
                                                  CommandType.StoredProcedure,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SP_UPDATE_DESIGN"),
                                                  parameters);

                        // Write entry into audit trail.
                        string action = string.Empty;

                        if (design.DesignId == 0)
                        {
                            if (design.Status.LookupId == 23)
                            {
                                action = "Submitted design";
                            }
                            else
                            {
                                action = "Added design";
                            }
                        }
                        else
                        {
                            if (design.Status.LookupId == 23)
                            {
                                if (design.UserId == design.LastModifyBy)
                                {
                                    action = "Submitted design";
                                }
                                else
                                {
                                    action = "Modified design";
                                }
                            }
                            else if (design.Status.LookupId == 25)
                            {
                                action = "Archived design";
                            }
                            else if (design.Status.LookupId == 26)
                            {
                                action = "Approved design";
                            }
                            else
                            {
                                action = "Modified design";
                            }
                        }

                        AuditEntryInfo auditEntry = new AuditEntryInfo(
                            Module.DesignManagement, design.Category.Name,
                            action, design.UserId, design.LastModifyBy);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #15
0
        /// <summary>
        /// Updates a registration account.
        /// </summary>
        /// <param name="registration">Registration Information of the user.</param>
        public void Update(RegistrationInfo registration, int userLoginId)
        {
            SqlParameter[] parameters = SQLHelper.GetCachedParameters("SP_UPDATE_ACCOUNT");

            if (parameters == null)
            {
                parameters = new SqlParameter[] {
                    new SqlParameter("@UserId", SqlDbType.Int),
                    new SqlParameter("@FirstName", SqlDbType.NVarChar, 50),
                    new SqlParameter("@MiddleName", SqlDbType.NVarChar, 50),
                    new SqlParameter("@LastName", SqlDbType.NVarChar, 50),
                    new SqlParameter("@CompanyName", SqlDbType.NVarChar, 200),
                    new SqlParameter("@Address1", SqlDbType.NVarChar, 255),
                    new SqlParameter("@Address2", SqlDbType.NVarChar, 255),
                    new SqlParameter("@City", SqlDbType.NVarChar, 100),
                    new SqlParameter("@StateId", SqlDbType.Int),
                    new SqlParameter("@Zip", SqlDbType.NVarChar, 15),
                    new SqlParameter("@CountryId", SqlDbType.Int),
                    new SqlParameter("@Phone", SqlDbType.NVarChar, 20),
                    new SqlParameter("@Fax", SqlDbType.NVarChar, 20),
                    new SqlParameter("@Mobile", SqlDbType.NVarChar, 20),
                    new SqlParameter("@Email", SqlDbType.NVarChar, 256),
                    new SqlParameter("@Role", SqlDbType.Int),
                    new SqlParameter("@Status", SqlDbType.Int)
                };
            }
            SQLHelper.CacheParameters("SP_UPDATE_ACCOUNT", parameters);

            parameters[0].Value  = registration.UserId;
            parameters[1].Value  = registration.FirstName;
            parameters[2].Value  = registration.MiddleName;
            parameters[3].Value  = registration.LastName;
            parameters[4].Value  = registration.CompanyName;
            parameters[5].Value  = registration.Address.Address1;
            parameters[6].Value  = registration.Address.Address2;
            parameters[7].Value  = registration.Address.City;
            parameters[8].Value  = registration.Address.State.StateId;
            parameters[9].Value  = registration.Address.Zip;
            parameters[10].Value = registration.Address.Country.CountryId;
            parameters[11].Value = registration.Address.Phone;
            parameters[12].Value = registration.Address.Fax;
            parameters[13].Value = registration.Address.Mobile;
            parameters[14].Value = registration.Email;
            parameters[15].Value = registration.Role;
            parameters[16].Value = registration.Status;


            using (SqlConnection connection = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                connection.Open();

                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        SQLHelper.ExecuteNonQuery(transaction, CommandType.StoredProcedure,
                                                  SQLHelper.GetSQLStatement(MODULE_NAME, "SP_UPDATE_ACCOUNT"),
                                                  parameters);

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.UpdateProfile, registration.UserName, "Updated Profile", registration.UserId, userLoginId);
                        AuditTrail.WriteEntry(auditEntry, transaction);

                        transaction.Commit();
                    }
                    catch (SqlException ex)
                    {
                        transaction.Rollback();

                        throw;
                    }
                }
            }
        }
Example #16
0
        public bool UpdateProduct(ProductInfo productInfo)
        {
            bool success = false;

            SqlParameter[] messageParameters = GetProductHeaderParams();
            messageParameters[0].Value = productInfo.ProductId;
            if (productInfo.BriefDesc != string.Empty)
            {
                messageParameters[1].Value = productInfo.BriefDesc;
            }
            messageParameters[2].Value = productInfo.ExtDesc;
            messageParameters[3].Value = (int)productInfo.ProductStatus;
            messageParameters[4].Value = productInfo.TotalPrice;
            messageParameters[5].Value = productInfo.OwnerId;

            using (SqlConnection conn = new SqlConnection(SQLHelper.CONNECTION_STRING))
            {
                conn.Open();
                using (SqlTransaction sqlTran = conn.BeginTransaction())
                {
                    bool isCustom = false;
                    try
                    {
                        int noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("Product", "SP_UPDATE_PRODUCTHEADER"), messageParameters);

                        AuditEntryInfo auditEntry = new AuditEntryInfo(Module.ProductCatalog, productInfo.ProductId,
                                                                       "Updated product header", productInfo.OwnerId, productInfo.OwnerId);
                        AuditTrail.WriteEntry(auditEntry, sqlTran);
                        success = true;

                        foreach (ProductItemInfo itemInfo in productInfo.ProductItems)
                        {
                            SqlParameter[] messageDetailsParameters = GetProductDetailsParams();
                            messageDetailsParameters[0].Value = productInfo.ProductId;
                            messageDetailsParameters[1].Value = 0;
                            messageDetailsParameters[2].Value = itemInfo.ProductTypeId;
                            messageDetailsParameters[3].Value = itemInfo.Quantity;
                            if (itemInfo.Size.Count > 0)
                            {
                                messageDetailsParameters[4].Value = itemInfo.Size[0];
                            }
                            if (itemInfo.IsCustomSize || isCustom)
                            {
                                messageDetailsParameters[5].Value = itemInfo.AgentUserId;
                                isCustom = true;
                            }
                            else
                            {
                                messageDetailsParameters[5].Value = DBNull.Value;
                            }
                            noOfRecords = SQLHelper.ExecuteNonQuery(sqlTran, CommandType.StoredProcedure,
                                                                    SQLHelper.GetSQLStatement("Product", "SP_UPDATE_PRODUCTDETAILS"), messageDetailsParameters);
                            auditEntry = new AuditEntryInfo(Module.ProductCatalog, productInfo.ProductId + "-" + itemInfo.ProductTypeId,
                                                            "Updated product details", productInfo.OwnerId, isCustom ? itemInfo.AgentUserId : productInfo.OwnerId);
                            AuditTrail.WriteEntry(auditEntry, sqlTran);
                        }
                        sqlTran.Commit();
                        success = true;
                    }
                    catch
                    {
                        sqlTran.Rollback();
                        success = false;
                        throw;
                    }
                }
            }
            return(success);
        }