Esempio n. 1
0
    protected void EntryMode(bool IsUpdate)
    {
        if (IsUpdate == true)
        {
            btnSave.Text      = "Update";
            hfIsUpadate.Value = "Y";
            txtEmpID.ReadOnly = false;
        }
        else
        {
            btnSave.Text      = "Save";
            hfIsUpadate.Value = "N";
            txtEmpID.ReadOnly = false;
            imgEmp.ImageUrl   = ConfigurationManager.AppSettings["EmpImagePath"].Trim() + "/NoImage.jpg";
            hfEmpImage.Value  = "";
            ImgSign.ImageUrl  = ConfigurationManager.AppSettings["EmpSignPath"].Trim() + "/NoImage.jpg";

            FileUpload1.Dispose();
            FileUpload2.Dispose();
            imgByte                = null;
            imgSignByte            = null;
            Session["imgByte"]     = "";
            Session["imgSignByte"] = "";
        }
    }
Esempio n. 2
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                //upload pics
                if (FileUpload1.HasFile)
                {
                    string fileName    = FileUpload1.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload1.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/ProfilePic/") + txtGuestId.Text + "_Profile.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload1.FileContent.Dispose();
                    FileUpload1.Dispose();
                }

                if (FileUpload2.HasFile)
                {
                    string fileName    = FileUpload2.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload2.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/IDPic/") + txtGuestId.Text + "_IDPic.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload2.FileContent.Dispose();
                    FileUpload2.Dispose();
                }

                var g = (from gu in db.Guests
                         where gu.Id.Equals(Request.QueryString["guestid"])
                         select gu).FirstOrDefault();

                g.GuestId                 = txtGuestId.Text;
                g.FirstName               = txtFirstName.Text;
                g.MiddleName              = txtMiddleName.Text;
                g.LastName                = txtLastName.Text;
                g.CompanyId               = Convert.ToInt32(ddlCompanyName.SelectedValue);
                g.ContactNumber           = txtContactNo.Text;
                g.Email                   = txtEmail.Text;
                g.ValidIDNumber           = txtIdNumber.Text;
                g.PicFilePath             = txtGuestId.Text + "_Profile.png";
                g.IDFilePath              = txtGuestId.Text + "_IDPic.png";
                g.EmergencyContactPerson  = txtContactPerson.Text;
                g.EmergencyContactNumber  = txtContactPersonNumber.Text;
                g.EmergencyContactAddress = txtContactPersonAddress.Text;
                g.CreatedBy               = User.Identity.Name;

                db.SubmitChanges();

                //audit trail
                DBLogger.Log("Update", "Updated Individual Guest", g.GuestId);

                pnlSuccess.Visible = true;

                //load images
                if (!File.Exists(Server.MapPath("~/ProfilePic/") + g.GuestId + "_Profile.png"))
                {
                    imgProfile.ImageUrl = "~/ProfilePic/noImage.png";
                }
                else
                {
                    imgProfile.ImageUrl = "~/ProfilePic/" + g.GuestId + "_Profile.png?t=" + DateTime.Now.ToString();
                }

                if (!File.Exists(Server.MapPath("~/IDPic/") + g.GuestId + "_IDPic.png"))
                {
                    IDPic.ImageUrl = "~/IDPic/noImage.png";
                }
                else
                {
                    IDPic.ImageUrl = "~/IDPic/" + g.GuestId + "_IDPic.png?t=" + DateTime.Now.ToString();
                }
            }
        }
