protected void OrderNotesGrid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName.Equals("AddNote"))
     {
         string[] data    = ((string)e.CommandArgument).Split(':');
         int      orderId = AlwaysConvert.ToInt(data[0]);
         HiddenOrderId.Value   = orderId.ToString();
         AddDialogCaption.Text = String.Format(AddDialogCaption.Text, data[1]);
         List <string> history = new List <string>();
         Order         order   = EntityLoader.Load <Order>(orderId);
         if (order != null)
         {
             IList <OrderNote> notes = order.Notes;
             notes.Sort(new PropertyComparer("CreatedDate", CommerceBuilder.Common.SortDirection.DESC));
             foreach (OrderNote note in notes)
             {
                 if (note.NoteType != NoteType.SystemPrivate && note.NoteType != NoteType.SystemPublic)
                 {
                     StringBuilder historyEntry = new StringBuilder();
                     historyEntry.Append("<i>On " + note.CreatedDate.ToString("g") + ", ");
                     historyEntry.Append(note.User.PrimaryAddress.FullName);
                     historyEntry.Append(note.NoteType == NoteType.Public ? " wrote" : " whispered");
                     historyEntry.Append(":</i><br />");
                     historyEntry.Append(note.Comment);
                     history.Add(historyEntry.ToString());
                 }
             }
         }
         NoteHistory.Text = string.Join("<hr>", history.ToArray());
         AddPopup.Show();
         NoteText.Focus();
     }
 }
Exemplo n.º 2
0
        private void ShowAddForm(string fileName)
        {
            FileInfo fi = new FileInfo(Path.Combine(_DigitalGoodPath, fileName));

            ServerFileName.Text          = fileName;
            ServerFileSize.Text          = FileHelper.FormatFileSize(fi.Length);
            Name.Text                    = Path.GetFileNameWithoutExtension(fileName);
            DownloadName.Text            = fileName;
            ActivationMode.SelectedIndex = 2;
            AddPopup.Show();
        }
        protected void ShowProductForm(Product product)
        {
            if (product.IsSubscription)
            {
                if (product.SubscriptionPlan.IsRecurring && product.SubscriptionPlan.PaymentFrequencyType == PaymentFrequencyType.Optional)
                {
                    string value = Request.Form[AutoDeliveryInterval.UniqueID];
                    BindAutoDelieveryOptions(product);

                    if (!string.IsNullOrEmpty(value))
                    {
                        ListItem item = AutoDeliveryInterval.Items.FindByValue(value);
                        if (item != null)
                        {
                            item.Selected = true;
                        }
                    }
                }
                else
                {
                    AutoDeliveryPH.Visible = false;
                }

                OptionalSubscription.Visible = product.SubscriptionPlan.IsOptional;
            }
            else
            {
                trSubscriptionRow.Visible = false;
            }

            AddPopup.Show();
            //SET NAME AND PRICE
            AddProductName.Text = product.Name;
            // SET QUANTITY TO ONE IF NOT SPECIFIED
            if (string.IsNullOrEmpty(AddProductQuantity.Text) || AddProductQuantity.Text == "0")
            {
                AddProductQuantity.Text = "1";
            }
            AddProductId.Value = product.Id.ToString();
            //BUILD PRODUCT ATTRIBUTES
            _SelectedOptions = AbleCommerce.Code.ProductHelper.BuildProductOptions(product, phOptions, true);
            //BUILD PRODUCT CHOICES
            AbleCommerce.Code.ProductHelper.BuildProductChoices(product, phOptions);
            //BUILD KIT OPTIONS, IGNORING INVENTORY
            _SelectedKitProducts = AbleCommerce.Code.ProductHelper.BuildKitOptions(product, phOptions, true);
            //SET PRICE
            string optionList = ProductVariantDataSource.GetOptionList(product.Id, _SelectedOptions, true);

            // IF ALL OPTIONS HAVE A VALUE SELECTED, SHOW THE BASKET CONTROLS
            AddProductSaveButton.Visible = (_SelectedOptions.Count == product.ProductOptions.Count);
        }
 protected void ShowDisplayOptions_Click(object sender, ImageClickEventArgs e)
 {
     ShowDisplayOptions.Visible = false;
     HideDisplayOptions.Visible = true;
     trDisplayOptions1a.Visible = true;
     trDisplayOptions1b.Visible = true;
     trDisplayOptions2.Visible  = true;
     trDisplayOptions3a.Visible = true;
     trDisplayOptions3b.Visible = true;
     trDisplayOptions4a.Visible = true;
     trDisplayOptions4b.Visible = true;
     trDisplayOptions5.Visible  = true;
     AddPopup.Show();
 }
 protected void ShowAddDialog_Click(object sender, EventArgs e)
 {
     AddPopup.Show();
     AddComment.Focus();
 }
