本文整理汇总了C#中City.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# City.Commit方法的具体用法?C# City.Commit怎么用?C# City.Commit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类City
的用法示例。
在下文中一共展示了City.Commit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnCitySave_Click
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: gvCity_RowDeleting
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;
}
}