/// <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; SharedAuthorizationBLL objtempBLL = new SharedAuthorizationBLL(); SharedAuthorizationBO objtemp = objtempBLL.GetSharedAuthorizationsByID(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> /// Set Grid Data source /// </summary> /// <param name="addRow"></param> /// <param name="deleteRow"></param>e private void Bindgrid() { oSharedAuthorizationBLL = new SharedAuthorizationBLL(); int UserId = 0, ProjectId = 0; if (Session["USER_ID"] != null) { UserId = Convert.ToInt32(Session["USER_ID"].ToString()); } if (Session["PROJECT_ID"] != null) { ProjectId = Convert.ToInt32(Session["PROJECT_ID"].ToString()); } grdTempAuth.DataSource = oSharedAuthorizationBLL.GetSharedAuthorizationsByUser(UserId, ProjectId); grdTempAuth.DataBind(); }
/// <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["SharedUser"] = e.CommandArgument; SharedAuthorizationBLL objtempBLL = new SharedAuthorizationBLL(); SharedAuthorizationBO objtemp = objtempBLL.GetSharedAuthorizationsByID(Convert.ToInt32(ViewState["SharedUser"].ToString())); ddlAssignTo.ClearSelection(); ddlAssignTo.SelectedValue = objtemp.AssignedToId.ToString(); ddlModuleDropDownList.ClearSelection(); ddlModuleDropDownList.SelectedValue = objtemp.ModuleId.ToString(); getWorkfolwitemByModuleID(); ddlWorkflowItemDropDownList.ClearSelection(); ddlWorkflowItemDropDownList.SelectedValue = objtemp.WorkFlowId.ToString(); txtRemarks.Text = objtemp.Remarks.ToString(); btnSave.Text = "Update"; btnClear.Text = "Cancel"; } else if (e.CommandName == "DeleteRow") { SharedAuthorizationBLL objtempBLL = new SharedAuthorizationBLL(); objtempBLL.DeleteSharedAuthorizationsByID(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> /// 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; oSharedAuthorizationBLL = new SharedAuthorizationBLL(); oSharedAuthorizationBO = new SharedAuthorizationBO(); try { if (ViewState["SharedUser"] != null) { oSharedAuthorizationBO.WorkFlowSharedId = Convert.ToInt32(Convert.ToInt32(ViewState["SharedUser"].ToString())); } oSharedAuthorizationBO.AssignedToId = Convert.ToInt32(ddlAssignTo.SelectedValue); oSharedAuthorizationBO.AuthoriserId = Convert.ToInt32(Session["USER_ID"]); oSharedAuthorizationBO.ModuleId = Convert.ToInt32(ddlModuleDropDownList.Text); oSharedAuthorizationBO.WorkFlowId = Convert.ToInt32(ddlWorkflowItemDropDownList.Text); oSharedAuthorizationBO.Remarks = txtRemarks.Text.Trim(); if (oSharedAuthorizationBO.Remarks.Length > 500) { oSharedAuthorizationBO.Remarks = oSharedAuthorizationBO.Remarks.Substring(0, 499); } oSharedAuthorizationBO.ProjectId = Convert.ToInt32(Session["PROJECT_ID"]); oSharedAuthorizationBO.CreatedBy = Convert.ToInt32(Session["USER_ID"]); // oSharedAuthorizationBO.AuthoriserId = Convert.ToInt32(ViewState["SharedUser"]); //if (ViewState["SharedUser"] != null && Convert.ToInt32(ViewState["SharedUser"].ToString()) == 0) //{ // result = oSharedAuthorizationBLL.AddSharedAuthorization(oSharedAuthorizationBO); //} //else result = oSharedAuthorizationBLL.AddSharedAuthorization(oSharedAuthorizationBO); if (string.IsNullOrEmpty(result) || result == "" || result == "null") { if (Convert.ToInt32(ViewState["SharedUser"]) == 0) { result = "Shared Authorization added successfully"; SendMailForUser("INS", Convert.ToInt32(ddlAssignTo.SelectedValue), oSharedAuthorizationBO); } else if (result == "Shared Authorization already exists in the system.") { result = "Shared Authorization already exists"; } else { result = "Shared Authorization Updated successfully"; SendMailForUser("INS", Convert.ToInt32(ddlAssignTo.SelectedValue), oSharedAuthorizationBO); } 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(); }