/// <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; ViewState["RELATIONSHIPID"] = ((Literal)gr.FindControl("litRELATIONSHIPID")).Text; RelationshipBLL objrelBLL = new RelationshipBLL(); message = objrelBLL.ObsoleteRelationship(Convert.ToInt32(ViewState["RELATIONSHIPID"]), Convert.ToString(chk.Checked)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; } BindGrid(false, true); 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(bool addRow, bool deleteRow) { RelationshipBO objRel = new RelationshipBO(); RelationshipBLL objRElBLL = new RelationshipBLL(); grdRelationship.DataSource = objRElBLL.GetALLRelationship(); grdRelationship.DataBind(); }
/// <summary> /// To save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btn_Save_Click(object sender, EventArgs e) { string AlertMessage = string.Empty; string message = string.Empty; RelationshipBO objRel = new RelationshipBO(); objRel.RELATIONSHIPID = int.Parse(ViewState["RELATIONSHIPID"].ToString()); objRel.RELATIONSHIP = txtrel.Text.Trim(); objRel.UserID = Convert.ToInt32(Session["USER_ID"].ToString()); RelationshipBLL objRelBLL = new RelationshipBLL(); if (objRel.RELATIONSHIPID == 0) { message = objRelBLL.AddRelation(objRel); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Relationship added successfully');", true); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearDetails(); //BindGrid(true, true); } } else { message = objRelBLL.UpdateRelationship(objRel); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Updated", "alert('Relationship updated successfully');", true); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; ClearDetails(); SetUpdateMode(false); } btn_Save.Text = "Save"; ViewState["RELATIONSHIPID"] = 0; } //ClearDetails(); //BindGrid(true, false); AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); }
/// <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 grdRelationship_RowCommand(object sender, GridViewCommandEventArgs e) { string message = string.Empty; if (e.CommandName == "EditRow") { ViewState["RELATIONSHIPID"] = e.CommandArgument; RelationshipBO objRel = null; RelationshipBLL objrelBLL = new RelationshipBLL(); objRel = objrelBLL.GetRelationshipByID(Convert.ToInt32(ViewState["RELATIONSHIPID"])); if (objRel != null) { txtrel.Text = objRel.RELATIONSHIP; } SetUpdateMode(true); ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true); } else if (e.CommandName == "DeleteRow") { // ViewState["RELATIONSHIPID"] = e.CommandArgument; RelationshipBLL objrelBLL = new RelationshipBLL(); message = objrelBLL.DeleteRelation(Convert.ToInt32(e.CommandArgument)); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data Deleted successfully"; } SetUpdateMode(true); BindGrid(false, true); } if (message != "") { ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true); } }