Esempio n. 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     referencess    = jobs.References();
     languagess     = jobs.Languages();
     BtnAddNew.Text = Resources.Index.AddNewReference;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ddlCategory.Items.Count != 0)
            {
                referencecategoriess = jobs.Referencecategories();

                foreach (var item in referencecategoriess)
                {
                    ddlCategory.Items.Add(item.ReferenceCategoryNameTR.ToString());
                    ddlCategory.Items[ddlCategory.Items.Count - 1].Value = item.id.ToString().Clean();
                }
            }



            btnUpdate.ServerClick += BtnUpdate_ServerClick;
            btnClear.ServerClick  += BtnClear_ServerClick;
            BtnUpload.Text         = Resources.Index.Upload;
            btnClear.Value         = Resources.Index.Clean;

            if (Request.QueryString["Process"] != null)
            {
                string Processs = Request.QueryString["Process"];

                if (Processs == "EditReference")
                {
                    Prcs = AddNewReference.Process.EditReference;
                    id   = Request.QueryString["id"].Clean();
                    Dictionary <string, string> condition = new Dictionary <string, string>();
                    condition.Add("id", id);
                    referencess     = jobs.References(condition);
                    btnUpdate.Value = Resources.Index.Update;
                    if (referencess.Count > 0)
                    {
                        PageTitle = Resources.Index.EditReference;
                        {
                            if (!Page.IsPostBack)
                            {
                                string CategoryName = referencess[0].id.ToString().Clean();
                                ddlCategory.SelectedValue = CategoryName;
                                txtTurkishTitle.Value     = referencess[0].TurkishReferenceName.ToString().Clean();
                                txtEnglishTitle.Value     = referencess[0].EnglishReferenceName.ToString().Clean();
                                txtturkish.Value          = referencess[0].ReferenceDescriptionTR.ToString().Clean();
                                txtenglish.Value          = referencess[0].ReferenceDescriptionEN.ToString().Clean();
                                image1.ImageUrl           = referencess[0].RefereneLogo.ToString().Clean();
                                imageuploading.Visible    = false;
                            }
                        }
                    }
                    else
                    {
                        PageTitle = Resources.Index.DataNotFound;
                        Prcs      = AddNewReference.Process.DataNotFound;
                    }
                }
                else if (Processs == "DeleteReference")
                {
                    PageTitle = Resources.Index.DeleteReference;
                    Prcs      = AddNewReference.Process.DeleteReference;
                    id        = Request.QueryString["id"].Clean();
                    int result = jobs.query("Delete reference where id='" + id + "'");
                    if (result > 0)
                    {
                        Response.Redirect("/ReferenceList.aspx");
                    }
                    else
                    {
                        Response.Write("Error");
                    }
                }
                else
                {
                    Title = Resources.Index.WrongParameter;
                }
            }
            else
            {
                btnUpdate.Value         = Resources.Index.AddReference;
                PageTitle               = Resources.Index.AddNewReference;
                Prcs                    = Process.AddReference;
                Viewingimages.Visible   = false;
                uploadbuttondiv.Visible = false;
            }
            if (FileUpload1.HasFile)
            {
                if (Path.GetExtension(FileUpload1.PostedFile.FileName) == ".jpg" || Path.GetExtension(FileUpload1.PostedFile.FileName) == ".png")
                {
                    Random rndm            = new Random();
                    string PhotoExtensions = Path.GetExtension(FileUpload1.PostedFile.FileName);
                    string PhotoName       = FileUpload1.PostedFile.FileName /*+ rndm.Next(99999999, 999999999) + PhotoExtensions*/;
                    //Firstly we will save chosen images to \\images\\ folder as temporary
                    FileUpload1.SaveAs(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    //After we are converting as bitmap
                    Bitmap Photo  = new Bitmap(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    int    Width  = 215;
                    int    Height = 215;
                    //Resizing the photo
                    Size Size = new Size(Width, Height);
                    //Resmi boyutlandırıyoruz.
                    Bitmap ResizedPhoto         = new Bitmap(Photo, Size);
                    string Resizedandsavedphoto = "~\\Content\\img\\uploads\\" + PhotoName;
                    //We are saving resized photo to \\images\\userphotos\\ folder
                    ResizedPhoto.Save(Server.MapPath(Resizedandsavedphoto), ImageFormat.Jpeg);
                    Photo.Dispose();
                    ResizedPhoto.Dispose();
                    //we delete the photo we saved as temporary
                    FileInfo Firstuploadedphoto = new FileInfo(Server.MapPath("~\\Content\\img\\uploads\\temp\\") + PhotoName);
                    Firstuploadedphoto.Delete();
                    image1.ImageUrl = Resizedandsavedphoto.Clean();
                }
            }
        }