Esempio n. 1
0
        /// <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 grdProjectGeo_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string message = string.Empty;

            try
            {
                if (e.CommandName == "EditRow")
                {
                    ViewState["Geography_ID"] = e.CommandArgument;
                    GeographyBO oGeo = (new ProjectBLL()).GetProjectGeographyByProjectID(Convert.ToInt32(ViewState["Geography_ID"]));

                    if (oGeo != null)
                    {
                        txtGeneralDirection.Text = oGeo.GeneralDirection;
                        txtKeyGeoFeatures.Text   = oGeo.KeyFeatures;
                    }
                    btnSave.Text  = "Update";
                    btnClear.Text = "Cancel";
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "Added", "setDirty();", true);
                }

                else if (e.CommandName == "DeleteRow")
                {
                    ProjectBLL ProjectBLLobj = new ProjectBLL();
                    message = ProjectBLLobj.DeleteProjGeo(Convert.ToInt32(e.CommandArgument));
                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data Deleted successfully";
                    }

                    BindGrid();
                    ClearDetails();
                }
                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }