/// <summary> /// Update Database Make data as Obsoluted /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void IsObsolete_CheckedChanged(Object sender, EventArgs e) { string message = string.Empty; try { CheckBox chk = (CheckBox)sender; GridViewRow gr = (GridViewRow)chk.Parent.Parent; string APPROVALTEMPAUTHORISERID = ((Literal)gr.FindControl("litLineTypeID")).Text; TemporaryAuthorizationBLL objtempBLL = new TemporaryAuthorizationBLL(); TemporaryAuthorizationBO objtemp = objtempBLL.GetTempAuthorizationsByID(Convert.ToInt32(APPROVALTEMPAUTHORISERID)); objtempBLL.ObsoleteTempAuthorizationsByID(Convert.ToInt32(APPROVALTEMPAUTHORISERID), Convert.ToString(chk.Checked)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data Updated successfully"; } string status = ""; if (!chk.Checked) { status = "INS"; } SendMailForUser(status, Convert.ToInt32(objtemp.AssignedTo), objtemp); ClearDetails(); Bindgrid(); if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } }
/// <summary> /// To save details to the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string result = string.Empty; string AlertMessage = string.Empty; objTemporaryAuthorizationBLL = new TemporaryAuthorizationBLL(); objTemporaryAuthorizationBO = new TemporaryAuthorizationBO(); try { objTemporaryAuthorizationBO.Assigntoid = Convert.ToInt32(ddlAssignTo.SelectedValue); objTemporaryAuthorizationBO.Authoriserid = Convert.ToInt32(Session["USER_ID"]); objTemporaryAuthorizationBO.Fromdate = Convert.ToDateTime(dptxtFrom.Text); objTemporaryAuthorizationBO.Todate = Convert.ToDateTime(dptxtTo.Text); objTemporaryAuthorizationBO.Remarks = txtRemarks.Text.Trim(); if (objTemporaryAuthorizationBO.Remarks.Length > 500) { objTemporaryAuthorizationBO.Remarks = objTemporaryAuthorizationBO.Remarks.Substring(0, 499); } objTemporaryAuthorizationBO.ProjectID = Convert.ToInt32(Session["PROJECT_ID"]); objTemporaryAuthorizationBO.Createdby = Convert.ToInt32(Session["USER_ID"]); objTemporaryAuthorizationBO.Approvaltempauthoriserid = Convert.ToInt32(ViewState["TEMPAUTHID"]); result = objTemporaryAuthorizationBLL.AddTemporaryAuthorization(objTemporaryAuthorizationBO); SendMailForUser("INS", Convert.ToInt32(ddlAssignTo.SelectedValue), objTemporaryAuthorizationBO); if (string.IsNullOrEmpty(result) || result == "" || result == "null") { if (Convert.ToInt32(ViewState["TEMPAUTHID"]) == 0) { result = "Temporary Authorization added successfully"; } else if (result == "Temp Authorization already exists in the system.") { result = "Temporary Authorization already exists"; } else { result = "Temporary Authorization Updated successfully"; } AlertMessage = "alert('" + result + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); } else { AlertMessage = "alert('" + result + "');"; } ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); ClearDetails(); } catch (Exception ex) { AlertMessage = "alert('" + ex + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); } Bindgrid(); }
/// <summary> /// Set edit mode for edit comand /// Delete data from the database for delete comand /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grdTempAuth_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; try { if (e.CommandName == "EditRow") { ViewState["TEMPAUTHID"] = e.CommandArgument; TemporaryAuthorizationBLL objtempBLL = new TemporaryAuthorizationBLL(); TemporaryAuthorizationBO objtemp = objtempBLL.GetTempAuthorizationsByID(Convert.ToInt32(ViewState["TEMPAUTHID"])); ddlAssignTo.ClearSelection(); if (ddlAssignTo.Items.FindByValue(objtemp.AssignedTo) != null) { ddlAssignTo.Items.FindByValue(objtemp.AssignedTo).Selected = true; } dptxtFrom.Text = Convert.ToDateTime(objtemp.Fromdate).ToString(UtilBO.DateFormat); dptxtTo.Text = Convert.ToDateTime(objtemp.Todate).ToString(UtilBO.DateFormat); txtRemarks.Text = objtemp.Remarks; btnSave.Text = "Update"; btnClear.Text = "Cancel"; } else if (e.CommandName == "DeleteRow") { TemporaryAuthorizationBLL objtempBLL = new TemporaryAuthorizationBLL(); objtempBLL.DeleteTempAuthorizationsByID(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data deleted successfully"; } ClearDetails(); Bindgrid(); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void Bindgrid() { objTemporaryAuthorizationBLL = new TemporaryAuthorizationBLL(); grdTempAuth.DataSource = objTemporaryAuthorizationBLL.GetTempAuthorizationsByUser(Convert.ToInt32(Session["USER_ID"].ToString()), Convert.ToInt32(Session["PROJECT_ID"].ToString())); grdTempAuth.DataBind(); }