Esempio n. 1
0
        public ActionResult Edit(int id)
        {
            LookupCode model = new LookupCode(RepoLookup.FindByPK(id));

            ViewBag.name = model.Nama;
            return(View("Form", model));
        }
Esempio n. 2
0
        public async Task <LookupCode> Update(LookupCode lookupCode)
        {
            _db.LookupCode.Update(lookupCode);
            await _db.SaveChangesAsync();

            return(lookupCode);
        }
Esempio n. 3
0
        protected void InsertButtonClick(object sender, CommandEventArgs e)
        {
            LookupCode biz = new LookupCode();

            //biz.NewRow(); // erroneous call

            //dr["LookupCodeId"]= lkpCodeId.Value;
            if (Request.Form["lkpName"] != null)
            {
                biz["LkpFieldName"] = Request.Form["lkpName"];
            }
            else
            {
                biz["LkpFieldName"] = lkpFieldName.Value;
            }
            biz["LkpCode"]        = lkpValue.Value;
            biz["LkpDescription"] = lkpDescription.Value;
            biz["LkpOrder"]       = PageUtil.ObjToInt(lkpOrder.Value);
            biz["LkpSuppress"]    = lkpSuppress.Checked;
            biz["UpdatedBy"]      = User.Identity.Name;
            biz["UpdatedTime"]    = DateTime.Now;
            biz["EnteredBy"]      = User.Identity.Name;
            biz["EnteredTime"]    = DateTime.Now;

            biz.Save();

            if (fieldName.SelectedIndex == 0)
            {
                Server.Transfer("AdminLookupCodes.aspx");
            }
            else
            {
                this.Page_Load(sender, e);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Builds a grid populated with the current LkpFieldName
        /// </summary>
        /// <param name="lkpField"></param>
        private bool BuildLookupCodeList(string lkpField)
        {
            InitParamaters();

            LookupCodeDa da       = new LookupCodeDa();
            var          lkpCodes = LookupCode.GetByFieldsAsDataView <LookupCode>(new Dictionary <string, object>
            {
                { LookupCode.LkpFieldName, lkpField }
            });
            // sort by, then alpha numeric
            DataColumn sortCol  = new DataColumn("_Sort", typeof(int), "ISNULL(LkpOrder," + int.MaxValue + ")");
            DataColumn sortCol2 = new DataColumn("_Sort2", typeof(int), "ISNULL(LookupCodeId," + int.MaxValue + ") - ISNULL(LookupCodeId," + int.MaxValue + " - 1)");

            lkpCodes.Table.Columns.Add(sortCol);
            lkpCodes.Table.Columns.Add(sortCol2);
            lkpCodes.Sort = "_Sort ASC, _Sort2 ASC, " + LookupCode.LkpCode + " ASC";
            // build main lookup code list

            LookupCodeGrid.DataSource = lkpCodes;
            LookupCodeGrid.DataBind();

            DataSet   ds = da.GetLookupCodeStats(lkpField, _diseaseName);
            DataTable lookupByMetadata   = ds.Tables[0];
            int       lookupCodeCount    = (int)ds.Tables[1].Rows[0][0];
            int       lookupDiseaseCount = (int)ds.Tables[2].Rows[0][0];

            BuildLkpStats(lookupByMetadata, lookupDiseaseCount, lookupCodeCount);

            return(lookupCodeCount > 0);
        }
Esempio n. 5
0
        public static FlightId GetFlightID(bool arr, string airline, string fltnum, double offset = 0.0)
        {
            LookupCode apCode = new LookupCode();

            apCode.codeContextField = CodeContext.IATA;
            apCode.valueField       = Parameters.APT_CODE;
            LookupCode[] ap = { apCode };

            LookupCode alCode = new LookupCode();

            alCode.codeContextField = CodeContext.IATA;
            alCode.valueField       = airline;;
            LookupCode[] al = { alCode };


            FlightId flightID = new FlightId();

            flightID.flightKindField        = arr ? FlightKind.Arrival : FlightKind.Departure;
            flightID.airportCodeField       = ap;
            flightID.airlineDesignatorField = al;
            flightID.scheduledDateField     = DateTime.Now.AddDays(offset);
            flightID.flightNumberField      = fltnum;

            return(flightID);
        }
        public void RollbackDataTest()
        {
            var lookupCode = new LookupCode
            {
                Description = "desc"
            };

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope())
                    {
                        dbContext.LookupCode.Add(lookupCode);
                        dbContext.SaveChanges();
                        scope2.Complete();
                    }
                    //No scope complete, should rollback.
                }
            }

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id);
                Assert.Null(workSectionCode2);
            }
        }
        public void PersistingDataTest()
        {
            var lookupCode = new LookupCode
            {
                Description = "desc"
            };

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                using (TransactionScope scope = new TransactionScope())
                {
                    using (TransactionScope scope2 = new TransactionScope())
                    {
                        dbContext.LookupCode.Add(lookupCode);
                        dbContext.SaveChanges();
                        scope2.Complete();
                        scope.Complete();
                    }
                }
            }

            using (var dbContext = new SheriffDbContext(EnvironmentBuilder.SetupDbOptions()))
            {
                var workSectionCode2 = dbContext.LookupCode.Find(lookupCode.Id);
                Assert.NotNull(workSectionCode2);
                dbContext.Remove(workSectionCode2);
                dbContext.SaveChanges();
            }
        }
