Example #1
0
    protected void ImageButtonLogo_Click(object sender, ImageClickEventArgs e)
    {
        if (FileUploadLogo.HasFile)
        {
            if (System.IO.Path.GetExtension(FileUploadLogo.FileName) == ".png")
            {
                try
                {
                    FileUploadLogo.SaveAs(Server.MapPath("~/images/logomain.png"));
                }
                catch (Exception ex)
                {
                }
                ImageLogo.ImageUrl        = "~/images/logomain.png";
                LabelMessageLogo.Text     = "فایل لوگو تغییر یافت.";
                LabelMessageLogo.CssClass = "SuccessMessage";

                //insert log
                AdminLogInsert ali = new AdminLogInsert();
                ali.insertAdminLog(Convert.ToInt32(Session["UserId"]), 1901, 0, "0");
            }
            else
            {
                LabelMessageLogo.Text     = "لطفاً فایلی با فرمت PNG انتخاب نمایید.";
                LabelMessageLogo.CssClass = "ErrorMessage";
            }
        }
        else
        {
            LabelMessageLogo.Text     = "لطفاً فایل مورد نظر را انتخاب کنید.";
            LabelMessageLogo.CssClass = "ErrorMessage";
        }
    }
Example #2
0
    protected void ButtonUpload_Command(object sender, CommandEventArgs e)
    {
        warning.Visible = false;

        using (System.Drawing.Image myImage = System.Drawing.Image.FromStream(FileUploadLogo.PostedFile.InputStream))
        {
            if (Path.GetExtension(FileUploadLogo.FileName) == ".jpg")
            {
                if (myImage.Height == 115 && myImage.Width == 380)
                {
                    string   path = Server.MapPath("~/images/logo.jpg");
                    FileInfo file = new FileInfo(path);

                    if (file.Exists)
                    {
                        file.Delete();
                    }

                    FileUploadLogo.SaveAs(Server.MapPath("~/Images/") + "logo.jpg");
                }
                else
                {
                    warning.Visible      = true;
                    LabeWarningLogo.Text = "Ukuran image salah. Ukuran height 115px dan width 380px";
                }
            }
            else
            {
                warning.Visible      = true;
                LabeWarningLogo.Text = "Format image harus .jpg";
            }
        }

        ImageLogo.ImageUrl = "~/images/logo.jpg";
    }
Example #3
0
        protected void UploadLogo()
        {
            // Specify the path
            String savePath = Server.MapPath("~/Pictures/");

            // Verify that the FileUpload control contains a file.
            if (FileUploadLogo.HasFile)
            {
                // Get the name of the file to upload.
                String fileName = FileUploadLogo.FileName;

                // Get the extension of the uploaded file.
                string extension = System.IO.Path.GetExtension(fileName);

                if ((extension == ".jpg") || (extension == ".png"))
                {
                    // Add the path to the name of the file to upload
                    savePath += fileName;

                    // Call the SaveAs method to save the uploaded file to the path.
                    FileUploadLogo.SaveAs(savePath);

                    LabelMessageCompany.Text = "The file was saved as " + fileName;
                }
                else
                {
                    LabelMessageCompany.Text = "The file was not uploaded because it does not have a .jpg or .png extension.";
                }
            }
            else
            {
                // Notify the user that a file was not uploaded.
                LabelMessageCompany.Text = "Please specify a file to upload.";
            }
        }
Example #4
0
 /// <summary>
 /// Event when user select Upload Logo File  button. It uploads the picture file to the
 /// Images directory and writes the file name for the File Name text box and updates that column
 /// in the database.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void UploadLogoButton_Click(object sender, EventArgs e)
 {
     if (FileUploadLogo.HasFile)
     {
         try
         {
             string filename = Path.GetFileName(FileUploadLogo.FileName);
             FileUploadLogo.SaveAs(Server.MapPath("~/Images/") + filename);
             ErrorLabel.Text = "Upload status: Logo File uploaded!";
             SiteDL.UpdateLogoPath(filename);
             FormView1.DataBind();
         }
         catch (Exception ex)
         {
             ErrorLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
         }
     }
     else
     {
         ErrorLabel.Text = "Could not find file";
     }
     upPayPal.Update();
 }
