protected void btnaddSave_Click(object sender, EventArgs e) { if (Session["user"] == null || Session["access"] != "ADMIN") { Response.Redirect("../index.aspx"); } SqlTrainingHistory.InsertParameters["USER_ISN"].DefaultValue = dropaddUser.SelectedValue; SqlTrainingHistory.InsertParameters["TRAINING_CODE_ISN"].DefaultValue = dropaddTraining.SelectedValue; SqlTrainingHistory.InsertParameters["TRAINING_DATE"].DefaultValue = txtaddTrainingDate.Text.Trim(); SqlTrainingHistory.InsertParameters["TRAINING_TYPE_ISN"].DefaultValue = dropaddTrainingType.SelectedValue; SqlTrainingHistory.InsertParameters["NOTE"].DefaultValue = txtAddNote.Text.ToUpper().Trim(); string UserName = (string)Session["commonname"]; string CurrentDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); SqlTrainingHistory.InsertParameters["TRAINING_STATUS_ISN"].DefaultValue = dropaddTrainingStatus.SelectedValue; SqlTrainingHistory.InsertParameters["ADDED_BY"].DefaultValue = UserName.ToUpper().Trim(); SqlTrainingHistory.InsertParameters["ADDED_DATE"].DefaultValue = CurrentDate; SqlTrainingHistory.InsertParameters["UPDATED_BY"].DefaultValue = UserName.ToUpper().Trim(); SqlTrainingHistory.InsertParameters["UPDATED_DATE"].DefaultValue = CurrentDate; try { SqlTrainingHistory.Insert(); txtaddTrainingDate.Text = string.Empty; txtAddNote.Text = string.Empty; adderror.Text = string.Empty; dropaddUser.SelectedIndex = -1; dropTraining.SelectedIndex = -1; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("alert('Training Added Successfully.');"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); gvTrainingHistory.DataBind(); upTrainingHistory.Update(); } catch { adderror.Text = "An error has occurred while adding a training."; adderror.ForeColor = System.Drawing.Color.Red; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#addModal').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); } }
protected void btnUpdateTraining_Click(object sender, EventArgs e) { if (Session["user"] == null || Session["access"] != "ADMIN") { Response.Redirect("../index.aspx"); } string UserName = (string)Session["commonname"]; string CurrentDate = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); SqlTrainingHistory.UpdateParameters["TRAINING_ISN"].DefaultValue = trainingisn.Value; SqlTrainingHistory.UpdateParameters["USER_ISN"].DefaultValue = dropUser.SelectedValue; SqlTrainingHistory.UpdateParameters["NOTE"].DefaultValue = txtNote.Text; SqlTrainingHistory.UpdateParameters["TRAINING_TYPE_ISN"].DefaultValue = dropTrainingType.SelectedValue; SqlTrainingHistory.UpdateParameters["TRAINING_CODE_ISN"].DefaultValue = dropTraining.SelectedValue; SqlTrainingHistory.UpdateParameters["TRAINING_STATUS_ISN"].DefaultValue = dropTrainingStatus.SelectedValue; SqlTrainingHistory.UpdateParameters["TRAINING_DATE"].DefaultValue = txtTrainingDate.Text.Trim(); SqlTrainingHistory.UpdateParameters["UPDATED_BY"].DefaultValue = UserName.ToUpper().Trim(); SqlTrainingHistory.UpdateParameters["UPDATED_DATE"].DefaultValue = CurrentDate; try { SqlTrainingHistory.Update(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("alert('Training Profile Updated Successfully');"); sb.Append("$('#editModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "EditHideModalScript", sb.ToString(), false); gvTrainingHistory.DataBind(); upTrainingHistory.Update(); } catch { editError.Text = "Error: Record NOT updated."; editError.ForeColor = System.Drawing.Color.Red; System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#editModal').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddShowModalScript", sb.ToString(), false); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["user"] == null || Session["access"] != "ADMIN") { Response.Redirect("../index.aspx"); } if (!IsPostBack) { Session["mainselect"] = "SELECT TRAININGHISTORY.TRAINING_ISN, TRAININGHISTORY.TRAINING_TYPE_ISN, TRAININGHISTORY.USER_ISN, TRAININGHISTORY.TRAINING_CODE_ISN, TRAININGHISTORY.TRAINING_DATE, TRAININGHISTORY.NOTE, TRAININGHISTORY.ADDED_BY, TRAININGHISTORY.ADDED_DATE, TRAININGHISTORY.UPDATED_BY, TRAININGHISTORY.UPDATED_DATE, USERPROFILE.LAST_NAME + ', ' + USERPROFILE.FIRST_NAME AS NAME, CODE.CODE_DESCRIPTION, CODE.CODE_ID, TRAININGSTATUS.CODE_DESCRIPTION AS TRAINING_STATUS, TRAININGSTATUS.CODE_ID AS STATUS, TRAININGHISTORY.TRAINING_STATUS_ISN, TRAININGTYPE.CODE_ID AS TRAININGTYPE, TRAININGTYPE.CODE_DESCRIPTION AS TRAININGTYPEDESCRIPTION FROM TRAININGHISTORY INNER JOIN USERPROFILE ON TRAININGHISTORY.USER_ISN = USERPROFILE.USER_ISN INNER JOIN CODE AS TRAININGTYPE ON TRAININGTYPE.CODE_ISN = TRAININGHISTORY.TRAINING_TYPE_ISN INNER JOIN CODE ON CODE.CODE_ISN = TRAININGHISTORY.TRAINING_CODE_ISN LEFT OUTER JOIN CODE AS TRAININGSTATUS ON TRAININGHISTORY.TRAINING_STATUS_ISN = TRAININGSTATUS.CODE_ISN ORDER BY USERPROFILE.LAST_NAME, TRAININGHISTORY.TRAINING_DATE DESC"; SqlTrainingHistory.SelectCommand = (string)Session["mainselect"]; SqlTrainingHistory.DataBind(); } if (IsPostBack) { SqlTrainingHistory.SelectCommand = (string)Session["mainselect"]; SqlTrainingHistory.DataBind(); } }