예제 #1
0
        /// <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);
        }