Exemplo n.º 6
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            // CHECK IF PAGE IS VALID
            if (Page.IsValid)
            {
                // MAKE SURE PASSWORD VALIDATES AGAINST POLICY
                if (ValidatePassword())
                {
                    // ATTEMPT TO CREATE THE USER
                    MembershipCreateStatus status;
                    User newUser = UserDataSource.CreateUser(AddEmail.Text, AddEmail.Text, AddPassword.Text, string.Empty, string.Empty, true, 0, out status);
                    if (status == MembershipCreateStatus.Success)
                    {
                        // FORCE PASSWORD EXPIRATION
                        newUser.Passwords[0].ForceExpiration = ForceExpiration.Checked;
                        newUser.Passwords[0].Save();

                        // ASSIGN GROUPS TO NEW USER
                        IList <Group> availableGroups = SecurityUtility.GetManagableGroups();
                        int           groupId         = AlwaysConvert.ToInt(AddGroup.SelectedValue);
                        if (groupId > 0)
                        {
                            int index = availableGroups.IndexOf(groupId);
                            if (groupId > -1)
                            {
                                // ADD THE GROUP ASSOCIATION FOR THE NEW USER
                                newUser.UserGroups.Add(new UserGroup(newUser, availableGroups[index]));
                                newUser.Save();
                            }
                        }

                        // REDIRECT TO EDIT FORM IF INDICATED
                        if (((Button)sender).ID == "AddEditButton")
                        {
                            Response.Redirect("EditUser.aspx?UserId=" + newUser.Id.ToString());
                        }

                        // NO REDIRECT, DISPLAY A CONFIRMATION FOR CREATED USER
                        UserAddedMessage.Text    = string.Format(UserAddedMessage.Text, newUser.UserName);
                        UserAddedMessage.Visible = true;

                        // RESET THE ADD FORM FIELDS
                        AddEmail.Text           = String.Empty;
                        AddPassword.Text        = String.Empty;
                        AddConfirmPassword.Text = String.Empty;
                        AddGroup.SelectedIndex  = -1;

                        //REBIND THE SEARCH
                        UserGrid.DataBind();
                    }
                    else
                    {
                        // CREATE USER FAILED WITHIN THE API
                        switch (status)
                        {
                        case MembershipCreateStatus.DuplicateEmail:
                        case MembershipCreateStatus.DuplicateUserName:
                            AddCustomValidationError(phEmailValidation, AddEmail, "The email address is already registered.");
                            break;

                        case MembershipCreateStatus.InvalidEmail:
                        case MembershipCreateStatus.InvalidUserName:
                            AddCustomValidationError(phEmailValidation, AddEmail, "The email address is invalid.");
                            break;

                        case MembershipCreateStatus.InvalidPassword:
                            AddCustomValidationError(phPasswordValidation, AddPassword, "The password is invalid.");
                            break;

                        default:
                            AddCustomValidationError(phEmailValidation, AddEmail, "Unexpected error: " + status.ToString());
                            break;
                        }
                        AddPopup.Show();
                    }
                }
                else
                {
                    AddPopup.Show();
                }
            }
            else
            {
                AddPopup.Show();
            }
        }
        protected void AddButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (!DigitalGoodNameExists(Name.Text))
                {
                    // SET THE DIGITAL GOOD PATH
                    string digitalGoodPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data\\DigitalGoods");

                    // SAVE THE BINARY FILE DATA
                    HttpPostedFile file = null;
                    if (Request.Files.Count > 0)
                    {
                        file = Request.Files[0];
                    }
                    bool fileUploaded = ((file != null) && (file.ContentLength > 0));
                    if (fileUploaded)
                    {
                        string fileName = string.IsNullOrEmpty(UploadFileName.Text) ? Path.GetFileName(file.FileName) : UploadFileName.Text;
                        string filePath = Path.Combine(digitalGoodPath, fileName);
                        if (FileHelper.IsExtensionValid(fileName, AbleContext.Current.Store.Settings.FileExt_DigitalGoods))
                        {
                            if (!File.Exists(filePath) || UploadOverwrite.Checked)
                            {
                                int    fileLength = file.ContentLength;
                                Byte[] buffer     = new byte[fileLength];
                                file.InputStream.Read(buffer, 0, fileLength);
                                File.WriteAllBytes(filePath, buffer);
                                // RECORD THE DIGITAL GOOD
                                DigitalGood dg = new DigitalGood();
                                dg.ServerFileName   = fileName;
                                dg.Name             = Name.Text;
                                dg.FileSize         = fileLength;
                                dg.FileName         = fileName;
                                dg.ActivationModeId = AlwaysConvert.ToByte(ActivationMode.SelectedValue);
                                dg.MaxDownloads     = AlwaysConvert.ToByte(MaxDownloads.Text);
                                int tempDays    = AlwaysConvert.ToInt(ActivationTimeoutDays.Text);
                                int tempHours   = AlwaysConvert.ToInt(ActivationTimeoutHours.Text);
                                int tempMinutes = AlwaysConvert.ToInt(ActivationTimeoutMinutes.Text);
                                if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0))
                                {
                                    dg.ActivationTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes);
                                }
                                else
                                {
                                    dg.ActivationTimeout = string.Empty;
                                }
                                tempDays    = AlwaysConvert.ToInt(DownloadTimeoutDays.Text);
                                tempHours   = AlwaysConvert.ToInt(DownloadTimeoutHours.Text);
                                tempMinutes = AlwaysConvert.ToInt(DownloadTimeoutMinutes.Text);
                                if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0))
                                {
                                    dg.DownloadTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes);
                                }
                                else
                                {
                                    dg.DownloadTimeout = string.Empty;
                                }
                                dg.Save();
                                // SEE WHETHER WE ARE SUPPOSED TO EDIT AFTER SAVING
                                if (((WebControl)sender).ID == "AddAndEditButton")
                                {
                                    // REDIRECT TO THE EDIT PAGE
                                    Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + dg.Id);
                                }
                                else
                                {
                                    // REDIRECT BACK TO THIS PAGE TO PREVENT REFRESH ISSUES WITH FILE UPLOAD
                                    Response.Redirect(Request.ServerVariables["SCRIPT_NAME"]);
                                }
                            }
                            else
                            {
                                CustomValidator overwrite = new CustomValidator();
                                overwrite.IsValid           = false;
                                overwrite.ControlToValidate = "UploadFileName";
                                overwrite.ErrorMessage      = "The target file '" + fileName + "' already exists.  Either allow overwrite or use an alternate file name.";
                                overwrite.Text            = "*";
                                overwrite.ValidationGroup = "Add";
                                phUploadOverwrite.Controls.Add(overwrite);
                                AddPopup.Show();
                            }
                        }
                        else
                        {
                            CustomValidator filetype = new CustomValidator();
                            filetype.IsValid           = false;
                            filetype.ControlToValidate = "UploadFileName";
                            filetype.ErrorMessage      = "The target file '" + fileName + "' does not have a valid file extension.";
                            filetype.Text            = "*";
                            filetype.ValidationGroup = "Add";
                            phUploadFileTypes.Controls.Add(filetype);
                            AddPopup.Show();
                        }
                    }
                    UploadFileName.Text     = string.Empty;
                    UploadOverwrite.Checked = false;
                }
                else
                {
                    CustomValidator uniqueName = new CustomValidator();
                    uniqueName.IsValid           = false;
                    uniqueName.ControlToValidate = "Name";
                    uniqueName.ErrorMessage      = "The specified display name already exists.  You must use an alternate name.";
                    uniqueName.Text            = "*";
                    uniqueName.ValidationGroup = "Add";
                    phUniqueName.Controls.Add(uniqueName);
                    AddPopup.Show();
                }
            }
            else
            {
                AddPopup.Show();
            }
        }
