public override void Save() { try { int orderNo = 1; foreach (RadListDataItem item in lstZones.Items) { // objMaster = new ZoneBO(); objMaster.GetByPrimaryKey(item.Value); if (objMaster.Current != null) { objMaster.CheckDataValidation = false; objMaster.Current.OrderNo = orderNo++; objMaster.Save(); } } General.LoadZoneList(); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }
void Grid_RowsChanging(object sender, GridViewCollectionChangingEventArgs e) { if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.Remove) { objMaster = new ZoneBO(); try { objMaster.GetByPrimaryKey(grdLister.CurrentRow.Cells["Id"].Value.ToInt()); if (objMaster.Current != null) { int id = objMaster.Current.Id; string zoneName = objMaster.Current.ZoneName; objMaster.Delete(objMaster.Current); //using (PDADataContext db = new PDADataContext()) //{ // Zone objZone = db.Zones.FirstOrDefault(c => c.ZoneName == zoneName && c.ClientId==AppVars.objPolicyConfiguration.DefaultClientId); // if (objZone != null) // { // db.Zones.DeleteOnSubmit(objZone); // db.SubmitChanges(); // } //} } } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } e.Cancel = true; } } }
private void UpdateZones() { ZoneBO objMaster = null; try { objMaster = new ZoneBO(); for (int i = 0; i < grdZones.RowCount; i++) { int Id = grdZones.Rows[i].Cells[COL_ZONE.Id].Value.ToInt(); objMaster.GetByPrimaryKey(Id); objMaster.Edit(); objMaster.Current.BlockPickup = grdZones.Rows[i].Cells[COL_ZONE.BlockPickup].Value.ToBool(); objMaster.Current.BlockDropOff = grdZones.Rows[i].Cells[COL_ZONE.BlockDropOff].Value.ToBool(); objMaster.Current.IsOutsideArea = grdZones.Rows[i].Cells[COL_ZONE.IsLocalArea].Value.ToBool(); objMaster.Save(); objMaster.Clear(); } this.Close(); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } } }
private void SaveData() { try { //if(AppVars.objPolicyConfiguration.EnableAutoDespatch.ToBool()) //{ // int nearestAutoDespatchRadius=AppVars.objPolicyConfiguration.AutoDespatchElapsedTime.ToInt(); // if (grdZones.Rows.Where(c => c.Cells["IsUpdated"].Value.ToStr() == "1" && c.Cells["Radius"].Value.ToInt()>0) // .Any(c => c.Cells["Radius"].Value.ToInt() < nearestAutoDespatchRadius)) // { // ENUtils.ShowMessage("Bidding Radius must be greater than AutoDespatch Nearest Distance"); // return; // } //} DateTime?dt = null; foreach (var item in grdZones.Rows.Where(c => c.Cells["IsUpdated"].Value.ToStr() == "1")) { objMaster.GetByPrimaryKey(item.Cells["Id"].Value.ToInt()); if (objMaster.Current != null) { dt = item.Cells["FlashingHour"].Value.ToDateTimeorNull(); if (dt != null && (dt.Value.Minute == 0 && dt.Value.Hour == 0)) { dt = null; } objMaster.Current.FlashingHour = dt; dt = item.Cells["JobDue"].Value.ToDateTimeorNull(); if (dt != null && (dt.Value.Minute == 0 && dt.Value.Hour == 0)) { dt = null; } objMaster.Current.JobDueTime = dt; objMaster.Current.EnableAutoDespatch = item.Cells["AutoDespatch"].Value.ToBool(); objMaster.Current.EnableBidding = item.Cells["Bidding"].Value.ToBool(); objMaster.Current.BiddingRadius = item.Cells["Radius"].Value.ToInt(); if (item.Cells["BackupPlot1"].Value.ToIntorNull() != null && item.Cells["BackupPlot2"].Value.ToIntorNull() != null) { if (objMaster.Current.Gen_Zone_Backups == null) { objMaster.Current.Gen_Zone_Backups = new Gen_Zone_Backup(); } objMaster.Current.Gen_Zone_Backups.BackupZone1Id = item.Cells["BackupPlot1"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone2Id = item.Cells["BackupPlot2"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone3Id = item.Cells["BackupPlot3"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone4Id = item.Cells["BackupPlot4"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone5Id = item.Cells["BackupPlot5"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone6Id = item.Cells["BackupPlot6"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone7Id = item.Cells["BackupPlot7"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone8Id = item.Cells["BackupPlot8"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone9Id = item.Cells["BackupPlot9"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone10Id = item.Cells["BackupPlot10"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone11Id = item.Cells["BackupPlot11"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone12Id = item.Cells["BackupPlot12"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone13Id = item.Cells["BackupPlot13"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone14Id = item.Cells["BackupPlot14"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone15Id = item.Cells["BackupPlot15"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone16Id = item.Cells["BackupPlot16"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone17Id = item.Cells["BackupPlot17"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone18Id = item.Cells["BackupPlot18"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone19Id = item.Cells["BackupPlot19"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone20Id = item.Cells["BackupPlot20"].Value.ToIntorNull(); if (item.Cells["BackupPlot1"].Tag == null && item.Cells["BackupPlot2"].Tag == null) { objMaster.Current.Gen_Zone_Backups.BackupZone1Priority = true; } else if (item.Cells["BackupPlot2"].Tag == null) { objMaster.Current.Gen_Zone_Backups.BackupZone1Priority = true; } else { objMaster.Current.Gen_Zone_Backups.BackupZone1Priority = item.Cells["BackupPlot1"].Tag.ToBool(); } } else { if (item.Cells["BackupPlot1"].Value.ToIntorNull() == null) { if (objMaster.Current.Gen_Zone_Backups == null) { objMaster.Current.Gen_Zone_Backups = new Gen_Zone_Backup(); } objMaster.Current.Gen_Zone_Backups.BackupZone1Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone2Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone3Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone4Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone5Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone6Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone7Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone8Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone9Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone10Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone11Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone12Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone13Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone14Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone15Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone16Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone17Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone18Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone19Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone20Id = null; } else { if (objMaster.Current.Gen_Zone_Backups == null) { objMaster.Current.Gen_Zone_Backups = new Gen_Zone_Backup(); } objMaster.Current.Gen_Zone_Backups.BackupZone1Id = item.Cells["BackupPlot1"].Value.ToIntorNull(); objMaster.Current.Gen_Zone_Backups.BackupZone1Priority = true; } if (item.Cells["BackupPlot2"].Value.ToIntorNull() == null) { if (objMaster.Current.Gen_Zone_Backups == null) { objMaster.Current.Gen_Zone_Backups = new Gen_Zone_Backup(); } objMaster.Current.Gen_Zone_Backups.BackupZone2Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone3Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone4Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone5Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone6Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone7Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone8Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone9Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone10Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone11Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone12Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone13Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone14Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone15Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone16Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone17Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone18Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone19Id = null; objMaster.Current.Gen_Zone_Backups.BackupZone20Id = null; } //if (item.Cells["BackupPlot1"].Value.ToIntorNull() != null && item.Cells["BackupPlot2"].Value.ToIntorNull() == null) //{ // objMaster.Current.Gen_Zone_Backups.BackupZone2Id = null; //} } // 9 dec 14 objMaster.Current.PlotEntranceMessage = item.Cells["PlotMessage"].Value.ToStr().Trim(); objMaster.Current.PlotLimit = item.Cells["Limit"].Value.ToInt(); objMaster.Current.PlotLimitExceedMessage = item.Cells["OverLimitMessage"].Value.ToStr(); objMaster.Current.BlockDropOff = item.Cells["outoftown"].Value.ToBool(); // objMaster.CheckDataValidation = false; objMaster.Save(); } } CloseForm(); } catch (Exception ex) { ENUtils.ShowMessage(ex.Message); } }