/// <summary> /// To save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { string message = string.Empty; string AlertMessage = string.Empty; if (ConcernIDTextBox.Text == string.Empty) { FenceDescriptionBOObj = new FenceDescriptionBO(); FenceDescriptionBOObj.FenceDescription = txtFenceDescription.Text.ToString(); FenceDescriptionBOObj.Createdby = Convert.ToInt32(Session["USER_ID"].ToString()); FenceDescriptionBLLObj = new FenceDescriptionBLL(); message = FenceDescriptionBLLObj.insert(FenceDescriptionBOObj); AlertMessage = "alert('" + message + "');"; if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data saved successfully"; ClearFields(); BindGrid(true, true); } //BindGrid(true, true); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Fence description details added successfully');", true); // ClearFields(); } else { int reasonid = Convert.ToInt32(ViewState["FenceID"]); FenceDescriptionBOObj = new FenceDescriptionBO(); FenceDescriptionBOObj.FenceDescription = txtFenceDescription.Text.ToString(); FenceDescriptionBOObj.Createdby = Convert.ToInt32(Session["USER_ID"].ToString()); FenceDescriptionBLLObj = new FenceDescriptionBLL(); message = FenceDescriptionBLLObj.Update(FenceDescriptionBOObj, reasonid); if (string.IsNullOrEmpty(message) || message == "" || message == "null") { message = "Data updated successfully"; BindGrid(true, true); ClearFields(); } } //BindGrid(true, true); //ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Fence description details updated successfully');", true); //ClearFields(); AlertMessage = "alert('" + message + "');"; ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true); SetUpdateMode(false); }
/// <summary> /// To save details to database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Insert() { try { FenceDescriptionBOObj = new FenceDescriptionBO(); FenceDescriptionBOObj.FenceDescription = txtFenceDescription.Text.ToString(); FenceDescriptionBOObj.Createdby = 1; FenceDescriptionBLLObj = new FenceDescriptionBLL(); FenceDescriptionBLLObj.insert(FenceDescriptionBOObj); } catch (Exception ex) { throw ex; } finally { FenceDescriptionBLLObj = null; } }