Esempio n. 8
0
        public async Task <LookupCode> Add(LookupCode courtRoleCode)
        {
            await _db.LookupCode.AddAsync(courtRoleCode);

            await _db.SaveChangesAsync();

            return(courtRoleCode);
        }
Esempio n. 9
0
        public void delete(LookupCode dbitem)
        {
            context.LookupCode.Remove(dbitem);
            var auditrail = new Auditrail {
                Actionnya = "Delete", EventDate = DateTime.Now, Modulenya = "Lookup Code", QueryDetail = "Delete " + dbitem.Deskripsi, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
            };

            context.Auditrail.Add(auditrail);
            context.SaveChanges();
        }
Esempio n. 10
0
        protected void DeleteButtonClick(object sender, CommandEventArgs e)
        {
            int        lkpId = int.Parse(lkpCodeId.Value);
            LookupCode lk    = new LookupCode();

            lk.Delete(lkpId);

            this.ResetFields();

            this.Page_Load(sender, e);
        }
Esempio n. 11
0
        /// <summary>
        /// Adds a new LkpCode value for a LkpFieldName
        /// </summary>
        /// <param name="lkpField"></param>
        /// <param name="lkpCode"></param>
        /// <returns></returns>
        private int AddLookupCodeValue(string lkpField, string lkpCode, string lkpOrder)
        {
            LookupCode biz = new LookupCode();

            biz[LookupCode.LkpFieldName] = lkpField;
            biz[LookupCode.LkpCode]      = lkpCode;
            biz[LookupCode.LkpSuppress]  = 0;
            biz[LookupCode.LkpOrder]     = lkpOrder;
            biz.Save();
            return(int.Parse(biz[biz.PrimaryKeyName].ToString()));
        }
