TechEthical CEHP
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SqlServer;
using System.Data.SqlClient;
using System.Data;
using Directory;
namespace Bathuasoft.admin
{
public partial class Add_MotivationalSpeeches : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["Loginxtr"].ToString() == "1254lkjhhfdgftfrdgf")
{
BindGrid();
}
else
{
Response.Redirect("login.aspx");
}
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(txtTitle.Text))
{
Random random = new Random();
random.Next(11111, 32700);
if (FileUpload1.HasFile==true)
{
try
{
lblImagePath.Text = random.Next() + ".jpg";
FileUpload1.SaveAs (Server.MapPath("~/img/VideoPath/") + lblImagePath.Text.Trim());
}
catch
{
}
}
else
{
lblImagePath.Text = "";
}
connection_sql obj = new connection_sql();
obj.MakeConnection();
SqlCommand cmd = new SqlCommand("sp_SaveVideoMotivationalSpeeches", obj.conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Title", txtTitle.Text);
cmd.Parameters.AddWithValue("@Types", txtType.Text);
cmd.Parameters.AddWithValue("@Course", txtCourse.Text);
cmd.Parameters.AddWithValue("@Description", txtDescription.Text);
cmd.Parameters.AddWithValue("@Path", txtVideoPath.Text);
int k = cmd.ExecuteNonQuery();
obj.CloseConnection();
if (k==1)
{
txtType.Text = "";
txtDescription.Text = "";
txtTitle.Text="";
txtVideoPath.Text = "";
txtCourse.Text = "";
lblImagePath.Text = "";
ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Save Successfully.');", true);
}
BindGrid();
}
}
private void BindGrid()
{
DataSet ds = new DataSet();
connection_sql obj = new connection_sql();
obj.MakeConnection();
ds = obj.getDataSet("Select ID, Title, Description, Course, Types, Path as Video, ImagePath "
+ " from tbl_VideoMotivationalSpeeches order by id desc");
if (ds != null && ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
}
obj.CloseConnection();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
connection_sql obj = new connection_sql();
obj.MakeConnection();
if (e.CommandName == "DELETERECORD")
{
int a = obj.ExcuteCommand("Delete From tbl_VideoMotivationalSpeeches where id=" + e.CommandArgument.ToString());
ScriptManager.RegisterStartupScript(this, GetType(), "set", "alert('Delete Successfully');", true);
Response.Redirect("Add-Video-Motivational-Speeches.aspx");
}
obj.CloseConnection();
}
}
}
TechEthical Mini WebShell Version 1.0, Coded By The_M@T3