protected void lvWork_ItemInserting(object sender, ListViewInsertEventArgs e) { TextBox txtCompanyName = (TextBox)e.Item.FindControl("txtCompanyName1") as TextBox; TextBox txtPosition = (TextBox)e.Item.FindControl("txtPosition") as TextBox; TextBox txtCity = (TextBox)e.Item.FindControl("txtCity") as TextBox; TextBox txtJoining = (TextBox)e.Item.FindControl("txtStartDate") as TextBox; TextBox txtLeaving = (TextBox)e.Item.FindControl("txtEndDate") as TextBox; String CompanyName = "", Position = "", City = "", Joining = "", Leaving = ""; String PK = gObj.getNextPK("Work"); CompanyName = txtCompanyName.Text; Position = txtPosition.Text; City = txtCity.Text; Joining = txtJoining.Text; Leaving = txtLeaving.Text; String cmdStr = "INSERT INTO Work VALUES('" + myUserID + "', '" + CompanyName + "', '" + City + "', '" + Joining + "'," + " '" + Leaving + "', '" + Position + "', '" + PK + "')"; SqlCommand scom = new SqlCommand(cmdStr, con); con.Open(); Boolean flg = false; //If there is an error no PostBack// if ((CompanyName == "") || (Position == "") || (City == "") || (Joining == "")) { lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } try { if (!flg) { scom.ExecuteNonQuery(); } } catch { //Most Probably it is the date issue// //Give a msg saying the date should be in correct format// //And Recheck other entries// lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } finally { con.Close(); } if (!flg) { Server.Transfer("editEducationWork.aspx"); } }
protected void lvEducation_ItemInserting(object sender, ListViewInsertEventArgs e) { String InstitutionName = "", DegreeTitle = "", Category = "", Batch = ""; TextBox txtInstitutionName = (TextBox)e.Item.FindControl("txtInstitution") as TextBox; TextBox txtDegreeTitle = (TextBox)e.Item.FindControl("txtDegree") as TextBox; DropDownList DDCategory = (DropDownList)e.Item.FindControl("DDCategory") as DropDownList; TextBox txtBatch = (TextBox)e.Item.FindControl("txtBatch") as TextBox; InstitutionName = txtInstitutionName.Text; DegreeTitle = txtDegreeTitle.Text; Category = DDCategory.Text; Batch = txtBatch.Text; String PK = gObj.getNextPK("Education"); String cmdStr = "Insert into Education values ('" + myUserID + "', '" + Category + "'," + " '" + Batch + "', '" + DegreeTitle + "', '" + InstitutionName + "', '" + PK + "')"; SqlCommand scom = new SqlCommand(cmdStr, con); con.Open(); Boolean flg = false; //If there is an error no PostBack// if ((InstitutionName == "") || (DegreeTitle == "") || (Category == "") || (Batch == "")) { lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } try { if (!flg) { scom.ExecuteNonQuery(); } } catch { //Most Probably it is the date issue// //Give a msg saying the date should be in correct format// //And Recheck other entries// lblErrorInsert.Text = "Check the Entries, Date should be (MM/DD/YYYY)"; lblErrorInsert.Visible = true; flg = true; } finally { con.Close(); } if (!flg) { Server.Transfer("editEducation.aspx"); } }
protected void UploadButton_Click(object sender, EventArgs e) { String GoToPicView = ""; flgErr = false; String FolderID = ""; //The FolderName is the unique identifier// FolderID = gObj.getNextPK("AlbumFolder"); if (txtAlbumName.Text != "") { if (FileUploadProfilePic.HasFile) { try { if (FileUploadProfilePic.PostedFile.ContentType == "image/jpeg") { if (FileUploadProfilePic.PostedFile.ContentLength / 1000 < 1000) { //********CREATING New Album Folder*********// String folder2 = "~/foopicDB/" + Session["UserName"].ToString() + "/" + FolderID; Directory.CreateDirectory(Server.MapPath(folder2)); //***Inserting The Folder Into The Database****// String cmdStr = "INSERT INTO AlbumFolder VALUES('" + FolderID + "','" + myUserID + "','" + txtAlbumName.Text + "','albumcover','" + DateTime.Now.ToString() + "', " + "'nothing', 2)"; SqlCommand scom = new SqlCommand(cmdStr, con); con.Open(); scom.ExecuteNonQuery(); con.Close(); //*************End of Folder Insertion*******// //****Now Trying to Upload the Picture****// String PicID = gObj.getNextPK("AlbumPics"); string filename = PicID + "_" + Path.GetFileName(FileUploadProfilePic.FileName); hidPicName.Value = filename; //**File Name For The Picture**// hidAlbumID.Value = FolderID; //**Saving The FolderID*******// FileUploadProfilePic.SaveAs(Server.MapPath("~/fooPicDB/" + myUserID + "/" + FolderID + "/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; //***Query To Insert The Picture Into the database****// cmdStr = "INSERT INTO AlbumPics VALUES ('" + FolderID + "','" + PicID + "','" + filename + "','nothing','" + myUserID + "','" + DateTime.Now.ToString() + "')"; scom = new SqlCommand(cmdStr, con); con.Open(); scom.ExecuteNonQuery(); con.Close(); //******************End of Picture Insertion*********// //****Inserting the latest picture as FolderImage*****// cmdStr = "UPDATE AlbumFolder SET AlbumCover = '" + filename + "' WHERE AlbumFolder_PK = '" + FolderID + "'"; scom = new SqlCommand(cmdStr, con); con.Open(); scom.ExecuteNonQuery(); con.Close(); GoToPicView = "true"; } else { StatusLabel.Text = "Upload status: The file has to be less than 1 MB!"; flgErr = true; } } else { StatusLabel.Text = "Upload status: Only JPEG files are accepted!"; flgErr = true; } } catch (Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; flgErr = true; } } setPanelView(false, false, true); //pnlNewAlbum.Visible = true; //pnlGallaryMain.Visible = false; //pnlAlbumPicture.Visible = false; setButton(false, false); //butNewAlbum.Visible = false; //butUpdate.Visible = false; flgErr = true; } else { setPanelView(false, false, true); //pnlAlbumPicture.Visible = false; //pnlGallaryMain.Visible = false; //pnlNewAlbum.Visible = true; setButton(false, false); //butNewAlbum.Visible = false; //butUpdate.Visible = false; flgErr = true; } if (GoToPicView == "true") { setPanelView(true, false, false); //pnlAlbumPicture.Visible = true; //pnlGallaryMain.Visible = false; //pnlNewAlbum.Visible = false; setButton(false, false); //butNewAlbum.Visible = false; //butUpdate.Visible = false; createAlbumPictures(FolderID); } }