Esempio 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();
        }
Esempio n. 2
0
        protected void ctlLocationLookup_OnObjectLookUpReturn(object sender, ObjectLookUpReturnArgs e)
        {
            IList <DbLocation>            locationList            = (IList <DbLocation>)e.ObjectReturn;
            IList <DbServiceTeamLocation> serviceTeamLocationList = new List <DbServiceTeamLocation>();

            foreach (DbLocation location in locationList)
            {
                Location locate = new Location();
                locate.LocationID = location.LocationID;
                DbServiceTeam         serviceTeam         = ScgDbQueryProvider.DbServiceTeamQuery.FindByIdentity(Convert.ToInt64(ctlServiceTeamIDHidden.Value));
                DbServiceTeamLocation serviceTeamLocation = GetServiceTeamLocation(serviceTeam, locate);
                serviceTeamLocationList.Add(serviceTeamLocation);
            }

            if (serviceTeamLocationList.Count > 0)
            {
                try
                {
                    DbServiceTeamLocationService.AddServiceTeamLocationList(serviceTeamLocationList);
                    ctlLocationGrid.DataCountAndBind();
                }
                catch (ServiceValidationException ex)
                {
                    ValidationErrors.MergeErrors(ex.ValidationErrors);
                }
            }
            ctlUpdatePanelLocationGrid.Update();
        }
Esempio n. 3
0
        private DbServiceTeamLocation  GetServiceTeamLocation(DbServiceTeam serviceTeam, Location location)
        {
            DbServiceTeamLocation serviceTeamLocation = new DbServiceTeamLocation();

            serviceTeamLocation.ServiceTeamID = new DbServiceTeam(serviceTeam.ServiceTeamID);
            serviceTeamLocation.LocationID    = new DbLocation(location.LocationID.Value);
            serviceTeamLocation.Active        = true;
            serviceTeamLocation.CreBy         = UserAccount.UserID;
            serviceTeamLocation.CreDate       = DateTime.Now;
            serviceTeamLocation.UpdBy         = UserAccount.UserID;
            serviceTeamLocation.UpdDate       = DateTime.Now;
            serviceTeamLocation.UpdPgm        = ProgramCode;

            return(serviceTeamLocation);
        }