Esempio n. 3
0
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (Page.IsValid)
            {
                //upload pics
                if (FileUpload1.HasFile)
                {
                    string fileName    = FileUpload1.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload1.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/ProfilePic/") + txtGuestId.Text + "_Profile.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload1.FileContent.Dispose();
                    FileUpload1.Dispose();
                }

                if (FileUpload2.HasFile)
                {
                    string fileName    = FileUpload2.FileName;
                    Bitmap originalBMP = new Bitmap(FileUpload2.FileContent);

                    // Calculate the new image dimensions
                    decimal origWidth      = originalBMP.Width;
                    decimal origHeight     = originalBMP.Height;
                    decimal sngRatio       = origWidth / origHeight;
                    int     newWidth       = 200;
                    decimal newHeight_temp = newWidth / sngRatio;
                    int     newHeight      = Convert.ToInt32(newHeight_temp);

                    Bitmap   newBMP    = new Bitmap(originalBMP, newWidth, newHeight);
                    Graphics oGraphics = Graphics.FromImage(newBMP);

                    oGraphics.SmoothingMode     = SmoothingMode.AntiAlias;
                    oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    oGraphics.DrawImage(originalBMP, 0, 0, newWidth, newHeight);

                    newBMP.Save(Server.MapPath("~/IDPic/") + txtGuestId.Text + "_IDPic.png");

                    originalBMP.Dispose();
                    newBMP.Dispose();
                    oGraphics.Dispose();

                    FileUpload2.FileContent.Dispose();
                    FileUpload2.Dispose();
                }

                Guest g = new Guest();
                g.GuestId                 = txtGuestId.Text;
                g.FirstName               = txtFirstName.Text;
                g.MiddleName              = txtMiddleName.Text;
                g.LastName                = txtLastName.Text;
                g.CompanyId               = Convert.ToInt32(ddlCompanyName.SelectedValue);
                g.ContactNumber           = txtContactNo.Text;
                g.Email                   = txtEmail.Text;
                g.ValidIDNumber           = txtIdNumber.Text;
                g.PicFilePath             = txtGuestId.Text + "_Profile.png";
                g.IDFilePath              = txtGuestId.Text + "_IDPic.png";
                g.EmergencyContactPerson  = txtContactPerson.Text;
                g.EmergencyContactNumber  = txtContactPersonNumber.Text;
                g.EmergencyContactAddress = txtContactPersonAddress.Text;
                g.CreateDate              = DateTime.Now;
                g.CreatedBy               = User.Identity.Name;
                g.IsCompany               = false;

                db.Guests.InsertOnSubmit(g);
                db.SubmitChanges();

                //audit trail
                DBLogger.Log("Create", "Created Individual Guest", g.GuestId);

                Response.Redirect("~/guest/default.aspx");
                //pnlSuccess.Visible = true;
                //clearButtons();
            }
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                string institutename  = txtinstitutename.Text;
                string category       = Txtcategory.Text;
                string educationgroup = txteducationgroup.Text;
                string description    = txtinstdescp.Text;
                string address        = txtaddress.Text;
                string state          = ddlstate.SelectedItem.ToString();
                string city           = ddlcity.SelectedItem.ToString();
                string area           = txtarea.Text;
                string town           = txttown.Text;
                string country        = txtcountry.Text;
                long   zipcode        = long.Parse(txtzipcode.Text.ToString());
                string affiliatedto   = ddlaffiliatedto.SelectedItem.ToString();
                string board          = ddlboard.SelectedItem.ToString();
                string classfrom      = ddlclassfrom.SelectedItem.ToString();
                string medium         = ddlmedium.SelectedItem.ToString();
                string classto        = ddlclassto.SelectedItem.ToString();
                string schooltype     = ddlschooltype.SelectedItem.ToString();
                string classification = ddlclassification.SelectedItem.ToString();
                string admissionproc  = txtadmprocedure.Text;
                string docrequired    = txtdocsreq.Text;
                int    agecriteria    = int.Parse(txtagecriteria.Text.ToString());

                DateTime admstartdate = DateTime.Parse(txtadmstartdate.Text.ToString());
                //string admstdate = admstartdate.ToString("YYYY-MM-DD");

                DateTime admenddate = DateTime.Parse(txtadmenddate.Text.ToString());
                //string admedate = admenddate.ToString("YYYY-MM-DD");

                string contactname = txtyourname.Text;
                string email       = txtemail.Text;
                string phone       = txtphone.Text;
                string website     = txtwebsite.Text;
                string designation = txtdesignation.Text;
                string facebook    = txtfacebook.Text;
                string twitter     = txttwitter.Text;
                string linkedin    = txtlinkedin.Text;
                string skype       = txtskype.Text;
                string gmaps       = txtgmapslink.Text;
                con.Open();
                SqlCommand cmd0 = new SqlCommand(@"INSERT INTO Schoolmaster(Schoolname,Category,Educationgroup,Ins_description,Address,State,City,Area,Town,Country,Zipcode,Googlemaps,Affiliatedto,Board,Medium,Class_from,Class_to,School_type,Classification,Adm_procedure,Docs_required,Age_criteria,Admstartdate,Admenddate,Contact_name,Contact_email,Contact_Phone,Designation,Website,Facebook,Twitter,Linkedin,Skype,Listingpriority,Package) values('" + institutename + "','" + category + "','" + educationgroup + "','" + description + "','" + address + "','" + state + "','" + city + "','" + area + "','" + town + "','" + country + "','" + zipcode + "','" + gmaps + "','" + affiliatedto + "','" + board + "','" + medium + "','" + classfrom + "','" + classto + "','" + schooltype + "','" + classification + "','" + admissionproc + "','" + docrequired + "','" + agecriteria + "','" + admstartdate + "','" + admenddate + "','" + contactname + "','" + email + "','" + phone + "','" + designation + "','" + website + "','" + facebook + "','" + twitter + "','" + linkedin + "','" + skype + "','low','Free');", con);
                cmd0.ExecuteNonQuery();



                SqlCommand cmd1 = new SqlCommand("Select MAX(SchoolId) from Schoolmaster;", con);
                cmd1.ExecuteNonQuery();


                SqlDataReader dr0 = cmd1.ExecuteReader();
                while (dr0.Read())   // This is how record is read. Loop through the each record
                {
                    var schoolid = long.Parse(dr0[0].ToString());
                    lblclassid.Text = schoolid.ToString();
                }
                dr0.Close();


                int Class_id = int.Parse(lblclassid.Text.ToString());



                /////Loading CoachingFacilities

                for (int i = 0; i < cblfacilities.Items.Count; i++)
                {
                    if (cblfacilities.Items[i].Selected == true)
                    {
                        SqlCommand cmd2 = new SqlCommand("insert into Schoolfacilities values ('" + Class_id + "','" + cblfacilities.Items[i].ToString() + "')", con);
                        cmd2.ExecuteNonQuery();
                    }
                }

                ///////////Condition for checking values in fileupload box and then loading the table////////////
                if (FileUpload1.HasFile && FileUpload2.HasFile && FileUpload3.HasFile)
                {
                    FileInfo fi1    = new FileInfo(FileUpload1.FileName);
                    string   name1  = fi1.Name;
                    byte[]   image1 = FileUpload1.FileBytes;

                    FileInfo fi2    = new FileInfo(FileUpload2.FileName);
                    string   name2  = fi2.Name;
                    byte[]   image2 = FileUpload2.FileBytes;

                    FileInfo fi3    = new FileInfo(FileUpload3.FileName);
                    string   name3  = fi3.Name;
                    byte[]   image3 = FileUpload3.FileBytes;

                    SqlCommand com = new SqlCommand("Insert into Schoolimages (SchoolId,Schoollogo, School_Image1,School_Image2) values (@SchoolId,@Schoollogo, @School_Image1,@School_Image2)", con);
                    com.Parameters.AddWithValue("@SchoolId", SqlDbType.VarChar).Value        = lblclassid.Text;
                    com.Parameters.AddWithValue("@Schoollogo", SqlDbType.VarBinary).Value    = image1;
                    com.Parameters.AddWithValue("@School_Image1", SqlDbType.VarBinary).Value = image2;
                    com.Parameters.AddWithValue("@School_Image2", SqlDbType.VarBinary).Value = image3;
                    com.ExecuteNonQuery();
                }

                else if (FileUpload1.HasFile && !FileUpload2.HasFile && !FileUpload3.HasFile)
                {
                    FileInfo fi1    = new FileInfo(FileUpload1.FileName);
                    string   name1  = fi1.Name;
                    byte[]   image1 = FileUpload1.FileBytes;

                    //FileInfo fi2 = new FileInfo(FileUpload2.FileName);
                    //string name2 = fi2.Name;
                    //byte[] image2 = FileUpload2.FileBytes;

                    //FileInfo fi3 = new FileInfo(FileUpload3.FileName);
                    //string name3 = fi3.Name;
                    //byte[] image3 = FileUpload3.FileBytes;

                    SqlCommand com = new SqlCommand("Insert into Schoolimages (SchoolId,Schoollogo ) values (@SchoolId,@Schoollogo)", con);
                    com.Parameters.AddWithValue("@SchoolId", SqlDbType.VarChar).Value     = lblclassid.Text;
                    com.Parameters.AddWithValue("@Schoollogo", SqlDbType.VarBinary).Value = image1;
                    //com.Parameters.AddWithValue("@School_Image1", SqlDbType.VarBinary).Value = image2;
                    //com.Parameters.AddWithValue("@School_Image2", SqlDbType.VarBinary).Value = image3;
                    com.ExecuteNonQuery();
                }
                else if (!FileUpload1.HasFile && FileUpload2.HasFile && !FileUpload3.HasFile)
                {
                    FileInfo fi2    = new FileInfo(FileUpload2.FileName);
                    string   name2  = fi2.Name;
                    byte[]   image2 = FileUpload2.FileBytes;



                    SqlCommand com = new SqlCommand("Insert into Schoolimages (SchoolId, School_Image1) values (@SchoolId, @School_Image1)", con);
                    com.Parameters.AddWithValue("@SchoolId", SqlDbType.VarChar).Value = lblclassid.Text;

                    com.Parameters.AddWithValue("@School_Image1", SqlDbType.VarBinary).Value = image2;

                    com.ExecuteNonQuery();
                }
                else if (!FileUpload1.HasFile && !FileUpload2.HasFile && FileUpload3.HasFile)
                {
                    FileInfo fi3    = new FileInfo(FileUpload3.FileName);
                    string   name3  = fi3.Name;
                    byte[]   image3 = FileUpload3.FileBytes;

                    SqlCommand com = new SqlCommand("Insert into Schoolimages (SchoolId,School_Image2) values (@SchoolId,@School_Image2)", con);
                    com.Parameters.AddWithValue("@SchoolId", SqlDbType.VarChar).Value = lblclassid.Text;

                    com.Parameters.AddWithValue("@School_Image2", SqlDbType.VarBinary).Value = image3;
                    com.ExecuteNonQuery();
                }
                else if (FileUpload1.HasFile && !FileUpload2.HasFile && !FileUpload3.HasFile)
                {
                    FileInfo fi1    = new FileInfo(FileUpload1.FileName);
                    string   name1  = fi1.Name;
                    byte[]   image1 = FileUpload1.FileBytes;


                    SqlCommand com = new SqlCommand("Insert into Schoolimages (SchoolId,Schoollogo) values (@SchoolId,@Schoollogo)", con);
                    com.Parameters.AddWithValue("@SchoolId", SqlDbType.VarChar).Value     = lblclassid.Text;
                    com.Parameters.AddWithValue("@Schoollogo", SqlDbType.VarBinary).Value = image1;
                    com.ExecuteNonQuery();
                }


                con.Close();


                string display = "School Details Added Successfully!";
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true);


                txtinstitutename.Text           = "";
                Txtcategory.Text                = "";
                txteducationgroup.Text          = "";
                txtinstdescp.Text               = "";
                txtaddress.Text                 = "";
                ddlstate.SelectedIndex          = 0;
                ddlcity.SelectedIndex           = 0;
                txtarea.Text                    = "";
                txttown.Text                    = "";
                txtcountry.Text                 = "";
                txtzipcode.Text                 = "";
                ddlaffiliatedto.SelectedIndex   = 0;
                ddlboard.SelectedIndex          = 0;
                ddlclassfrom.SelectedIndex      = 0;
                ddlclassto.SelectedIndex        = 0;
                ddlschooltype.SelectedIndex     = 0;
                ddlclassification.SelectedIndex = 0;
                txtadmprocedure.Text            = "";
                txtdocsreq.Text                 = "";
                txtagecriteria.Text             = "";
                txtadmstartdate.Text            = "";
                txtadmenddate.Text              = "";

                txtyourname.Text    = "";
                txtemail.Text       = "";
                txtphone.Text       = "";
                txtwebsite.Text     = "";
                txtdesignation.Text = "";
                txtfacebook.Text    = "";
                txttwitter.Text     = "";
                txtlinkedin.Text    = "";
                txtskype.Text       = "";
                FileUpload1.Dispose();
                FileUpload2.Dispose();
                FileUpload3.Dispose();
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + ex.Message + "');", true);
            }
        }
 protected void Button2_Click(object sender, EventArgs e)
 {
     FileUpload2.Dispose();
 }
