示例#1
0
        protected void btnCitySave_Click(object sender, ImageClickEventArgs e)
        {
            try
            {
                // Create a new City Object
                _currentCity = new City();

                // Set whether Add / Edit
                if (txtCityID.Text.ToString() != "0")
                    _currentCity.AddEditOption = 1;
                else
                    _currentCity.AddEditOption = 0;

                // Assign values to the City Object
                _currentCity.StateID = Convert.ToInt32(ddlCountryState.SelectedValue.ToString());
                _currentCity.CityID = Convert.ToInt32(txtCityID.Text.ToString());
                _currentCity.CityDescription = txtCity.Text.ToString();

                // Add / Edit the City
                TransactionResult result;
                _currentCity.ScreenMode = ScreenMode.Add;
                result = _currentCity.Commit();

                // Display the Status - Whether successfully saved or not
                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 successful
                if (result.Status == TransactionStatus.Success)
                {
                    ddlCityState_SelectedIndexChanged(sender, e);
                    txtCityID.Text = "";
                    txtCity.Text = "";
                    tcntAllCSCTabs.ActiveTab = tpnlCity;
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Countries.aspx", "", "btnCitySave_Click", ex.Message.ToString(), new ECGroupConnection());
                throw;
            }
        }
示例#2
0
        protected void gvCity_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            try
            {
                TransactionResult result;
                // Get the selected row's City id
                int cityIDToDelete = Convert.ToInt32(gvCity.DataKeys[e.RowIndex].Value);

                // Delete the selected City
                _currentCity = new City();
                _currentCity.CityID = cityIDToDelete;
                _currentCity.ScreenMode = ScreenMode.Delete;
                result = _currentCity.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)
                {
                    ddlCityState_SelectedIndexChanged(sender, e);
                    tcntAllCSCTabs.ActiveTab = tpnlCity;
                }
            }
            catch (Exception ex)
            {
                ErrorLog.LogErrorMessageToDB("Countries.aspx", "", "gvCity_RowDeleting", ex.Message.ToString(), new ECGroupConnection());
                throw;
            }
        }