private void ServiceUserFrm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != System.Windows.Forms.DialogResult.OK) { return; } if (firstnametxt.Text.Trim().Length == 0) { firstnameerrorpic.Visible = true; e.Cancel = true; } if (surnametxt.Text.Trim().Length == 0) { surnameerrorpic.Visible = true; e.Cancel = true; } if (_id == 0 && !PNumberAvailable) { pnumbererrorpic.Visible = true; pnumbererrodlbl.Text = "( Already Exists )"; pnumbererrodlbl.Visible = true; e.Cancel = true; } else if (pNumberTxt.Text.Trim().Length == 0) { pnumbererrorpic.Visible = true; pnumbererrodlbl.Text = "( Invalid PNumber )"; pnumbererrodlbl.Visible = true; e.Cancel = true; } //change this to use call history stuff instead //if (_id != 0) //{ // DateTime serviceStart = PeriodStartDate; // DateTime serviceEnd = serviceStart.AddDays(PeriodWeekCount * 7); // if (CallManager.Instance.Calls.Where(c => c.ServiceUser.id == _id && !c.HasFullWorkers && // !(c.TimeTo > serviceStart && c.TimeFrom < serviceEnd)).Count() > 0) // { // MessageBox.Show("There are still unassigned calls outside this service period.", "Unassigned Calls", MessageBoxButtons.OK); // e.Cancel = true; // } //} //all good, update the location stuff try { if (PostCode == "") { _longLat.Empty(); } else if (PostCode != _longLat.pCode) { //if the postcode has changed GoogleMapLocation location; location = new GoogleMapLocation(new GoogleMapAddress(PostCode, "UK")); _longLat = location.LongLat; } } catch (Exception ex) { //ignore } }
private void WorkerFrm_FormClosing(object sender, FormClosingEventArgs e) { if (DialogResult != System.Windows.Forms.DialogResult.OK) { return; } if (firstnametxt.Text.Trim().Length == 0) { firstnameerrorpic.Visible = true; e.Cancel = true; } if (surnametxt.Text.Trim().Length == 0) { surnameerrorpic.Visible = true; e.Cancel = true; } if (_id == 0 && !ENumberAvailable) { pnumbererrorpic.Visible = true; pnumbererrodlbl.Text = "( Already Exists )"; pnumbererrodlbl.Visible = true; e.Cancel = true; } else if (eNumberTxt.Text.Trim().Length == 0) { pnumbererrorpic.Visible = true; pnumbererrodlbl.Text = "( Invalid PNumber )"; pnumbererrodlbl.Visible = true; e.Cancel = true; } //all good, update the location stuff try { if (PostCode == "") { _longLat.Empty(); } else if (PostCode != _longLat.pCode) { //if the postcode has changed _longLat.Empty(); _longLat.pCode = PostCode; //get the google long lat locations (this will insert into pcodes.db) GoogleMapLocation location; location = new GoogleMapLocation(new GoogleMapAddress(PostCode, "UK")); _longLat = location.LongLat; } } catch (Exception ex) { //ignore } }