Esempio n. 1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// cmdUpdate_Click runs when the Update button is clicked.
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	9/17/2004	Updated to reflect design changes for Help, 508 support
        ///                       and localisation
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void OnUpdateClick(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    int portalID;
                    if (Globals.IsHostTab(PortalSettings.ActiveTab.TabID))
                    {
                        portalID = -1;
                    }
                    else
                    {
                        portalID = PortalId;
                    }
                    var objVendors = new VendorsController();
                    var objVendor  = new VendorInfo
                    {
                        PortalId   = portalID,
                        VendorId   = VendorID,
                        VendorName = txtVendorName.Text,
                        Unit       = addresssVendor.Unit,
                        Street     = addresssVendor.Street,
                        City       = addresssVendor.City,
                        Region     = addresssVendor.Region,
                        Country    = addresssVendor.Country,
                        PostalCode = addresssVendor.Postal,
                        Telephone  = addresssVendor.Telephone,
                        Fax        = addresssVendor.Fax,
                        Cell       = addresssVendor.Cell,
                        Email      = txtEmail.Text,
                        Website    = txtWebsite.Text,
                        FirstName  = txtFirstName.Text,
                        LastName   = txtLastName.Text,
                        UserName   = UserInfo.UserID.ToString(),
                        LogoFile   = ctlLogo.Url,
                        KeyWords   = txtKeyWords.Text,
                        Authorized = chkAuthorized.Checked
                    };
                    if (VendorID == -1)
                    {
                        try
                        {
                            VendorID = objVendors.AddVendor(objVendor);
                        }
                        catch (Exception exc)
                        {
                            //AddModuleMessage("ErrorAddVendor", ModuleMessage.ModuleMessageType.RedError);
                            Exceptions.ProcessModuleLoadException(this, exc);
                            return;
                        }
                    }
                    else
                    {
                        VendorInfo vendorCheck = objVendors.GetVendor(VendorID, portalID);
                        if (vendorCheck != null)
                        {
                            objVendors.UpdateVendor(objVendor);
                        }
                        else
                        {
                            Response.Redirect(Globals.NavigateURL());
                        }
                    }

                    if (cmdUpdate.Text == "Signup")
                    {
                        var custom = new ArrayList();
                        custom.Add(DateTime.Now.ToString());
                        custom.Add(txtVendorName.Text);
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(addresssVendor.Unit);
                        custom.Add(addresssVendor.Street);
                        custom.Add(addresssVendor.City);
                        custom.Add(addresssVendor.Region);
                        custom.Add(addresssVendor.Country);
                        custom.Add(addresssVendor.Postal);
                        custom.Add(addresssVendor.Telephone);
                        custom.Add(addresssVendor.Fax);
                        custom.Add(addresssVendor.Cell);
                        custom.Add(txtEmail.Text);
                        custom.Add(txtWebsite.Text);
                        //send email to Admin
                        Mail.SendEmail(PortalSettings.Email,
                                       PortalSettings.Email,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_ADMINISTRATOR_BODY", Localization.GlobalResourceFile, custom));


                        //send email to vendor
                        custom.Clear();
                        custom.Add(txtFirstName.Text);
                        custom.Add(txtLastName.Text);
                        custom.Add(txtVendorName.Text);

                        Mail.SendEmail(PortalSettings.Email,
                                       txtEmail.Text,
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_SUBJECT"),
                                       Localization.GetSystemMessage(PortalSettings, "EMAIL_VENDOR_REGISTRATION_BODY", Localization.GlobalResourceFile, custom));


                        ReturnUrl(txtVendorName.Text.Substring(0, 1));
                    }
                    else
                    {
                        ReturnUrl(Convert.ToString(ViewState["filter"]));
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }