Exemplo n.º 1
0
        protected void ctlDeleteLocation_Click(object sender, ImageClickEventArgs e)
        {
            foreach (GridViewRow row in ctlLocationGrid.Rows)
            {
                if ((row.RowType == DataControlRowType.DataRow) && (((CheckBox)row.FindControl("ctlSelect")).Checked))
                {
                    try
                    {
                        long serviceTeamLocationId = UIHelper.ParseLong(ctlLocationGrid.DataKeys[row.RowIndex]["ServiceTeamLocationID"].ToString());
                        DbServiceTeamLocation serviceTeamLocation = ScgDbQueryProvider.DbServiceTeamLocationQuery.FindByIdentity(serviceTeamLocationId);
                        DbServiceTeamLocationService.Delete(serviceTeamLocation);
                    }
                    catch (Exception ex)
                    {
                        if (((System.Data.SqlClient.SqlException)(ex.GetBaseException())).Number == 547)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AlertInUseData",
                                                                    "alert('This data is now in use.');", true);

                            ctlUpdatePanelLocationGrid.Update();
                        }
                    }
                }
            }
            ctlLocationGrid.DataCountAndBind();
            ctlUpdatePanelLocationGrid.Update();
        }