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); } } }
private void CreateSINBINZone() { try { if (General.GetQueryable <Gen_Zone>(c => c.ZoneName == "SIN BIN").Count() == 0) { ZoneBO objZone = new ZoneBO(); objZone.New(); objZone.Current.ZoneName = "SIN BIN"; objZone.Current.ShortName = "SIN BIN"; objZone.Current.AddOn = DateTime.Now; objZone.Current.AddBy = AppVars.LoginObj.LuserId.ToInt(); objZone.Current.OrderNo = 1000; objZone.Current.ZoneTypeId = 1; objZone.Current.PlotKind = 1; objZone.CheckDataValidation = false; objZone.Save(); } } catch { } }
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); } } }
public override void Save() { try { if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } else { objMaster.Edit(); } objMaster.Current.ZoneName = txtZoneName.Text.Trim(); objMaster.Current.PostCode = string.Join(",", grdPostCodes.Rows.Select(c => c.Cells[COLS.PostCode].Value.ToStr()).ToArray <string>()); objMaster.Current.IsBase = chkBase.Checked; objMaster.Current.ShortName = txtShortName.Text.Trim(); objMaster.Current.ZoneTypeId = ddlType.SelectedValue.ToIntorNull(); objMaster.Current.PlotKind = ddlKind.SelectedValue.ToIntorNull(); string[] skipProperties = new string[] { "Gen_Zones" }; int orderNo = 1; IList <Gen_Zone_AssociatedPostCode> savedList = objMaster.Current.Gen_Zone_AssociatedPostCodes; List <Gen_Zone_AssociatedPostCode> listofDetail = (from r in grdPostCodes.Rows //where r.Cells[COL_DOCUMENT.FILENAME].Value.ToStr()!=string.Empty select new Gen_Zone_AssociatedPostCode { Id = r.Cells[COLS.Id].Value.ToInt(), ZoneId = r.Cells[COLS.MasterId].Value.ToInt(), AreaName = objMaster.Current.ZoneName, PostCode = r.Cells[COLS.PostCode].Value.ToStr().Trim(), OrderNo = orderNo++ }).ToList(); Utils.General.SyncChildCollection(ref savedList, ref listofDetail, "Id", skipProperties); objMaster.Save(); General.LoadZoneList(); // PDAClass.SaveZone(objMaster.Current); } 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); } }