Exemplo n.º 8
0
        protected void AddButton_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                if (!DigitalGoodNameExists(Name.Text))
                {
                    string      fileName = Path.GetFileName(ServerFileName.Text);
                    DigitalGood dg       = new DigitalGood();
                    dg.ServerFileName   = _RelativeDigitalGoodPath + fileName;
                    dg.Name             = Name.Text;
                    dg.FileSize         = new FileInfo(Path.Combine(_DigitalGoodPath, fileName)).Length;
                    dg.FileName         = string.IsNullOrEmpty(DownloadName.Text) ? fileName : DownloadName.Text;
                    dg.ActivationModeId = AlwaysConvert.ToByte(ActivationMode.SelectedValue);
                    dg.MaxDownloads     = AlwaysConvert.ToByte(MaxDownloads.Text);
                    int tempDays    = AlwaysConvert.ToInt(ActivationTimeoutDays.Text);
                    int tempHours   = AlwaysConvert.ToInt(ActivationTimeoutHours.Text);
                    int tempMinutes = AlwaysConvert.ToInt(ActivationTimeoutMinutes.Text);
                    if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0))
                    {
                        dg.ActivationTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes);
                    }
                    else
                    {
                        dg.ActivationTimeout = string.Empty;
                    }
                    tempDays    = AlwaysConvert.ToInt(DownloadTimeoutDays.Text);
                    tempHours   = AlwaysConvert.ToInt(DownloadTimeoutHours.Text);
                    tempMinutes = AlwaysConvert.ToInt(DownloadTimeoutMinutes.Text);
                    if ((tempDays > 0) || (tempHours > 0) || (tempMinutes > 0))
                    {
                        dg.DownloadTimeout = string.Format("{0},{1},{2}", tempDays, tempHours, tempMinutes);
                    }
                    else
                    {
                        dg.DownloadTimeout = string.Empty;
                    }
                    dg.Save();

                    // SEE WHETHER WE ARE SUPPOSED TO EDIT AFTER SAVING
                    if (((WebControl)sender).ID == "AddAndEditButton")
                    {
                        // REDIRECT TO THE EDIT PAGE
                        Response.Redirect("~/Admin/DigitalGoods/EditDigitalGood.aspx?DigitalGoodId=" + dg.Id);
                    }

                    // UPDATE THE FILE LIST
                    int index = IndexOfFile(fileName);
                    if (index > -1)
                    {
                        FileDigitalGood fdg = _FileList[index];
                        if (fdg.DigitalGoods == null)
                        {
                            fdg.DigitalGoods = new List <DigitalGood>();
                        }
                        fdg.DigitalGoods.Add(dg);
                    }

                    // REBIND THE FILE GRID
                    BindFileGrid();
                }
                else
                {
                    CustomValidator uniqueName = new CustomValidator();
                    uniqueName.IsValid           = false;
                    uniqueName.ControlToValidate = "Name";
                    uniqueName.ErrorMessage      = "The specified name already exists.  You must use an alternate name.";
                    uniqueName.Text            = "*";
                    uniqueName.ValidationGroup = "Add";
                    phUniqueName.Controls.Add(uniqueName);
                    AddPopup.Show();
                }
            }
            else
            {
                AddPopup.Show();
            }
        }