Esempio n. 12
0
        public ActionResult Edit(LookupCode model)
        {
            if (ModelState.IsValid)
            {
                Context.LookupCode dbitem = RepoLookup.FindByPK(model.Id);
                model.setDb(dbitem);
                RepoLookup.save(dbitem);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
Esempio n. 13
0
        public ActionResult Add(LookupCode model)
        {
            if (ModelState.IsValid)
            {
                Context.LookupCode dbitem = new Context.LookupCode();
                model.setDb(dbitem);
                RepoLookup.save(dbitem);

                return(RedirectToAction("Index"));
            }
            return(View("Form", model));
        }
Esempio n. 14
0
        /// <summary>
        /// Handles deleting event for record in Lookup Code Grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int    keyIndex = e.RowIndex;
            string priKey   = LookupCodeGrid.DataKeys[keyIndex][LookupCode.LookupCodeId].ToString();

            if (!string.IsNullOrEmpty(priKey))
            {
                int        lkpCodeId = int.Parse(priKey);
                LookupCode biz       = new LookupCode();
                biz.Delete(lkpCodeId);
                BindLookupCodesGrid();
            }
        }
Esempio n. 15
0
        private void flightSaktaubyValues(string propertyNameFieldtxt, string valueFieldtxt)
        {
            var todoItem = (flight)BindingContext;

            ServiceReference2.AMSIntegrationServiceClient proxy = new ServiceReference2.AMSIntegrationServiceClient(
                ServiceReference2.AMSIntegrationServiceClient.EndpointConfiguration.BasicHttpBinding_IAMSIntegrationService,
                "http://57.31.17.135/SITAAMSIntegrationService/v1/SITAAMSIntegrationService/");

            FlightId idFl = new FlightId();

            idFl.flightNumberField  = todoItem.FlightNumber;
            idFl.scheduledDateField = todoItem.FlightSTA;
            idFl.flightKindField    = FlightKind.Arrival;

            LookupCode asq = new LookupCode();

            asq.codeContextField = CodeContext.IATA;
            asq.valueField       = todoItem.CIata;


            ObservableCollection <LookupCode> airdEs = new ObservableCollection <LookupCode>();

            airdEs.Add(asq);
            idFl.airlineDesignatorField = airdEs;

            LookupCode qsa = new LookupCode();

            qsa.codeContextField = CodeContext.IATA;
            qsa.valueField       = "TSE";

            ObservableCollection <LookupCode> airportLo = new ObservableCollection <LookupCode>();

            airportLo.Add(qsa);
            idFl.airportCodeField = airportLo;

            PropertyValue val1 = new PropertyValue();

            val1.valueField        = valueFieldtxt;
            val1.propertyNameField = propertyNameFieldtxt;

            ObservableCollection <PropertyValue> values = new ObservableCollection <PropertyValue>();

            values.Add(val1);

            proxy.UpdateFlightCompleted += Proxy_UpdateFlightCompleted;
            proxy.UpdateFlightAsync(idFl, values);
        }
        public async Task <LookupCode> Update(LookupCode lookupCode)
        {
            lookupCode.SortOrderForLocation.ThrowBusinessExceptionIfNull("SortOrderForLocation cannot be null");
            var savedLookup = await Db.LookupCode.Include(lc => lc.SortOrder.Where(so =>
                                                                                   so.LookupCodeId == lookupCode.Id &&
                                                                                   so.LocationId == lookupCode.SortOrderForLocation.LocationId))
                              .FirstOrDefaultAsync(lc => lc.Id == lookupCode.Id);

            savedLookup.ThrowBusinessExceptionIfNull($"Couldn't find lookup code with id: {lookupCode.Id}");

            if ((savedLookup.Code != lookupCode.Code ||
                 savedLookup.LocationId != lookupCode.LocationId)
                &&
                Db.LookupCode.AsNoTracking()
                .Any(lc => lc.Code == lookupCode.Code && lc.LocationId == lookupCode.LocationId))
            {
                throw new BusinessLayerException($"Attempted to create a duplicate entry.");
            }

            savedLookup.Location = await Db.Location.FindAsync(lookupCode.LocationId);

            Db.Entry(savedLookup).CurrentValues.SetValues(lookupCode);
            Db.Entry(savedLookup).Property(x => x.ExpiryDate).IsModified = false;

            var sortOrder = savedLookup.SortOrder.FirstOrDefault();

            if (sortOrder != null)
            {
                sortOrder.SortOrder = lookupCode.SortOrderForLocation.SortOrder;
                await Db.SaveChangesAsync();
            }
            else
            {
                var lookupSortOrder = new LookupSortOrder
                {
                    LookupCodeId = savedLookup.Id,
                    LocationId   = lookupCode.SortOrderForLocation.LocationId,
                    SortOrder    = lookupCode.SortOrderForLocation.SortOrder
                };
                await Db.LookupSortOrder.AddAsync(lookupSortOrder);

                await Db.SaveChangesAsync();

                lookupCode.SortOrderForLocation = lookupSortOrder;
            }
            return(lookupCode);
        }
Esempio n. 17
0
        public string BindingKonsolidasi()
        {
            GridRequestParameters param = GridRequestParameters.Current;

            List <Context.LookupCode> items = RepoLookup.FindAll(param.Skip, 200, (param.Sortings != null ? param.Sortings.ToList() : null), param.Filters).Where(d => d.LookupCodeCategories.Category == "tms_customer_konsolidasi").ToList();

            List <LookupCode> ListModel = new List <LookupCode>();

            foreach (Context.LookupCode item in items)
            {
                LookupCode lc = new LookupCode(item);
                ListModel.Add(lc);
            }

            int total = RepoLookup.Count(param.Filters);

            return(new JavaScriptSerializer().Serialize(new { total = total, data = ListModel }));
        }
Esempio n. 18
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void OnLookupGridRowUpdaing(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = LookupCodeGrid.Rows[e.RowIndex];
            List <ICaisisInputControl> cicList = PageUtil.GetCaisisInputControlsInContainer(row);
            LookupCode biz    = new LookupCode();
            object     priKey = LookupCodeGrid.DataKeys[e.RowIndex].Value;

            // Insert/No Key Present
            if (!priKey.ToString().Equals(string.Empty))
            {
                int lkpCodeId = (int)priKey;
                biz.Get(lkpCodeId);
            }
            if (Request.Form["lkpName"] != null)
            {
                biz[LookupCode.LkpFieldName] = Request.Form["lkpName"];
            }
            else if (!string.IsNullOrEmpty(lkpFieldName.Value))
            {
                biz[LookupCode.LkpFieldName] = lkpFieldName.Value;
            }
            else if (!string.IsNullOrEmpty(fieldName.SelectedValue))
            {
                biz[LookupCode.LkpFieldName] = fieldName.SelectedValue;
            }
            else
            {
                return;
            }
            // Manually Extract values to fix issues with LkpSupress
            foreach (ICaisisInputControl cic in cicList)
            {
                if (cic is CaisisCheckBox)
                {
                    CaisisCheckBox cb = cic as CaisisCheckBox;
                    biz[cic.Field] = cb.Checked;
                }
                else
                {
                    biz[cic.Field] = cic.Value;
                }
            }
            biz.Save();
        }
Esempio n. 19
0
        protected void AddLkpCode(object sender, EventArgs e)
        {
            bool isValid = ValidateLkpFieldName(LkpFieldName.Text);

            if (isValid)
            {
                LookupCode lkpCode = new LookupCode();
                lkpCode[LookupCode.LkpFieldName] = LkpFieldName.Text;
                lkpCode[LookupCode.LkpSuppress]  = 0;
                lkpCode[LookupCode.LkpCode]      = "[enter]";
                lkpCode.Save();

                string lkpFieldName = PageUtil.EscapeSingleQuotes(LkpFieldName.Text);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Reload", "closeAndReloadLkpCode('" + lkpFieldName + "')", true);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "WarnDuplicateField", "alert('The " + LookupCode.LkpFieldName + " already exists, please enter a new value.')", true);
            }
        }
Esempio n. 20
0
        protected void UpdateButtonClick(object sender, CommandEventArgs e)
        {
            LookupCode biz = new LookupCode();

            //biz.NewRow(); // erroneous call

            biz["LookupCodeId"]   = lkpCodeId.Value;
            biz["LkpFieldName"]   = lkpFieldName.Value;
            biz["LkpCode"]        = lkpValue.Value;
            biz["LkpDescription"] = lkpDescription.Value;
            biz["LkpOrder"]       = PageUtil.ObjToInt(lkpOrder.Value);
            biz["LkpSuppress"]    = lkpSuppress.Checked;
            biz["UpdatedBy"]      = User.Identity.Name;
            biz["UpdatedTime"]    = DateTime.Now;
            biz["EnteredBy"]      = User.Identity.Name; // these are required
            biz["EnteredTime"]    = DateTime.Now;       //

            biz.Save();

            this.Page_Load(sender, e);
        }
Esempio n. 21
0
 public void save(LookupCode dbitem)
 {
     if (dbitem.Id == 0) //create
     {
         context.LookupCode.Add(dbitem);
         var auditrail = new Auditrail {
             Actionnya = "Add", EventDate = DateTime.Now, Modulenya = "Lookup Code", QueryDetail = "Add " + dbitem.Deskripsi, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
         };
         context.Auditrail.Add(auditrail);
     }
     else //edit
     {
         context.LookupCode.Attach(dbitem);
         var auditrail = new Auditrail {
             Actionnya = "Edit", EventDate = DateTime.Now, Modulenya = "Lookup Code", QueryDetail = "Edit " + dbitem.Deskripsi, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
         };
         context.Auditrail.Add(auditrail);
         var entry = context.Entry(dbitem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Esempio n. 22
0
        /// <summary>
        /// Update lookup code record
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void HandleLookupUpdate(object sender, GridViewUpdateEventArgs e)
        {
            GridView    lkpCodeGrid = sender as GridView;
            GridViewRow updateRow   = lkpCodeGrid.Rows[e.RowIndex];

            // Fill dictionary from row controls
            CaisisGridView.ExtractCaisisInputValuesFromContainer(updateRow, e.NewValues);

            // Create a new biz for updating/inserting
            LookupCode biz = new LookupCode();
            // Determine if a lookupcodeid exists
            object lkpCodeIdKey = lkpCodeGrid.DataKeys[e.RowIndex][LookupCode.LookupCodeId];

            if (lkpCodeIdKey != null && !string.IsNullOrEmpty(lkpCodeIdKey.ToString()))
            {
                int lkpCodeId = int.Parse(lkpCodeIdKey.ToString());
                biz.Get(lkpCodeId);
            }
            else
            {
                return;
            }
            // Set the lkpcode extracted from textbox
            foreach (string col in e.NewValues.Keys)
            {
                //if (biz.HasColumn(col))
                if (biz.HasField(col))
                {
                    biz[col] = e.NewValues[col];
                }
            }

            biz.Save();

            // Notify the built-in update event to cancel/i.e., not bubble
            e.Cancel = true;
        }
Esempio n. 23
0
        public async Task SheriffOverrideConflictRemove()
        {
            var sheriffObject = await CreateSheriffUsingDbContext();

            var newLocation = new Location {
                Name = "New PLace", AgencyId = "zfddf2342"
            };
            await Db.Location.AddAsync(newLocation);

            await Db.SaveChangesAsync();

            var startDate = DateTimeOffset.UtcNow.Date.AddHours(1);
            var endDate   = startDate.AddHours(8);

            var shift = new Shift
            {
                Id         = 9000665,
                StartDate  = startDate,
                EndDate    = endDate,
                LocationId = newLocation.Id,
                Timezone   = "America/Vancouver",
                SheriffId  = sheriffObject.Id
            };

            Db.Shift.Add(shift);

            var duty = new Duty
            {
                LocationId = newLocation.Id,
            };

            Db.Duty.Add(duty);

            await Db.SaveChangesAsync();

            var dutySlot = new DutySlot
            {
                SheriffId  = sheriffObject.Id,
                LocationId = newLocation.Id,
                StartDate  = startDate,
                EndDate    = endDate,
                DutyId     = duty.Id
            };

            Db.DutySlot.Add(dutySlot);

            var lookupCode = new LookupCode
            {
                Code        = "zz4",
                Description = "gg",
                LocationId  = newLocation.Id
            };
            await Db.LookupCode.AddAsync(lookupCode);

            await Db.SaveChangesAsync();

            var entity = new SheriffLeaveDto
            {
                LeaveTypeId = lookupCode.Id,
                SheriffId   = sheriffObject.Id,
                StartDate   = startDate,
                EndDate     = endDate
            };

            Assert.True(Db.Shift.Any(s => s.ExpiryDate == null && s.Id == shift.Id));
            Assert.True(Db.DutySlot.Any(ds => ds.ExpiryDate == null && ds.Id == dutySlot.Id));

            await _controller.AddSheriffLeave(entity, true);

            Assert.False(Db.Shift.Any(s => s.ExpiryDate == null && s.Id == shift.Id));
            Assert.False(Db.DutySlot.Any(ds => ds.ExpiryDate == null && ds.Id == dutySlot.Id));
        }
Esempio n. 24
0
        public async Task AddUpdateRemoveSheriffTraining()
        {
            var sheriffObject = await CreateSheriffUsingDbContext();

            var newLocation = new Location {
                Name = "New PLace", AgencyId = "zfddf2342"
            };
            await Db.Location.AddAsync(newLocation);

            await Db.SaveChangesAsync();

            var lookupCode = new LookupCode
            {
                Code        = "zz4",
                Description = "gg",
                LocationId  = newLocation.Id
            };
            await Db.LookupCode.AddAsync(lookupCode);

            var lookupCode2 = new LookupCode
            {
                Code        = "zz",
                Description = "gg",
                LocationId  = newLocation.Id
            };

            await Db.LookupCode.AddAsync(lookupCode2);

            await Db.SaveChangesAsync();


            var entity = new SheriffTrainingDto
            {
                TrainingTypeId = lookupCode.Id,
                SheriffId      = sheriffObject.Id,
                StartDate      = DateTime.UtcNow,
                EndDate        = DateTime.UtcNow.AddHours(3)
            };

            //Add
            var controllerResult = await _controller.AddSheriffTraining(entity);

            var response = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult);

            Detach();

            var updateSheriffTraining = entity.Adapt <SheriffTrainingDto>();

            updateSheriffTraining.StartDate      = DateTime.UtcNow.AddDays(5);
            updateSheriffTraining.EndDate        = DateTime.UtcNow.AddDays(5);
            updateSheriffTraining.TrainingTypeId = lookupCode2.Id;
            updateSheriffTraining.TrainingType   = lookupCode2.Adapt <LookupCodeDto>();
            updateSheriffTraining.Id             = response.Id;

            //Update
            var controllerResult3 = await _controller.UpdateSheriffTraining(updateSheriffTraining);

            var response3 = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult3);

            Assert.Equal(response3.StartDate, updateSheriffTraining.StartDate);
            Assert.Equal(response3.EndDate, updateSheriffTraining.EndDate);
            Assert.Equal(response3.SheriffId, updateSheriffTraining.SheriffId);
            Assert.Equal(response3.TrainingTypeId, updateSheriffTraining.TrainingTypeId);

            //Remove
            var controllerResult4 = await _controller.RemoveSheriffTraining(updateSheriffTraining.Id, "expired");

            HttpResponseTest.CheckForNoContentResponse(controllerResult4);

            var controllerResult5 = await _controller.GetSheriffForTeam(sheriffObject.Id);

            var response5 = HttpResponseTest.CheckForValid200HttpResponseAndReturnValue(controllerResult5);

            Assert.Empty(response5.Training);
        }
Esempio n. 25
0
        /// <summary>
        /// Deletes the specified lookup code.
        /// </summary>
        /// <param name="lkpCodeId"></param>
        private void Delete(int lkpCodeId)
        {
            LookupCode lkpCode = new LookupCode();

            lkpCode.Delete(lkpCodeId);
        }
Esempio n. 26
0
        public ActionResult Add()
        {
            LookupCode model = new LookupCode();

            return(View("Form", model));
        }
Esempio n. 27
0
        public string GetKategori(LookupCode model)
        {
            model.listKategori = RepoKategori.FindAll().ToList();

            return(new JavaScriptSerializer().Serialize(model.listKategori));
        }
Esempio n. 28
0
        /// <summary>
        /// Save's all "dirty" rows as well as update/delete association to current disease
        /// </summary>
        private void Save()
        {
            // validation
            List <string> existingCodes  = new List <string>();
            List <string> duplicateCodes = new List <string>();

            // check each row, need to check for associate with disease
            foreach (GridViewRow row in LookupCodeGrid.Rows)
            {
                int?   lkpCodeId    = null;
                object rowLkpCodeId = LookupCodeGrid.DataKeys[row.RowIndex][LookupCode.LookupCodeId];
                if (!string.IsNullOrEmpty(rowLkpCodeId.ToString()))
                {
                    lkpCodeId = (int)rowLkpCodeId;
                }
                bool isDirtyRow = LookupCodeGrid.DirtyGridRows.Contains(row);
                ICaisisInputControl lkpCodeField = row.FindControl("LkpCode") as ICaisisInputControl;
                // validate empty values, duplicates, etc...
                if (!string.IsNullOrEmpty(lkpCodeField.Value))
                {
                    if (!lkpCodeId.HasValue && existingCodes.Contains(lkpCodeField.Value, StringComparer.OrdinalIgnoreCase))
                    {
                        // mark as duplicate and prevent insert
                        duplicateCodes.Add(lkpCodeField.Value);
                        isDirtyRow = false;
                        lkpCodeId  = null;
                    }
                    // track running list
                    else
                    {
                        existingCodes.Add(lkpCodeField.Value);
                    }
                }
                else
                {
                    isDirtyRow = false;
                    lkpCodeId  = null;
                }

                // if dirty, update/insert
                if (isDirtyRow)
                {
                    // update/insert
                    LookupCode lkpCode = new LookupCode();
                    if (lkpCodeId.HasValue)
                    {
                        lkpCode.Get(lkpCodeId.Value);
                    }
                    else
                    {
                        lkpCode[LookupCode.LkpFieldName] = CurrentLkpFieldName.Value;
                    }
                    CICHelper.SetBOValues(row.Controls, lkpCode, -1);
                    lkpCode.Save();
                    // update pri key
                    lkpCodeId = (int)lkpCode[LookupCode.LookupCodeId];
                }
                // continue if valid
                if (lkpCodeId.HasValue)
                {
                    // APPLY TO DISEASE
                    CheckBox    diseaseAttribute   = row.FindControl("DiseaseAttribute") as CheckBox;
                    HiddenField diseaseAttributeId = row.FindControl("DiseaseAttributeId") as HiddenField;
                    if (diseaseAttribute.Checked)
                    {
                        // only insert if key not set, as already assigned
                        if (string.IsNullOrEmpty(diseaseAttributeId.Value))
                        {
                            LookupCodeAttribute lkpCodeAttribute = new LookupCodeAttribute();
                            // set required
                            lkpCodeAttribute[LookupCodeAttribute.LookupCodeId]      = lkpCodeId;
                            lkpCodeAttribute[LookupCodeAttribute.AttributeId]       = _lkpDiseaseAttributeId;
                            lkpCodeAttribute[LookupCodeAttribute.AttributeValue]    = _diseaseName;
                            lkpCodeAttribute[LookupCodeAttribute.AttributeSuppress] = 0;
                            lkpCodeAttribute.Save();
                            // update hidden field
                            diseaseAttributeId.Value = lkpCodeAttribute[LookupCodeAttribute.LookupCodeAttributeId].ToString();
                        }
                    }
                    // if unchecking and pri key set, delete
                    else
                    {
                        if (!string.IsNullOrEmpty(diseaseAttributeId.Value))
                        {
                            int lkpCodeAttributeId = int.Parse(diseaseAttributeId.Value);
                            LookupCodeAttribute lkpCodeAttribute = new LookupCodeAttribute();
                            lkpCodeAttribute.Delete(lkpCodeAttributeId);
                            // udpate hidden field
                            diseaseAttributeId.Value = string.Empty;
                        }
                    }
                    // APPLY FILTERS: only when NOT in disease mode
                    if (!QueryDiseaseId.HasValue)
                    {
                        // APPLY TO ATTRIBUTE
                        CheckBox    applyToAttribute   = row.FindControl("ApplyToAttribute") as CheckBox;
                        HiddenField applyToAttributeId = row.FindControl("ApplyToAttributeId") as HiddenField;
                        if (applyToAttribute.Checked)
                        {
                            // no udpates, just inserts
                            if (string.IsNullOrEmpty(applyToAttributeId.Value))
                            {
                                LookupCodeAttribute lkpCodeAttribute = new LookupCodeAttribute();
                                lkpCodeAttribute[LookupCodeAttribute.LookupCodeId]      = lkpCodeId.Value;
                                lkpCodeAttribute[LookupCodeAttribute.AttributeId]       = int.Parse(FilterByAttributeNames.Value);
                                lkpCodeAttribute[LookupCodeAttribute.AttributeValue]    = FilterByAttributeValues.Value;
                                lkpCodeAttribute[LookupCodeAttribute.AttributeSuppress] = 0;
                                lkpCodeAttribute.Save();
                                applyToAttributeId.Value = lkpCodeAttribute[lkpCodeAttribute.PrimaryKeyName].ToString();
                            }
                        }
                        // if unchecking, delete only if key exists
                        else if (!string.IsNullOrEmpty(applyToAttributeId.Value))
                        {
                            LookupCodeAttribute lkpCodeAttribute = new LookupCodeAttribute();
                            lkpCodeAttribute.Delete(int.Parse(applyToAttributeId.Value));
                            applyToAttributeId.Value = string.Empty;
                        }

                        // APPLY TO PARENT
                        CheckBox    applyToParent   = row.FindControl("ApplyToParent") as CheckBox;
                        HiddenField applyToParentId = row.FindControl("ApplyToParentId") as HiddenField;
                        if (applyToParent.Checked)
                        {
                            // no udpates, just inserts
                            if (string.IsNullOrEmpty(applyToParentId.Value))
                            {
                                LookupParentChildCode parentChildCode = new LookupParentChildCode();
                                parentChildCode[LookupParentChildCode.ParentCodeId] = int.Parse(FilterByParentLkpCodes.Value);
                                parentChildCode[LookupParentChildCode.ChildCodeId]  = lkpCodeId.Value;
                                parentChildCode.Save();
                                applyToParentId.Value = parentChildCode[parentChildCode.PrimaryKeyName].ToString();
                            }
                        }
                        // if unchecking, delete only if key exists
                        else if (!string.IsNullOrEmpty(applyToParentId.Value))
                        {
                            LookupParentChildCode parentChildCode = new LookupParentChildCode();
                            parentChildCode.Delete(int.Parse(applyToParentId.Value));
                            applyToParentId.Value = string.Empty;
                        }
                    }
                }
            }
            // Save new CSV values
            var bulkLkpCodesRows = (from rowCodes in BulkLkpCodes.Text.Split(System.Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                                    let lkpCode = from code in rowCodes.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                                                  select code.Trim()
                                                  select lkpCode).SelectMany(s => s);

            foreach (string code in bulkLkpCodesRows)
            {
                LookupCode lkpCode = new LookupCode();
                // set required fields
                lkpCode[LookupCode.LkpFieldName] = CurrentLkpFieldName.Value;
                lkpCode[LookupCode.LkpSuppress]  = 0;
                // set code
                lkpCode[LookupCode.LkpCode] = code;
                // insert
                lkpCode.Save();
            }
            // reset bulk codes
            BulkLkpCodes.Text = string.Empty;

            // refresh cache for item
            CacheManager.ResetLookupCodeCache();

            // register warning for missing codes
            if (duplicateCodes.Count() > 0)
            {
                // create safe js array
                string[] duplicateCodesArray = duplicateCodes.Select(c => PageUtil.EscapeSingleQuotes(c)).ToArray();
                string   clientArray         = "['" + string.Join("', '", duplicateCodesArray) + "']";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "duplicateCodesMessage", "warnDuplicateCodes(" + clientArray + ");", true);
            }
        }