public int Delete_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp) { try { tbl_PhotoGalleryMasterDAL Objtbl_PhotoGalleryMasterDAL = new tbl_PhotoGalleryMasterDAL(); return(Objtbl_PhotoGalleryMasterDAL.Delete_Data(Objtbl_PhotoGalleryMasterProp)); } catch (Exception ex) { throw ex; } }
public DataSet Search_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp) { try { tbl_PhotoGalleryMasterDAL Objtbl_PhotoGalleryMasterDAL = new tbl_PhotoGalleryMasterDAL(); return(Objtbl_PhotoGalleryMasterDAL.Search_Data(Objtbl_PhotoGalleryMasterProp)); } catch (Exception ex) { throw ex; } }
public int Delete_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp) { try { Database DB = DatabaseFactory.CreateDatabase("AppConNagar"); DbCommand DBCmd = DB.GetStoredProcCommand("Delete_tbl_PhotoGalleryMaster"); DB.AddInParameter(DBCmd, "@PhotoCode", DbType.Int32, Objtbl_PhotoGalleryMasterProp.PhotoCode); return(DB.ExecuteNonQuery(DBCmd)); } catch (Exception ex) { throw ex; } }
public DataSet Search_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp) { try { Database DB = DatabaseFactory.CreateDatabase("AppConNagar"); DbCommand DBCmd = DB.GetStoredProcCommand("Search_tbl_PhotoGalleryMaster"); DB.AddInParameter(DBCmd, "@SearchBy", DbType.String, Objtbl_PhotoGalleryMasterProp.SearchBy); DB.AddInParameter(DBCmd, "@SearchVal", DbType.String, Objtbl_PhotoGalleryMasterProp.SearchVal); return(DB.ExecuteDataSet(DBCmd)); } catch (Exception ex) { throw ex; } }
private void FillAlbumImages(int AlbumCode) { try { tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp = new tbl_PhotoGalleryMasterProp(); Objtbl_PhotoGalleryMasterProp.SearchBy = "AlbumCode"; Objtbl_PhotoGalleryMasterProp.SearchVal = Convert.ToString(AlbumCode); tbl_PhotoGalleryMasterBAL Objtbl_PhotoGalleryMasterBAL = new tbl_PhotoGalleryMasterBAL(); DataSet dsData = Objtbl_PhotoGalleryMasterBAL.Search_Data(Objtbl_PhotoGalleryMasterProp); rptImageThumbnail.DataSource = dsData.Tables[0]; rptImageThumbnail.DataBind(); } catch { } }
private void DeleteData(int PhotoCode) { try { tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp = new tbl_PhotoGalleryMasterProp(); Objtbl_PhotoGalleryMasterProp.PhotoCode = PhotoCode; tbl_PhotoGalleryMasterBAL Objtbl_PhotoGalleryMasterBAL = new tbl_PhotoGalleryMasterBAL(); Objtbl_PhotoGalleryMasterBAL.Delete_Data(Objtbl_PhotoGalleryMasterProp); FillData(); } catch (Exception ex) { throw ex; } }
public DataSet Select_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp, ref int TotalCount) { try { Database DB = DatabaseFactory.CreateDatabase("AppConNagar"); DbCommand DBCmd = DB.GetStoredProcCommand("Select_tbl_PhotoGalleryMaster"); DB.AddInParameter(DBCmd, "@PhotoCode", DbType.Int32, Objtbl_PhotoGalleryMasterProp.PhotoCode); DB.AddInParameter(DBCmd, "@PageNo", DbType.Int32, Objtbl_PhotoGalleryMasterProp.PageNo); DB.AddInParameter(DBCmd, "@RecordCount", DbType.Int32, Objtbl_PhotoGalleryMasterProp.RecordCount); DB.AddOutParameter(DBCmd, "@TotalCount", DbType.Int32, 18); DataSet dsData = DB.ExecuteDataSet(DBCmd); TotalCount = Convert.ToInt32(DBCmd.Parameters["@TotalCount"].Value); return(dsData); } catch (Exception ex) { throw ex; } }
public int InsertUpdate_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp) { try { Database DB = DatabaseFactory.CreateDatabase("AppConNagar"); DbCommand DBCmd = DB.GetStoredProcCommand("InsertUpdate_tbl_PhotoGalleryMaster"); DB.AddInParameter(DBCmd, "@PhotoCode", DbType.Int32, Objtbl_PhotoGalleryMasterProp.PhotoCode); DB.AddInParameter(DBCmd, "@PhotoHead", DbType.String, Objtbl_PhotoGalleryMasterProp.PhotoHead); DB.AddInParameter(DBCmd, "@FileName", DbType.String, Objtbl_PhotoGalleryMasterProp.FileName); DB.AddInParameter(DBCmd, "@AlbumCode", DbType.Int32, Objtbl_PhotoGalleryMasterProp.AlbumCode); DB.AddInParameter(DBCmd, "@isVideo", DbType.Boolean, Objtbl_PhotoGalleryMasterProp.isVideo); DB.AddOutParameter(DBCmd, "@RetVal", DbType.Int32, 18); DB.ExecuteNonQuery(DBCmd); return(Convert.ToInt32(DBCmd.Parameters["@RetVal"].Value)); } catch (Exception ex) { throw ex; } }
private void FillData() { try { int PageCount = 0; tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp = new tbl_PhotoGalleryMasterProp(); Objtbl_PhotoGalleryMasterProp.PhotoCode = 0; Objtbl_PhotoGalleryMasterProp.PageNo = Convert.ToInt32(txtCurPage.Text); Objtbl_PhotoGalleryMasterProp.RecordCount = Convert.ToInt32(20); tbl_PhotoGalleryMasterBAL Objtbl_PhotoGalleryMasterBAL = new tbl_PhotoGalleryMasterBAL(); DataSet dsData = Objtbl_PhotoGalleryMasterBAL.Select_Data(Objtbl_PhotoGalleryMasterProp, ref PageCount); lblTotalPage.Text = Convert.ToString(PageCount); grdData.DataSource = dsData.Tables[0]; grdData.DataBind(); } catch (Exception ex) { throw ex; } }
public DataSet Select_Data(tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp, ref int PageCount) { try { if (Objtbl_PhotoGalleryMasterProp.PhotoCode != 0) { Objtbl_PhotoGalleryMasterProp.PageNo = 1; Objtbl_PhotoGalleryMasterProp.RecordCount = 1; } int RecordCount = 0; tbl_PhotoGalleryMasterDAL Objtbl_PhotoGalleryMasterDAL = new tbl_PhotoGalleryMasterDAL(); DataSet dsData = Objtbl_PhotoGalleryMasterDAL.Select_Data(Objtbl_PhotoGalleryMasterProp, ref RecordCount); double Page = Convert.ToDouble(RecordCount) / Convert.ToDouble(Objtbl_PhotoGalleryMasterProp.RecordCount); if (dsData.Tables[0].Rows.Count > 0) { string[] PageDecimal = Page.ToString().Split('.'); if (PageDecimal.Length > 1 && Convert.ToInt32(PageDecimal[1]) > 0) { PageCount = Convert.ToInt32(Page.ToString().Split('.')[0]) + 1; } else { PageCount = Convert.ToInt32(Page); } } else { PageCount = 0; } return(dsData); } catch (Exception ex) { throw ex; } }
private void EditData(int PhotoCode) { try { tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp = new tbl_PhotoGalleryMasterProp(); Objtbl_PhotoGalleryMasterProp.PhotoCode = PhotoCode; int PageCount = 0; tbl_PhotoGalleryMasterBAL Objtbl_PhotoGalleryMasterBAL = new tbl_PhotoGalleryMasterBAL(); DataSet dsData = Objtbl_PhotoGalleryMasterBAL.Select_Data(Objtbl_PhotoGalleryMasterProp, ref PageCount); txtPhotoHead.Text = Convert.ToString(dsData.Tables[0].Rows[0]["PhotoHead"]); ddlAlbumName.SelectedValue = Convert.ToString(dsData.Tables[0].Rows[0]["AlbumCode"]); tdUploadedImage.Visible = true; imgPhotos.ImageUrl = "~/PhotoGallery/" + Convert.ToString(dsData.Tables[0].Rows[0]["FileName"]).Split('.')[0] + "_thumb.jpg"; ViewState["FileName"] = Convert.ToString(dsData.Tables[0].Rows[0]["FileName"]); ViewState["EditCode"] = PhotoCode; } catch (Exception ex) { throw ex; } }
protected void imgbtnSave_Click(object sender, ImageClickEventArgs e) { string sSavePath = ""; string sThumbExtension = ""; string sFilename = ""; int intThumbWidth; int intThumbHeight; try { if (chkDeletePhotoPath.Checked == false) { // Set constant values sSavePath = "../PhotoGallery/"; sThumbExtension = "_thumb"; intThumbWidth = 160; intThumbHeight = 120; // If file field isn’t empty if (flPhotos.PostedFile != null && flPhotos.PostedFile.ContentLength > 0) { // Check file size (mustn’t be 0) HttpPostedFile myFile = flPhotos.PostedFile; int nFileLen = myFile.ContentLength; if (nFileLen == 0) { ShowGuidMessage(0, new Exception("No file was uploaded.")); return; } // Check file extension (must be JPG) if (System.IO.Path.GetExtension(myFile.FileName).ToLower() != ".jpg") { ShowGuidMessage(0, new Exception("The file must have an extension of JPG")); return; } // Read file into a data stream byte[] myData = new Byte[nFileLen]; myFile.InputStream.Read(myData, 0, nFileLen); // Make sure a duplicate file doesn’t exist. If it does, keep on appending an // incremental numeric until it is unique sFilename = System.IO.Path.GetFileName(myFile.FileName); int file_append = 0; while (System.IO.File.Exists(Server.MapPath(sSavePath + sFilename))) { file_append++; sFilename = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + ".jpg"; } // Save the stream to disk System.IO.FileStream newFile = new System.IO.FileStream(Server.MapPath(sSavePath + sFilename), System.IO.FileMode.Create); newFile.Write(myData, 0, myData.Length); newFile.Close(); // Check whether the file is really a JPEG by opening it System.Drawing.Image.GetThumbnailImageAbort myCallBack = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback); Bitmap myBitmap; try { myBitmap = new Bitmap(Server.MapPath(sSavePath + sFilename)); // If jpg file is a jpeg, create a thumbnail filename that is unique. file_append = 0; string sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + sThumbExtension + ".jpg"; while (System.IO.File.Exists(Server.MapPath(sSavePath + sThumbFile))) { file_append++; sThumbFile = System.IO.Path.GetFileNameWithoutExtension(myFile.FileName) + file_append.ToString() + sThumbExtension + ".jpg"; } // Save thumbnail and output it onto the webpage System.Drawing.Image myThumbnail = myBitmap.GetThumbnailImage(intThumbWidth, intThumbHeight, myCallBack, IntPtr.Zero); myThumbnail.Save(Server.MapPath(sSavePath + sThumbFile)); tdUploadedImage.Visible = true; imgPhotos.ImageUrl = sSavePath + sThumbFile; // Displaying success information //tdError.InnerText = "File uploaded successfully!"; // Destroy objects myThumbnail.Dispose(); myBitmap.Dispose(); } catch { // The file wasn't a valid jpg file System.IO.File.Delete(Server.MapPath(sSavePath + sFilename)); ShowGuidMessage(0, new Exception("The file wasn't a valid jpg file")); return; } } } if (sFilename == "" && Convert.ToInt32(ViewState["EditCode"]) > 0) { sFilename = Convert.ToString(ViewState["FileName"]); } else if (sFilename == "" && Convert.ToInt32(ViewState["EditCode"]) <= 0) { sFilename = "NoImage.jpg"; } else if (chkDeletePhotoPath.Checked == true) { sFilename = "NoImage.jpg"; } tbl_PhotoGalleryMasterProp Objtbl_PhotoGalleryMasterProp = new tbl_PhotoGalleryMasterProp(); Objtbl_PhotoGalleryMasterProp.PhotoCode = Convert.ToInt32(ViewState["EditCode"]); Objtbl_PhotoGalleryMasterProp.PhotoHead = txtPhotoHead.Text; Objtbl_PhotoGalleryMasterProp.FileName = sFilename; Objtbl_PhotoGalleryMasterProp.AlbumCode = Convert.ToInt32(ddlAlbumName.SelectedValue); tbl_PhotoGalleryMasterBAL Objtbl_PhotoGalleryMasterBAL = new tbl_PhotoGalleryMasterBAL(); Objtbl_PhotoGalleryMasterBAL.InsertUpdate_Data(Objtbl_PhotoGalleryMasterProp); ShowGuidMessage(1, null); mdlPopupNewEntry.Hide(); FillData(); } catch (Exception ex) { System.IO.File.Delete(Server.MapPath(sSavePath + sFilename)); ShowGuidMessage(0, ex); //MessageBox.Show(ex.Message); } }