Exemple #1
0
        protected void btnTitleAdd_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                _currentTitle = new Title();

                if (txtTitlesID.Text.ToString() != "0")
                    _currentTitle.AddEditOption = 1;
                else
                    _currentTitle.AddEditOption = 0;

                _currentTitle.TitleID = Convert.ToInt32(txtTitlesID.Text.ToString());
                _currentTitle.TitleDescription = txtTitles.Text.ToString();

                TransactionResult result;
                _currentTitle.ScreenMode = ScreenMode.Add;
                result = _currentTitle.Commit();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script>alert('" + result.Message.ToString() + ".');");
                sb.Append("</script>");
                ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);

                if (result.Status == TransactionStatus.Success)
                {
                    txtTitles.Text = "";
                    txtTitlesID.Text = "0";
                    GetTitleDetails();
                }
                else
                {
                    txtTitlesID.Text = "0";
                    txtTitles.Text = "";
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Titles.aspx", "", "btnTitleAdd_Click", ex.Message.ToString(), new ECGroupConnection());
                throw;
            }
        }
Exemple #2
0
        protected void gvTitle_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                TransactionResult result;
                // Get the selected row's title id
                int titleIDToDelete = Convert.ToInt32(gvTitle.DataKeys[e.RowIndex].Value);

                // Delete the selected title
                _currentTitle = new Title();
                _currentTitle.TitleID = titleIDToDelete;
                _currentTitle.ScreenMode = ScreenMode.Delete;
                result = _currentTitle.Commit();

                // Display the status of the delete
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script>alert('" + result.Message.ToString() + ".');");
                sb.Append("</script>");
                ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false);

                // If successfully deleted
                if (result.Status == TransactionStatus.Success)
                {
                    GetTitleDetails();
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Titles.aspx", "", "gvTitle_RowDeleting", ex.Message.ToString(), new ECGroupConnection());
                throw;
            }
        }