예제 #1
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        if (IsValid)
        {
            try
            {
                System.Drawing.Image image;
                if (fileuploadImage.HasFile)
                {
                    image = System.Drawing.Image.FromStream(fileuploadImage.PostedFile.InputStream);
                }
                else
                {
                    String filePath = WebHelper.Instance.GetWebsitePath() + "App_Themes/images/other/no_image.png";
                    image = System.Drawing.Image.FromFile(filePath);
                }
                String data = WebHelper.Instance.ImageToBase64(image, System.Drawing.Imaging.ImageFormat.Png);
                SB.CreateService(Guid.NewGuid(), txtName.Text.Trim(), txtDescription.Text.Trim(), txtCharge.Text.Trim(), data);

                pnlGreen.Visible       = true;
                lblSuccess.Text        = "Create new a service successfully.";
                hplnkGreen.Text        = "Go to Manage panel.";
                hplnkGreen.NavigateUrl = WebHelper.Instance.GetURL() + "ManageService/Service/Manage";
                Reset();
            }
            catch (Exception ex)
            {
                pnlRed.Visible       = true;
                lblError.Text        = ex.Message;
                hplnkRed.Text        = "Please try again.";
                hplnkRed.NavigateUrl = "";
            }
        }
    }