protected void grdpc_RowUpdating(object sender, GridViewUpdateEventArgs e) { GridViewRow row = grdpc.Rows[e.RowIndex]; HiddenField hdnID = (HiddenField)row.FindControl("hdnID"); TextBox name = (TextBox)row.FindControl("txtname"); TextBox pwd = (TextBox)row.FindControl("txtpwd"); TextBox location = (TextBox)row.FindControl("txtloc"); DropDownList loc1 = (DropDownList)row.FindControl("ddlloc1"); PlacementConsultantBO bo = new PlacementConsultantBO(); bo.pcid = Convert.ToInt32(hdnID.Value.ToString()); bo.pcname = Convert.ToString(name.Text); bo.pwd = Convert.ToString(pwd.Text); bo.loc = Convert.ToString(loc1.Text); PlacementConsultantBL update = new PlacementConsultantBL(); int result1 = update.UpdatePC(bo); if (result1 == 1) { Page.ClientScript.RegisterStartupScript(this.GetType(), "alertkey", "<script>alert('Details Updated successfully');</script>", false); } grdpc.EditIndex = -1; bind(); }
protected void btnSubmit_Click(object sender, EventArgs e) { string name = txtpcname.Text; string pwd = txtPwd.Text; string loc = ddlloc.SelectedValue; int HRID = Convert.ToInt32(Session["UserID"].ToString()); PlacementConsultantBO bo = new PlacementConsultantBO(); bo.pcname = name; bo.pwd = pwd; bo.loc = loc; bo.HRID = HRID; PlacementConsultantBL bl1 = new PlacementConsultantBL(); int result = bl1.AddPlacementConsultant(bo); if (result == 1) { ClientScript.RegisterStartupScript(Page.GetType(), "alertMessage", "alert('Placement Consultant added successfully');window.location='HRHome.aspx';", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alertMessage", "alert('Failure')", true); } }
public int AddPlacementConsultant(PlacementConsultantBO bo) { string ConnectionString = "Data Source=ingnrilpsql02;" + "Initial Catalog=AHD13_AMS60;" + "User id=a36;" + "Password=a36;"; SqlConnection connection = new SqlConnection(ConnectionString); //Connection is opened using Open method //create command object SqlCommand command = new SqlCommand(); //Set command type as stored procedure command.CommandType = CommandType.StoredProcedure; //Command text is stored procedure name if command type is stored command.CommandText = "sp_Group4AddPlacementConsultant"; //Used to relate command object to connection command.Connection = connection; //Used to pass parameter to procedure command.Parameters.AddWithValue("@PlacementConsultantName", bo.pcname); command.Parameters.AddWithValue("@PlacementConsultantPassword", bo.pwd); command.Parameters.AddWithValue("@Location", bo.loc); command.Parameters.AddWithValue("@EmployeeID", bo.HRID); SqlParameter outputparameter = new SqlParameter(); outputparameter.ParameterName = "@PlacementConsultantID"; outputparameter.SqlDbType = System.Data.SqlDbType.Int; outputparameter.Direction = System.Data.ParameterDirection.Output; command.Parameters.Add(outputparameter); try { connection.Open(); int rowAffected = command.ExecuteNonQuery(); if (rowAffected > 0) { return(1); } else { //returntype = false; return(rowAffected); } } catch (SqlException ex) { Console.WriteLine(ex.Message); } finally { command.Dispose(); connection.Dispose(); connection.Close(); } return(0); }
public int UpdatePC(PlacementConsultantBO bo) { string ConnectionString = "Data Source=ingnrilpsql02;" + "Initial Catalog=AHD13_AMS60;" + "User id=a36;" + "Password=a36;"; SqlConnection connection = new SqlConnection(ConnectionString); //Connection is opened using Open method //create command object SqlCommand command = new SqlCommand(); //Set command type as stored procedure command.CommandType = CommandType.StoredProcedure; //Command text is stored procedure name if command type is stored command.CommandText = "sp_Group4UpdatePC"; //Used to relate command object to connection command.Connection = connection; //Used to pass parameter to procedure command.Parameters.AddWithValue("@PlacementConsultantID", bo.pcid); command.Parameters.AddWithValue("@PlacementConsultantName", bo.pcname); command.Parameters.AddWithValue("@PlacementConsultantPassword", bo.pwd); command.Parameters.AddWithValue("@Location", bo.loc); try { connection.Open(); int rowAffected = command.ExecuteNonQuery(); connection.Close(); ////Connection should be closed after use. Its done using close method // Used to return the value of output parameter if (rowAffected > 0) { return(1); } else { //returntype = false; return(rowAffected); } } catch (SqlException ex) { Console.WriteLine(ex.Message); } finally { command.Dispose(); connection.Dispose(); connection.Close(); } return(0); }
public int UpdatePC(PlacementConsultantBO bo) { PlacementConsultantDB db2 = new PlacementConsultantDB(); return(db2.UpdatePC(bo)); }
public int AddPlacementConsultant(PlacementConsultantBO bo) { PlacementConsultantDB db = new PlacementConsultantDB(); return(db.AddPlacementConsultant(bo)); }