Example #1
0
    protected void Save_Click(object sender, EventArgs e)
    {
        Suc.Visible = false; SucDel.Visible = false;
        Rett.Text   = "";
        string imgPath = ""; // Define the Employee Photo file

        if (FileUpload1.HasFiles)
        {
            string ext = System.IO.Path.GetExtension(FileUpload1.PostedFile.FileName);
            if (ext != ".exe" || ext != ".php")
            {
                //sets the image path
                var r = new Random();
                // print random integer >= 0 and  < 100


                imgPath = "Uploads/" + r.Next(100) + FileUpload1.FileName;

                //get the size in bytes that
                FileUpload1.SaveAs(Server.MapPath(imgPath));

                var Res = Obj.NewMainReports(Convert.ToInt32(DropYear.SelectedValue), Convert.ToInt32(Sector.SelectedValue), Convert.ToInt32(Mang.SelectedValue), imgPath, FileName.Value);
                if (Res == 0)
                {
                    Rett.Text = "البيانات مسجلة سابقا لنفس الخطة والإدارة العليا والادارة";
                }
                else
                {
                    CloseAll();
                    DropYear.ClearSelection();
                    Sector.ClearSelection();
                    Mang.ClearSelection();
                    FileName.Value = "";
                    FileUpload1.Attributes.Clear();
                    Main.Attributes.Remove("Style");
                    Main.Style.Add("display", "block");
                    Suc.Visible = true; SucDel.Visible = false;
                }
            }
        }
    }