Esempio n. 6
0
    public void fileupload2()
    {
        SqlConnection conn = new SqlConnection(constr);

        try
        {
            if (FileUpload2.HasFile)
            {
                FileUpload2.Dispose();
                string fileName = FileUpload2.ResolveClientUrl(FileUpload2.PostedFile.FileName);

                DataTable datatble = new DataTable();
                DataSet   ds       = new DataSet();
                //string SourceConstr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + fileName + "';Extended Properties= 'Excel 8.0;HDR=Yes;IMEX=1'";
                //OleDbConnection con = new OleDbConnection(SourceConstr);
                ////con.Open();
                ////string query = "Select Partno,Description from [Sheet1$]";
                //string query = "Select * from [ofarticles$]";
                //OleDbDataAdapter data = new OleDbDataAdapter(query, SourceConstr);
                //data.Fill(datatble);
                //ds.Tables.Add(datatble);

                //string filename = Path.GetFileName(FileUpload2.PostedFile.FileName);
                //FileUpload2.SaveAs(Server.MapPath("uploads/" + filename));
                //string filepath = "uploads/" + filename;

                //string file = FileUpload2.PostedFile.FileName;
                //string serverpath = Server.MapPath("~/uploads/" + file);
                //if (File.Exists(serverpath))
                //    File.Delete(serverpath);

                //FileUpload2.SaveAs(Server.MapPath("~/uploads/" + file));
                //string filepath = Server.MapPath("~/uploads/" + file);
                //DataTable res = ConvertCSVtoDataTable(filepath);
                //ds.Tables.Add(res);



                string file       = FileUpload2.PostedFile.FileName;
                string serverpath = Server.MapPath("~/uploads/" + file);
                if (File.Exists(serverpath))
                {
                    File.Delete(serverpath);
                }
                FileUpload2.SaveAs(Server.MapPath("~/uploads/" + file));
                string filePath = Server.MapPath("~/uploads/" + file);


                bool   hasHeaders = false;
                string HDR        = hasHeaders ? "Yes" : "No";
                // string HDR = "Yes";
                string strConn;
                if (filePath.Substring(filePath.LastIndexOf('.')).ToLower() == ".xlsx")
                {
                    strConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=\"Excel 12.0;HDR=" + HDR + ";IMEX=0\"";
                }
                else
                {
                    strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filePath + ";Extended Properties=\"Excel 8.0;HDR=" + HDR + ";IMEX=0\"";
                }
                OleDbConnection con = new OleDbConnection(strConn);
                con.Open();
                DataTable schemaTable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });
                DataRow   schemaRow   = schemaTable.Rows[0];
                //DataRow schemaRow = schemaTable.Rows[1];
                string sheet = schemaRow["TABLE_NAME"].ToString();
                if (!sheet.EndsWith("_"))
                {
                    string           query = "SELECT * FROM [" + sheet + "]";
                    OleDbDataAdapter data  = new OleDbDataAdapter(query, con);
                    data.Fill(datatble);
                    DataTable filteredRows = datatble.Rows.Cast <DataRow>()
                                             .Where(row => !row.ItemArray.All(field => field is System.DBNull))
                                             .CopyToDataTable();
                    ds.Tables.Add(filteredRows);
                }

                SqlDataAdapter daa1 = new SqlDataAdapter("Select * from tbl_PartNo ", conn);
                DataSet        dss  = new DataSet();
                daa1.Fill(dss);

                if (dss.Tables[0].Rows.Count > 0)
                {
                    dss.Locale = System.Globalization.CultureInfo.InvariantCulture;
                    SqlCommand     cmd1 = new SqlCommand("Truncate table tbl_PartNo", conn);
                    SqlDataAdapter daa3 = new SqlDataAdapter(cmd1);
                    conn.Close();
                    conn.Open();
                    cmd1.ExecuteNonQuery();
                    conn.Close();
                }
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    string Partno      = Convert.ToString(ds.Tables[0].Rows[i][2].ToString());
                    string Description = Convert.ToString(ds.Tables[0].Rows[i][3].ToString());

                    ds.Locale = System.Globalization.CultureInfo.InvariantCulture;
                    SqlCommand     cmd = new SqlCommand("insert into tbl_PartNo(Partno,Description)values ('" + Partno + "','" + Description + "')", conn);
                    SqlDataAdapter daa = new SqlDataAdapter(cmd);
                    conn.Close();
                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
                if (HttpContext.Current.Session["User_Name"].ToString() != "" && HttpContext.Current.Session["User_Name"].ToString() != null)
                {
                    objofarticle            = new ofarticle_grid();
                    objofarticle.FileUpload = "Part No";
                    objofarticle.UserName   = HttpContext.Current.Session["User_Name"].ToString();
                    objofarticle.Time       = HttpContext.Current.Session["Logtime"].ToString();
                    objofarticle.Date       = HttpContext.Current.Session["LogDate"].ToString();

                    objQualitySheetdclassDataContext.ofarticle_grids.InsertOnSubmit(objofarticle);
                    objQualitySheetdclassDataContext.SubmitChanges();
                    objQualitySheetdclassDataContext = null;
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Part No File Uploaded Successfully !');", true);

                    Loadofarticle();
                }
            }
        }

        catch (Exception ex)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('Invalid file !');", true);
            Exception ex2          = ex;
            string    errorMessage = string.Empty;
            while (ex2 != null)
            {
                errorMessage += ex2.ToString();
                ex2           = ex2.InnerException;
            }
            HttpContext.Current.Response.Write(errorMessage);
        }
        finally
        {
            //conn.Close();
            FileUpload2.Dispose();
        }
    }