protected void Page_Load(object sender, EventArgs e) { if (Request["video_id"] != null) { MsgBox1.Show("Confirm", "Are you sure to delete the video", null, new EO.Web.MsgBoxButton("Yes", null, "Yes"), new EO.Web.MsgBoxButton("No", null, "No")); } }
protected void dgreturnmedia_DeleteCommand(object source, DataGridCommandEventArgs e) { DateTime currentdate = DateTime.Now; Session["renew"] = e.Item.Cells[1].Text; int noofrenewals = int.Parse(e.Item.Cells[11].Text); if (noofrenewals > 1) { MsgBox1.alert("You can not renew, Please return the media"); } else { DataAccess da = new DataAccess(); string sql = "select * from tblrenewmedia where intissueid = '" + Session["renew"] + "'"; DataSet ds2 = new DataSet(); ds2 = da.ExceuteSql(sql); if (ds2.Tables[0].Rows.Count > noofrenewals) { MsgBox1.alert("Oops! You can not renew "); } else { da = new DataAccess(); string strsql = "insert into tblrenewmedia (intissueid,dtrenewdate) values('" + Session["renew"] + "' , '" + currentdate + "')"; DataSet ds1 = new DataSet(); ds1 = da.ExceuteSql(strsql); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["order_no"] != null && Request["model_id"] != null) { MsgBox1.Show("Confirm", "Are you sure to cancel the item from order", null, new EO.Web.MsgBoxButton("Yes", null, "Yes"), new EO.Web.MsgBoxButton("No", null, "No")); } }
protected void btnSave_Click(object sender, EventArgs e) { try { SqlCommand RegCommand; SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["conn"]); Conn.Open(); RegCommand = new SqlCommand("spitemcategory", Conn); RegCommand.CommandType = CommandType.StoredProcedure; if (btn_Save.Text == "Save") { RegCommand.Parameters.Add("@intid", "0"); } else { RegCommand.Parameters.Add("@intid", Session["intid"].ToString()); } RegCommand.Parameters.Add("@strcategory", txtboard.Text.Trim()); RegCommand.ExecuteNonQuery(); Conn.Close(); fillBoard(); } catch { MsgBox1.alert("Item Category Already Exists!"); } }
protected void btnsave_Click(object sender, EventArgs e) { if ((txtfinalquery.Text.IndexOf("select") > -1 && txtfinalquery.Text.IndexOf("alter") < 0) || txtfinalquery.Text.IndexOf("sp_helptext") > -1) { try { str = txtfinalquery.Text; da = new SqlDataAdapter(str, conn); ds = new DataSet(); da.Fill(ds); dgbranchmaster.DataSource = ds; dgbranchmaster.DataBind(); } catch { MsgBox1.alert("Incorrect Query"); } } else //else if(txtfinalquery.Text.IndexOf("update") > -1 || txtfinalquery.Text.IndexOf("delete") > -1) { try { conn.Open(); str = txtfinalquery.Text; cmd = new SqlCommand(str, conn); cmd.ExecuteNonQuery(); conn.Close(); } catch { MsgBox1.alert("Incorrect Query"); } } }
protected void fillroute() { strsql = "select strroutename,intid from tblroute where intschool=" + Session["SchoolID"].ToString(); da = new DataAccess(); ds = new DataSet(); ds = da.ExceuteSql(strsql); ddlrouteno.DataSource = ds; ddlrouteno.DataTextField = "strroutename"; ddlrouteno.DataValueField = "intid"; ddlrouteno.DataBind(); ddlrouteno.Items.Insert(0, "-Select-"); if (ds.Tables[0].Rows.Count == 0) { MsgBox1.alert("There is no Bus Route Added for Booking"); } }
protected void btnSave_Click(object sender, EventArgs e) { SqlCommand RegCommand; SqlParameter OutPutParam; SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["conn"]); Conn.Open(); RegCommand = new SqlCommand("spassignbusroute", Conn); RegCommand.CommandType = CommandType.StoredProcedure; OutPutParam = RegCommand.Parameters.Add("@rc", SqlDbType.Int); OutPutParam.Direction = ParameterDirection.Output; if (btnSave.Text == "Save") { RegCommand.Parameters.Add("@intID", "0"); } else { RegCommand.Parameters.Add("@intID", Session["intID"].ToString()); } RegCommand.Parameters.Add("@introute", ddlroute.SelectedValue); RegCommand.Parameters.Add("@strdestination", txtdestination.Text); RegCommand.Parameters.Add("@dtpickuptime", ddlpickhour.SelectedValue + ":" + ddlpickmin.SelectedValue + " " + ddlpickcat.SelectedValue); RegCommand.Parameters.Add("@dtdroptime", ddldrophour.SelectedValue + ":" + ddldropmin.SelectedValue + " " + ddldropcat.SelectedValue); RegCommand.Parameters.Add("@intamount", txtamount.Text); RegCommand.Parameters.Add("@intschool", Session["SchoolID"].ToString()); RegCommand.ExecuteNonQuery(); if ((int)(RegCommand.Parameters["@rc"].Value) == 0) { MsgBox1.alert("The Pickup place already assigned!"); } Conn.Close(); string id = Convert.ToString(OutPutParam.Value); if (btnSave.Text == "Save") { Functions.UserLogs(Session["UserID"].ToString(), "tblassignbusroute", id, "Added", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 118); } else { Functions.UserLogs(Session["UserID"].ToString(), "tblassignbusroute", id, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 118); } Clear(); fillgrid(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Details Saved Successfully!')", true); }
protected void DL_ItemCommand(object source, DataListCommandEventArgs e) { //check if logged in if (Session["uName"] == null) { Response.Redirect("Login.aspx", false); Context.ApplicationInstance.CompleteRequest(); } else { try { //check amount of credits int currentCredits = Convert.ToInt32(Session["uCredits"]); int moviePrice = Convert.ToInt32(((Literal)e.Item.FindControl("Literal3")).Text); if (currentCredits < moviePrice) { //display message to top up, else go along MsgBox1.confirm("Oh no! You don't have enough credits to rent this movie! Would you like to top up now? ", "hid_f"); } else { //put in session all video details for Watching Session["wTitle"] = ((Literal)e.Item.FindControl("Literal1")).Text; Session["wYear"] = ((Literal)e.Item.FindControl("Literal2")).Text; Session["wPrice"] = ((Literal)e.Item.FindControl("Literal3")).Text; Session["wRating"] = ((Literal)e.Item.FindControl("Literal4")).Text; Session["wPlot"] = ((Literal)e.Item.FindControl("Literal5")).Text; //deduct amount of credits Session["uCredits"] = currentCredits - moviePrice; //redirect to Watching Response.Redirect("Watching.aspx", false); Context.ApplicationInstance.CompleteRequest(); } } catch (System.Threading.ThreadAbortException) { //Do nothing. The exception will get rethrown by the framework when this block terminates. } } }
protected void btnsave_Click(object sender, EventArgs e) { //if (ddltype.SelectedIndex == 0) //{ // MsgBox1.alert("Please select Menu type"); //} if (ddlday.SelectedIndex == 0) { //ScriptManager.RegisterStartupScript(this, GetType(), "clientscript", "Alert('Please select a day');", true); MsgBox1.alert("Please select a day"); } if (ddlday.SelectedIndex > 0) { SqlCommand cmd; SqlParameter Outputparameter; SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["Conn"]); Conn.Open(); cmd = new SqlCommand("spmenutimetable", Conn); cmd.CommandType = CommandType.StoredProcedure; Outputparameter = cmd.Parameters.Add("@rc", SqlDbType.Int); Outputparameter.Direction = ParameterDirection.Output; if (Btnsave.Text == "Save") { cmd.Parameters.Add("@intid", "0"); } else { cmd.Parameters.Add("@intid", Session["sid"].ToString()); } cmd.Parameters.Add("@strday", ddlday.SelectedValue); cmd.Parameters.Add("@strtype", ddltype.SelectedValue); string meal; if (rbtveg.Checked == true) { meal = rbtveg.Text; } else { meal = rbtnonveg.Text; } cmd.Parameters.Add("@strmealstype", meal); cmd.Parameters.Add("@strfoodname", txtfoodname.Text.Trim()); cmd.Parameters.Add("@strcurryname", Txtcurryname.Text.Trim()); cmd.Parameters.Add("@strmaindish", txtmaindish.Text.Trim()); cmd.Parameters.Add("@strsidedish", Txtsidedish.Text.Trim()); cmd.Parameters.Add("@stradditional", txtadditional.Text.Trim()); cmd.Parameters.Add("@intschool", Session["SchoolID"].ToString()); cmd.ExecuteNonQuery(); if (cmd.Parameters["@rc"].Value.ToString() == "0") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Already Exist')", true); //MsgBox1.alert("Already Exist"); } Conn.Close(); string id = Convert.ToString(Outputparameter.Value); if (Btnsave.Text == "Save") { Functions.UserLogs(Session["UserID"].ToString(), "tblmenutimetable", id, "Added", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 61); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "clientScript", "alert('Details Saved Successfully')", true); } else { Functions.UserLogs(Session["UserID"].ToString(), "tblmenutimetable", id, "Updated", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 61); } if (Btnsave.Text == "Update") { //allclear(); // Response.Redirect("edit_lunch_menu.aspx?sid=" + Session["sid"].ToString()); ScriptManager.RegisterStartupScript(Page, Page.GetType(), "redirect script", "alert('Details Update Successfully!'); location.href='edit_lunch_menu.aspx?sid=" + Session["sid"].ToString() + "';", true); } else { fillgrid(); allclear(); } } }
protected void Button1_Click(object sender, EventArgs e) { if (Txtbarcode.Text == "") { MsgBox1.alert("Please enter Barcode"); } else { strsql = "select * from (select a.intschool,a.intid, strpatrontype,strname,intbarcode,strtitle,"; strsql += " convert(varchar(10),dtdateofissue,103) as dtdateofissue1, dtdateofissue, convert(varchar(10)"; strsql += " ,dtdateofissue+b.intnoofdays,103) as expirydate, "; strsql += " (datediff(day,(dtdateofissue+b.intnoofdays),getdate())) as execess,b.intid as intid1,b.intnoofrenewals as noofrenewals, 0 as fine"; strsql += " from tblissueamedia a, tblreturndate b where a.strpatrontype=b.strpatron and a.strdepartment=b.intdepartment and "; strsql += " a.strdesignation=b.intdesignation and a.intmediatype=b.intmediatype and a.intmediacategory=b.intmediacategory and a.intreturn=1 and a.strpatrontype='Employee' "; strsql += " union all"; strsql += " select a.intschool,a.intid, strpatrontype,strname,intbarcode,strtitle,"; strsql += " convert(varchar(10),dtdateofissue,103) as dtdateofissue1, dtdateofissue,"; strsql += " convert(varchar(10),dtdateofissue+b.intnoofdays,103) as expirydate, "; strsql += " (datediff(day,(dtdateofissue+b.intnoofdays),getdate())) as execess,b.intid as intid1,b.intnoofrenewals as noofrenewals, 0 as fine "; strsql += " from tblissueamedia a, tblreturndate b where a.strpatrontype=b.strpatron and a.strstandard=b.strstandard and a.intmediatype=b.intmediatype and a.intmediacategory=b.intmediacategory and intreturn=1 and "; strsql += " a.strpatrontype='Student') as a where intschool=" + Session["SchoolId"].ToString() + " and intbarcode='" + Txtbarcode.Text + "'"; DataAccess da = new DataAccess(); DataSet ds = new DataSet(); ds = da.ExceuteSql(strsql); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { strsql = "select top 1 intissueid,convert(varchar(10),dtrenewdate,103) as dtrenewdate from tblrenewmedia where intissueid = '" + ds.Tables[0].Rows[i]["intid"].ToString() + "' order by intissueid desc"; da = new DataAccess(); DataSet dsm = new DataSet(); dsm = da.ExceuteSql(strsql); if (dsm.Tables[0].Rows.Count > 0) { ds.Tables[0].Rows[i]["dtdateofissue1"] = dsm.Tables[0].Rows[0]["dtrenewdate"].ToString(); ds.Tables[0].Rows[i]["dtdateofissue"] = dsm.Tables[0].Rows[0]["dtrenewdate"].ToString(); } strsql = "select * from tblreturndate where intid=" + ds.Tables[0].Rows[i]["intid1"].ToString(); da = new DataAccess(); DataSet ds1 = new DataSet(); ds1 = da.ExceuteSql(strsql); double dbfine = 0; int noofdays = int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()); if (noofdays > 0) { if (ds1.Tables[0].Rows.Count > 0) { if (ds1.Tables[0].Rows[0]["intupto4"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto4"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfineperday"].ToString()); //noofdays = int.Parse(ds1.Tables[0].Rows[0]["intupto4"].ToString()) - noofdays; } if (dbfine == 0) { if (ds1.Tables[0].Rows[0]["intupto4"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto3"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine4"].ToString()); noofdays = int.Parse(ds1.Tables[0].Rows[0]["intupto4"].ToString()) - noofdays; } if (ds1.Tables[0].Rows[0]["intupto4"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto3"].ToString()) && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) <= int.Parse(ds1.Tables[0].Rows[0]["intupto4"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine4"].ToString()); noofdays = 0; } } if (dbfine == 0) { if (ds1.Tables[0].Rows[0]["intupto3"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto2"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine3"].ToString()); noofdays = int.Parse(ds1.Tables[0].Rows[0]["intupto3"].ToString()) - noofdays; } if (ds1.Tables[0].Rows[0]["intupto3"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto2"].ToString()) && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) <= int.Parse(ds1.Tables[0].Rows[0]["intupto3"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine3"].ToString()); noofdays = 0; } } if (dbfine == 0) { if (ds1.Tables[0].Rows[0]["intupto2"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto1"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine2"].ToString()); noofdays = int.Parse(ds1.Tables[0].Rows[0]["intupto2"].ToString()) - noofdays; } if (ds1.Tables[0].Rows[0]["intupto2"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto1"].ToString()) && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) <= int.Parse(ds1.Tables[0].Rows[0]["intupto2"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine2"].ToString()); noofdays = 0; } } if (dbfine == 0) { if (ds1.Tables[0].Rows[0]["intupto1"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto1"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine1"].ToString()); noofdays = int.Parse(ds1.Tables[0].Rows[0]["intupto1"].ToString()) - noofdays; } if (ds1.Tables[0].Rows[0]["intupto1"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) <= int.Parse(ds1.Tables[0].Rows[0]["intupto1"].ToString())) { dbfine = double.Parse(ds1.Tables[0].Rows[0]["intfine1"].ToString()); noofdays = 0; } } if (noofdays < 0) { dbfine = 0; noofdays = 0; ds.Tables[0].Rows[i]["execess"] = 0; } if (ds1.Tables[0].Rows[0]["intupto4"].ToString() != "0" && int.Parse(ds.Tables[0].Rows[i]["execess"].ToString()) > int.Parse(ds1.Tables[0].Rows[0]["intupto4"].ToString())) { dbfine = noofdays * double.Parse(ds1.Tables[0].Rows[0]["intfineperday"].ToString()); } else { dbfine = dbfine + (noofdays * double.Parse(ds1.Tables[0].Rows[0]["intfineperday"].ToString())); } } ds.Tables[0].Rows[i]["fine"] = dbfine; } else { ds.Tables[0].Rows[i]["fine"] = dbfine; ds.Tables[0].Rows[i]["execess"] = 0; } } dgreturnmedia.DataSource = ds; dgreturnmedia.DataBind(); } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { string codCliente = txtCodigoCliente.Text; //--------------CONSULTA NUEVA string qry = ""; string qryDocumentos = ""; if (!(codCliente.Trim().Length == 9) && !(codCliente.Trim().Length == 6)) { MsgBox1.alert("El código proporcionado no es NDC ni de un cliente existente"); } else { AccesoDatos ad = new AccesoDatos(); if (codCliente.Trim().Length == 9) { qry = String.Format("select LNUCSO AS NDC, lclnoc as CLIENTE, LCLNOC AS NOMBRE, '' AS DIRECCION, '' AS NIT, LEMAIL AS EMAIL from cdicrm.cr0029f where LNUCSO='{0}'", codCliente); } else if (codCliente.Trim().Length == 6) { qry = String.Format("select '' AS NDC, gclcod as CLIENTE, gclnom as NOMBRE, ( gcldir||gclcod||gclciu ) as DIRECCION, gclnit as nit, GCLTX1 as EMAIL from intgen.fgen035 where gclcod='{0}'", codCliente); } qryDocumentos = @"select d.seqdocto as nodocumento, d.vcocia as compania, d.subare as area, t.nombretipo as tipo_documento, d.nombredoc from cdigen.twgen0003 d left join cdigen.twgen0002 t on d.idtipodoc=t.idtipodoc where d.clondc='{0}' and UPPER(coalesce(d.estado,''))<>'X'"; DataTable dtDatosCliente = new DataTable(); dtDatosCliente = ad.RealizaConsulta(qry); DataTable dtDocumentosCliente = new DataTable(); dtDocumentosCliente = ad.RealizaConsulta(String.Format(qryDocumentos, txtCodigoCliente.Text)); if (dtDatosCliente != null && dtDatosCliente.Rows.Count > 0) { //this.ViewState["CLIENTE"] = dtDatosCliente; //if (dtDatosCliente.Rows.Count > 0) { gvDatosCliente.DataSource = dtDatosCliente; gvDatosCliente.DataBind(); pDatosCliente.Visible = true; gvDocumentosCliente.DataSource = dtDocumentosCliente; gvDocumentosCliente.DataBind(); pDocumentosCliente.Visible = true; } //else //{ // this.obtenerDatos(0); //} } else { gvDatosCliente.DataSource = dtDatosCliente; gvDatosCliente.DataBind(); pDatosCliente.Visible = true; } } } catch (Exception arg_146_0) { Exception exception = arg_146_0; MsgBox1.alert("Error al cargar los datos " + exception.Message); } }
protected void FinishVideoBtn_Click(object sender, EventArgs e) { //warning message: are you sure? y:redirect n: close message MsgBox1.confirm("To get back to this page you will have to pay the same amount of credits again. Are you sure you want to quit the current viewing? ", "hid_f"); }
protected void btnAdd_Click(object sender, EventArgs e) { try { if (txttitle.Text != "" || drptitle.SelectedIndex > 0 || lbltitleview.Text != "") { int ImageName = 1; int ActualWidth = 0; int ActualHeight = 0; string extension = ""; groups(); SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["conn"]); HttpFileCollection uploadedFiles = Request.Files; for (int i = 0; i < uploadedFiles.Count; i++) { conn.Open(); SqlCommand command = new SqlCommand("spgallery", conn); command.CommandType = CommandType.StoredProcedure; SqlParameter param = command.Parameters.Add("@rc", SqlDbType.Int); param.Direction = ParameterDirection.Output; HttpPostedFile userPostedFile = uploadedFiles[i]; postedfile = userPostedFile.ToString(); extension = System.IO.Path.GetExtension(userPostedFile.FileName).ToLower(); if (userPostedFile.ContentLength > 0) { if (btnAdd.Text == "Upload") { command.Parameters.Add("@intid", "0"); } else { command.Parameters.Add("@intid", Session["intid"]); } command.Parameters.Add("@intacademicyear", drpacademicyear.SelectedValue); if (trtitletxt.Visible == true) { DataAccess da = new DataAccess(); DataSet ds = new DataSet(); string sql = "select intid from tblgallerygroups where intschool=" + Session["SchoolID"] + " and strgroups='" + txttitle.Text + "' order by intid desc"; ds = da.ExceuteSql(sql); command.Parameters.Add("@intgroups", ds.Tables[0].Rows[0]["intid"].ToString()); } else if (drptitle.Visible == true) { command.Parameters.Add("@intgroups", drptitle.SelectedValue); } else { DataAccess da = new DataAccess(); DataSet ds = new DataSet(); string sql = "select intid from tblgallerygroups where intschool=" + Session["SchoolID"] + " and strgroups='" + lbltitleview.Text + "' order by intid desc"; ds = da.ExceuteSql(sql); command.Parameters.Add("@intgroups", ds.Tables[0].Rows[0]["intid"].ToString()); } command.Parameters.Add("@intpublished", "0"); DataAccess da2 = new DataAccess(); DataSet ds2 = new DataSet(); string sql2 = "select top 1 intid from tblgallery where intschool=" + Session["SchoolID"] + " order by intid desc"; ds2 = da2.ExceuteSql(sql2); if (ds2.Tables[0].Rows.Count > 0) { ImageName = int.Parse(ds2.Tables[0].Rows[0]["intid"].ToString()) + 1; } if (radiophoto.Checked == true) { String[] allowedExtensions = { ".jpg", ".gif", ".png", ".jpeg" }; for (int j = 0; j < allowedExtensions.Length; j++) { if (extension == allowedExtensions[j]) { //userPostedFile.SaveAs(Server.MapPath("galleryimage/orgimage/" + ImageName + extension)); command.Parameters.Add("@strphotoorvideo", ImageName + extension); //System.Drawing.Image image = System.Drawing.Image.FromFile(System.AppDomain.CurrentDomain.BaseDirectory + "/gallery/galleryimage/orgimage/" + ImageName + extension); System.Drawing.Image image = System.Drawing.Image.FromStream(userPostedFile.InputStream); ActualWidth = image.Width; ActualHeight = image.Height; if (ActualWidth > 1000) { var newWidth = 0; var newHeight = 0; if (ActualWidth > 4000) { newWidth = (int)(image.Width * 0.3); newHeight = (int)(image.Height * 0.3); } else if (ActualWidth > 3000) { newWidth = (int)(image.Width * 0.4); newHeight = (int)(image.Height * 0.4); } else if (ActualWidth > 2000) { newWidth = (int)(image.Width * 0.5); newHeight = (int)(image.Height * 0.5); } else { newWidth = (int)(image.Width * 0.8); newHeight = (int)(image.Height * 0.8); } var thumbnailImage = new Bitmap(newWidth, newHeight); var thumbGraph = Graphics.FromImage(thumbnailImage); thumbGraph.CompositingQuality = CompositingQuality.HighQuality; thumbGraph.SmoothingMode = SmoothingMode.HighQuality; thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; var imageRectangle = new Rectangle(0, 0, newWidth, newHeight); thumbGraph.DrawImage(image, imageRectangle); thumbnailImage.Save(Server.MapPath("galleryimage/orgimage/" + ImageName + extension)); thumbnailImage.Save(Server.MapPath("galleryimage/Thumbimage/" + ImageName + "_thumb" + extension)); thumbnailImage.Dispose(); thumbGraph.Dispose(); image.Dispose(); } else { userPostedFile.SaveAs(Server.MapPath("galleryimage/orgimage/" + ImageName + extension)); var newWidth = (int)(image.Width * 0.2); var newHeight = (int)(image.Height * 0.2); var thumbnailImage = new Bitmap(newWidth, newHeight); var thumbGraph = Graphics.FromImage(thumbnailImage); thumbGraph.CompositingQuality = CompositingQuality.HighQuality; thumbGraph.SmoothingMode = SmoothingMode.HighQuality; thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; var imageRectangle = new Rectangle(0, 0, newWidth, newHeight); thumbGraph.DrawImage(image, imageRectangle); thumbnailImage.Save(Server.MapPath("galleryimage/Thumbimage/" + ImageName + "_thumb" + extension)); thumbnailImage.Dispose(); thumbGraph.Dispose(); image.Dispose(); } } } } else { if (extension != ".flv") { string strFLVFileName = System.IO.Path.GetFileNameWithoutExtension("galleryvideo/orgvideo/" + userPostedFile.FileName) + ".flv"; string strArgs = "-i " + Server.MapPath("galleryvideo/orgvideo/" + strFLVFileName) + " -ar 22050 " + Server.MapPath("galleryvideo/orgvideo/" + strFLVFileName); Process proc = new Process(); proc.StartInfo.FileName = Server.MapPath("../ffmpeg-0.5/ffmpeg.exe"); proc.StartInfo.Arguments = strArgs; proc.StartInfo.UseShellExecute = false; proc.StartInfo.CreateNoWindow = false; proc.StartInfo.RedirectStandardOutput = false; try { proc.Start(); } catch (Exception ex) { Response.Write(ex.Message); } proc.WaitForExit(); proc.Close(); } userPostedFile.SaveAs(Server.MapPath("galleryvideo/orgvideo/" + ImageName + ".flv")); command.Parameters.Add("@strphotoorvideo", ImageName + ".flv"); } } command.Parameters.Add("dtuploadeddate", DateTime.Now.ToString("yyyy/MM/dd")); command.Parameters.Add("@intschool", Session["SchoolID"]); if (trtitletxt.Visible == true) { command.Parameters.Add("@strname", txttitle.Text.Trim()); } else { command.Parameters.Add("@strname", lbltitleview.Text.Trim()); } command.Parameters.Add("@strdescription", ""); command.Parameters.Add("@intedit", "0"); if (radiophoto.Checked == true) { command.Parameters.Add("@strthumbnail", ImageName + "_thumb" + extension); command.Parameters.Add("@strcategory", "Photos"); } else { command.Parameters.Add("@strthumbnail", "-"); command.Parameters.Add("@strcategory", "Videos"); } command.Parameters.Add("@intwidth", ActualWidth); command.Parameters.Add("@intheight", ActualHeight); command.ExecuteNonQuery(); conn.Close(); string id = Convert.ToString(param.Value); if (btnAdd.Text == "Upload") { Functions.UserLogs(Session["UserID"].ToString(), "tblgallery", id, "Added", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 316); } else { Functions.UserLogs(Session["UserID"].ToString(), "tblgallery", id, "Added", Session["PatronType"].ToString(), Session["SchoolID"].ToString(), 318); } } lastupload(); fillgrid(); grdmenu(); drpacademicyear.Focus(); } else { MsgBox1.alert("Please select Image/Video title to Proceed"); } } catch { } }
protected void Btnsave_Click(object sender, EventArgs e) { SqlCommand cmd; SqlParameter OutPutParam; SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["conn"]); conn.Open(); cmd = new SqlCommand("SPmediareturndate", conn); cmd.CommandType = CommandType.StoredProcedure; OutPutParam = cmd.Parameters.Add("@rc", SqlDbType.Int); OutPutParam.Direction = ParameterDirection.Output; if (Btnsave.Text == "Save") { cmd.Parameters.Add("@intid", "0"); } else { cmd.Parameters.Add("@intid", Session["intid"].ToString()); } cmd.Parameters.Add("@strpatron", ddlpatron.SelectedValue); if (ddlpatron.SelectedValue == "Student") { cmd.Parameters.Add("@strstandard", ddlstd.SelectedValue); } else { cmd.Parameters.Add("@strstandard", "0"); } if (ddlpatron.SelectedValue == "Employee") { cmd.Parameters.Add("@intdepartment", ddldept.SelectedValue); cmd.Parameters.Add("@intdesignation", ddldesig.SelectedValue); } else { cmd.Parameters.Add("@intdepartment", "0"); cmd.Parameters.Add("@intdesignation", "0"); } cmd.Parameters.Add("@intmediatype", ddlmt.SelectedValue); cmd.Parameters.Add("@intmediacategory", ddlmc.SelectedValue); cmd.Parameters.Add("@intnoofdays", Txtnoofdays.Text.Trim()); cmd.Parameters.Add("@intnoofrenewals", Txtnoofrenewal.Text.Trim()); cmd.Parameters.Add("@intupto1", txtupto1.Text.Trim()); cmd.Parameters.Add("@intfine1", txtfineamount1.Text.Trim()); cmd.Parameters.Add("@intupto2", txtupto2.Text.Trim()); cmd.Parameters.Add("@intfine2", txtfineamount2.Text.Trim()); cmd.Parameters.Add("@intupto3", txtupto3.Text.Trim()); cmd.Parameters.Add("@intfine3", txtfineamount3.Text.Trim()); cmd.Parameters.Add("@intupto4", txtupto4.Text.Trim()); cmd.Parameters.Add("@intfine4", txtfineamount4.Text.Trim()); cmd.Parameters.Add("@intfineperday", txtfineperday.Text.Trim()); cmd.Parameters.Add("@intschool", Session["SchoolID"].ToString()); cmd.ExecuteNonQuery(); if ((int)(cmd.Parameters["@rc"].Value) == 0) { MsgBox1.alert("Oops! already Exist"); } conn.Close(); fillgrid(); allclear(); }