Professional Documents
Culture Documents
ProjectMaster Cs
ProjectMaster Cs
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Globalization;
using System.Text;
using System.Web.Services;
using System.IO;
public partial class ProjectMaster : System.Web.UI.Page
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
clsDataControl clsData = new clsDataControl();
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
string urlName = Request.UrlReferrer.ToString();
BindDepartment();
generateID();
if (Convert.ToString(Session["Department"]) != "Software")
{
pnl_GridProjectView.Visible = false;
ddl_Projecttype.SelectedIndex =
ddl_Projecttype.Items.IndexOf(ddl_Projecttype.Items.FindByValue("Internal"));
//ddl_Projecttype.SelectedItem.Value = "Internal";
ddl_Projecttype.Enabled = false;
ddl_Projecttype.CssClass = "col-sm-2 form-control";
}
else
{
BindGridProject();
}
}
}
catch (Exception Ex)
{
throw Ex;
}
}
//int id = int.Parse(c) + 1;
if (c == String.Empty)
{
c = 0.ToString();
}
int count = Int32.Parse(c.ToString());
con.Open();
if (count > 0)
{
count++;
}
else
{
count = 0001;
}
id1 = "SW";
}
protected void clear()
{
ddl_Projecttype.SelectedIndex = -1;
txt_Projectdesc.Text = string.Empty;
//txt_Projectid.Text = string.Empty;
txt_Projectname.Text = string.Empty;
ddl_department.SelectedIndex = -1;
}
protected void btn_Reset_Click(object sender, EventArgs e)
{
try
{
clear();
// Page.Response.Redirect(Page.Request.Url.ToString(), true);
}
catch (Exception Ex)
{
throw Ex;
}
}
protected void btn_back_Click(object sender, EventArgs e)
{
try
{
Response.Redirect("Dashboard.aspx");
}
catch (Exception Ex)
{
throw Ex;
}
}
protected void lnk_projectEditClick(object sender, CommandEventArgs e)
{
try
{
btn_add.Visible = false;
btn_edit.Visible = true;
string id = Convert.ToString(e.CommandArgument);
DataTable dt=clsData.Getdata("select * from tbl_PMIS_Projects where
p_id='" + id + "'");
lbl_id.Text = dt.Rows[0]["p_id"].ToString();
txt_Projectid.Text= dt.Rows[0]["project_id"].ToString();
txt_Projectname.Text= dt.Rows[0]["project_name"].ToString();
//ddl_Projecttype.SelectedIndex =
ddl_Projecttype.Items.IndexOf(ddl_Projecttype.Items.FindByText(dt.Rows[0]
["project_type"].ToString()));
//ddl_Projecttype.SelectedItem.Text = dt.Rows[0]
["project_type"].ToString();
ddl_Projecttype.SelectedIndex =
ddl_Projecttype.Items.IndexOf(ddl_Projecttype.Items.FindByText(dt.Rows[0]
["project_type"].ToString()));
ddl_department.SelectedIndex =
ddl_department.Items.IndexOf(ddl_department.Items.FindByValue(dt.Rows[0]
["department"].ToString()));
txt_Projectdesc.Text = dt.Rows[0]["description"].ToString();
}
catch (Exception)
{
throw;
}
}
protected void btn_edit_Click(object sender, EventArgs e)
{
try
{
string update = "update tbl_PMIS_Projects set project_name='" +
txt_Projectname.Text + "',project_type='" + ddl_Projecttype.SelectedItem.Text +
"',department='" + ddl_department.SelectedItem.Value + "',description='" +
txt_Projectdesc.Text + "' where p_id='" + lbl_id.Text + "'";
clsData.InsertOrUpdate(update, false, false);
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "$
('#alertContent').html('Project details updated successfully');$
('#alertWin').modal('show'); ", true);
}
catch (Exception)
{
throw;
}
}
protected void lnk_projectDeleteClick(object sender, CommandEventArgs e)
{
try
{
LinkButton lnkEdit = (LinkButton)sender;
GridViewRow gvrow = (GridViewRow)lnkEdit.NamingContainer;
string id = Convert.ToString(e.CommandArgument);
string project = clsData.GetSingleData("select
project_id+'_'+project_name from tbl_PMIS_Projects where p_id='" + id + "'");
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "$
('#lbl_id').html('" + id + "');$('#lbl_showhead').html('Project ID&Name :');$
('#lbl_show').html('" + project + "');$('#div_DeleteCancel').html('Are you sure to
Delete this Project?');$('#alertDeleteCancel').modal('show'); ", true);
BindGridProject();
}
catch (Exception)
{
throw;
}
}
[System.Web.Services.WebMethod]
public static void deleteitem(string ID)
{
SqlConnection con = new
SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("Delete from tbl_PMIS_Projects where p_id=
'" + ID + "'", con);
cmd.ExecuteNonQuery();
con.Close();
}
}