Example #5
0
    private bool SaveData()
    {
        objSettings           = new tblSettings();
        objEncrypt            = new clsEncryption();
        objSettings.Query.Top = 1;
        objSettings.Query.Load();
        if (objSettings.RowCount == 0)
        {
            objSettings = new tblSettings();
            objSettings.AddNew();
            objSettings.AppCreatedDate = DateTime.Now;
            objSettings.s_AppCreatedBy = Session[appFunctions.Session.UserID.ToString()].ToString();
        }
        objSettings.AppSiteName             = txtSiteName.Text;
        objSettings.AppFooterText           = txtFooter.Text;
        objSettings.AppIsSiteOffline        = chkSiteOffline.Checked;
        objSettings.AppSiteOfflineMessage   = txtSiteOfflineMessage.Text;
        objSettings.AppSiteTagLine          = txtSiteTagLine.Text;
        objSettings.AppSiteDefaultListLimit = ddlPerMenu.SelectedValue;
        objSettings.AppPathToFolder         = txtPathToFolder.Text;
        objSettings.AppIsCOD = CHkIsCOD.Checked;
        if (txtClientSiteUrl.Text.Contains("http://"))
        {
            objSettings.AppClientSiteURL = txtClientSiteUrl.Text;
        }
        else
        {
            objSettings.AppClientSiteURL = "http://" + txtClientSiteUrl.Text;
        }

        objSettings.AppEmailPassword  = objEncrypt.Encrypt(txtEmailPassword.Text, appFunctions.strKey);
        objSettings.AppSMTP           = txtSMTP.Text;
        objSettings.AppSiteEmail      = txtSiteEmail.Text;
        objSettings.AppRecepientEmail = txtRecepientEmail.Text;
        objSettings.AppPortNumber     = txtPortNumber.Text;
        string strFilePath = Server.MapPath("~/Uploads/ConfigurationsSetting");

        if (FileUploadOfflineImage.HasFile)
        {
            FileUploadOfflineImage.SaveAs(strFilePath + "/Offline.jpg");
            objSettings.AppSiteOfflineImage = "Uploads/ConfigurationsSetting/Offline.jpg";
        }

        if (FileUploadLogo.HasFile)
        {
            FileUploadLogo.SaveAs(strFilePath + "/Logo.jpg");
            objSettings.AppSiteLogo = "Uploads/ConfigurationsSetting/Logo.jpg";
        }

        if (FileUploadFavicon.HasFile)
        {
            FileUploadFavicon.SaveAs(strFilePath + "/Favicon.ico");
            objSettings.AppSiteFavicon = "Uploads/ConfigurationsSetting/Favicon.ico";
        }


        //if (chkDataBaseSettings.Checked)
        //{
        //    SaveDataBaseSettings();
        //}

        objSettings.Save();
        SetUpSiteSettings();


        objSettings = null;
        return(true);
    }
Example #6
0
        protected void ButtonAddNewLab_Click(object sender, EventArgs e)
        {
            if (TextBoxUserName.Text != "" && TextBoxPassword.Text != "" && TextBoxLabName.Text != "" && TextBoxOwnerName.Text != "" && TextBoxMobile.Text != "" && TextBoxPhone.Text != "" && TextBoxEmail.Text != "" && DropDownListState.SelectedIndex > 0 && TextBoxAddress.Text != "" && TextBoxValidity.Text != "")
            {
                if (FileUploadLogo.HasFile)
                {
                    string docfilename = Path.GetFileName(FileUploadLogo.PostedFile.FileName);
                    fileextension = System.IO.Path.GetExtension(docfilename);

                    if (fileextension.ToLower() == ".jpg" || fileextension.ToLower() == ".jpeg" || fileextension.ToLower() == ".png")
                    {

                        string dirPath = Server.MapPath(directoryUrl);

                        if (!Directory.Exists(dirPath))
                        {
                            Directory.CreateDirectory(dirPath);
                        }

                        LogoUrl = directoryUrl + DateTime.Now.Ticks.ToString() + "." + fileextension.ToLower();
                    }
                    else
                    {
                        messagediv.Visible = true;
                        messagediv.Attributes["class"] = "fixed-message rounded alert bg-danger alert-dismissible animated fadeIn text-center text-white";
                        mesaagetxt.InnerHtml = "Error! unsupported file format.";
                    }
                }

                else
                {
                    LogoUrl = "/Uploaded/images/logo/logo.png";
                }
                string response = operation.AddLab(TextBoxUserName.Text, TextBoxPassword.Text, TextBoxLabName.Text, TextBoxOwnerName.Text, TextBoxMobile.Text, TextBoxPhone.Text, TextBoxEmail.Text, DropDownListState.SelectedValue, TextBoxCity.Text, TextBoxPincode.Text, TextBoxAddress.Text, TextBoxValidity.Text, LogoUrl, TextBoxWebsite.Text);

                string responsemsg = response.Split(',')[0];

                if (responsemsg == "SUCCESS")
                {
                    if (FileUploadLogo.HasFile)
                    {
                        FileUploadLogo.SaveAs(Server.MapPath(LogoUrl));
                    }
                    messagediv.Visible = true;
                    messagediv.Attributes["class"] = "fixed-message rounded alert bg-success alert-dismissible animated fadeIn text-center text-white";
                    mesaagetxt.InnerHtml = "Success! Lab Id : " + response.Split(',')[1];
                }

                else if (responsemsg == "DUPLICATE")
                {
                    messagediv.Visible = true;
                    messagediv.Attributes["class"] = "fixed-message rounded alert bg-danger alert-dismissible animated fadeIn text-center text-white";
                    mesaagetxt.InnerHtml = "username already taken.";
                }
                else if (responsemsg == "ERROR")
                {
                    messagediv.Visible = true;
                    messagediv.Attributes["class"] = "fixed-message rounded alert bg-danger alert-dismissible animated fadeIn text-center text-white";
                    mesaagetxt.InnerHtml = "Error! something went wrong please try again later.";
                }
            }

            else
            {
                messagediv.Visible = true;
                messagediv.Attributes["class"] = "fixed-message rounded alert bg-danger alert-dismissible animated fadeIn text-center text-white";
                mesaagetxt.InnerHtml = "Error! Please fill required field.";
            }
        }