diff --git a/sources/CandidatesBrowser/CandidatesBrowser.csproj b/sources/CandidatesBrowser/CandidatesBrowser.csproj
index ffc684b..ed2c688 100644
--- a/sources/CandidatesBrowser/CandidatesBrowser.csproj
+++ b/sources/CandidatesBrowser/CandidatesBrowser.csproj
@@ -82,6 +82,7 @@
True
Resources.resx
+ True
diff --git a/sources/CandidatesBrowser/Forms/CandidateForm.Designer.cs b/sources/CandidatesBrowser/Forms/CandidateForm.Designer.cs
index a4176ca..99b8cde 100644
--- a/sources/CandidatesBrowser/Forms/CandidateForm.Designer.cs
+++ b/sources/CandidatesBrowser/Forms/CandidateForm.Designer.cs
@@ -36,7 +36,7 @@ private void InitializeComponent()
this.contactInformationLabel = new DevExpress.XtraEditors.LabelControl();
this.generalInforLabel = new DevExpress.XtraEditors.LabelControl();
this.cancelButton = new DevExpress.XtraEditors.SimpleButton();
- this.saveButton = new DevExpress.XtraEditors.SimpleButton();
+ this.saveAndCloseButton = new DevExpress.XtraEditors.SimpleButton();
this.socialNetworksLabel = new DevExpress.XtraEditors.LabelControl();
this.phonesLabel = new DevExpress.XtraEditors.LabelControl();
this.commentsLabel = new DevExpress.XtraEditors.LabelControl();
@@ -90,7 +90,7 @@ private void InitializeComponent()
this.genderLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem();
this.spaceBetweenEnglishAndGender = new DevExpress.XtraLayout.EmptySpaceItem();
this.englishLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem();
- this.saveButtonLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem();
+ this.saveAndCloseButtonLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem();
this.cancelButtonLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem();
this.spaceAtFormBottom = new DevExpress.XtraLayout.EmptySpaceItem();
this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem();
@@ -143,7 +143,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.genderLayoutControlItem)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spaceBetweenEnglishAndGender)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.englishLayoutControlItem)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.saveButtonLayoutControlItem)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.saveAndCloseButtonLayoutControlItem)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.cancelButtonLayoutControlItem)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.spaceAtFormBottom)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit();
@@ -156,7 +156,7 @@ private void InitializeComponent()
this.rootLayout.Controls.Add(this.contactInformationLabel);
this.rootLayout.Controls.Add(this.generalInforLabel);
this.rootLayout.Controls.Add(this.cancelButton);
- this.rootLayout.Controls.Add(this.saveButton);
+ this.rootLayout.Controls.Add(this.saveAndCloseButton);
this.rootLayout.Controls.Add(this.socialNetworksLabel);
this.rootLayout.Controls.Add(this.phonesLabel);
this.rootLayout.Controls.Add(this.commentsLabel);
@@ -241,23 +241,23 @@ private void InitializeComponent()
//
// cancelButton
//
- this.cancelButton.Location = new System.Drawing.Point(739, 457);
+ this.cancelButton.Location = new System.Drawing.Point(718, 457);
this.cancelButton.Name = "cancelButton";
- this.cancelButton.Size = new System.Drawing.Size(65, 22);
+ this.cancelButton.Size = new System.Drawing.Size(86, 22);
this.cancelButton.StyleController = this.rootLayout;
this.cancelButton.TabIndex = 21;
this.cancelButton.Text = "Cancel";
this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
//
- // saveButton
+ // saveAndCloseButton
//
- this.saveButton.Location = new System.Drawing.Point(670, 457);
- this.saveButton.Name = "saveButton";
- this.saveButton.Size = new System.Drawing.Size(65, 22);
- this.saveButton.StyleController = this.rootLayout;
- this.saveButton.TabIndex = 20;
- this.saveButton.Text = "Save";
- this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
+ this.saveAndCloseButton.Location = new System.Drawing.Point(628, 457);
+ this.saveAndCloseButton.Name = "saveAndCloseButton";
+ this.saveAndCloseButton.Size = new System.Drawing.Size(86, 22);
+ this.saveAndCloseButton.StyleController = this.rootLayout;
+ this.saveAndCloseButton.TabIndex = 20;
+ this.saveAndCloseButton.Text = "Save and Close";
+ this.saveAndCloseButton.Click += new System.EventHandler(this.saveAndCloseButton_Click);
//
// socialNetworksLabel
//
@@ -526,7 +526,7 @@ private void InitializeComponent()
this.commentsLayoutGroup,
this.contactsLayoutGroup,
this.generalInfoLayoutGroup,
- this.saveButtonLayoutControlItem,
+ this.saveAndCloseButtonLayoutControlItem,
this.cancelButtonLayoutControlItem,
this.spaceAtFormBottom,
this.emptySpaceItem1});
@@ -771,21 +771,21 @@ private void InitializeComponent()
this.englishLayoutControlItem.Text = "English level:";
this.englishLayoutControlItem.TextSize = new System.Drawing.Size(63, 13);
//
- // saveButtonLayoutControlItem
+ // saveAndCloseButtonLayoutControlItem
//
- this.saveButtonLayoutControlItem.Control = this.saveButton;
- this.saveButtonLayoutControlItem.Location = new System.Drawing.Point(668, 455);
- this.saveButtonLayoutControlItem.Name = "saveButtonLayoutControlItem";
- this.saveButtonLayoutControlItem.Size = new System.Drawing.Size(69, 26);
- this.saveButtonLayoutControlItem.TextSize = new System.Drawing.Size(0, 0);
- this.saveButtonLayoutControlItem.TextVisible = false;
+ this.saveAndCloseButtonLayoutControlItem.Control = this.saveAndCloseButton;
+ this.saveAndCloseButtonLayoutControlItem.Location = new System.Drawing.Point(626, 455);
+ this.saveAndCloseButtonLayoutControlItem.Name = "saveAndCloseButtonLayoutControlItem";
+ this.saveAndCloseButtonLayoutControlItem.Size = new System.Drawing.Size(90, 26);
+ this.saveAndCloseButtonLayoutControlItem.TextSize = new System.Drawing.Size(0, 0);
+ this.saveAndCloseButtonLayoutControlItem.TextVisible = false;
//
// cancelButtonLayoutControlItem
//
this.cancelButtonLayoutControlItem.Control = this.cancelButton;
- this.cancelButtonLayoutControlItem.Location = new System.Drawing.Point(737, 455);
+ this.cancelButtonLayoutControlItem.Location = new System.Drawing.Point(716, 455);
this.cancelButtonLayoutControlItem.Name = "cancelButtonLayoutControlItem";
- this.cancelButtonLayoutControlItem.Size = new System.Drawing.Size(69, 26);
+ this.cancelButtonLayoutControlItem.Size = new System.Drawing.Size(90, 26);
this.cancelButtonLayoutControlItem.TextSize = new System.Drawing.Size(0, 0);
this.cancelButtonLayoutControlItem.TextVisible = false;
//
@@ -794,7 +794,7 @@ private void InitializeComponent()
this.spaceAtFormBottom.AllowHotTrack = false;
this.spaceAtFormBottom.Location = new System.Drawing.Point(0, 455);
this.spaceAtFormBottom.Name = "spaceAtFormBottom";
- this.spaceAtFormBottom.Size = new System.Drawing.Size(668, 26);
+ this.spaceAtFormBottom.Size = new System.Drawing.Size(626, 26);
this.spaceAtFormBottom.TextSize = new System.Drawing.Size(0, 0);
//
// emptySpaceItem1
@@ -863,7 +863,7 @@ private void InitializeComponent()
((System.ComponentModel.ISupportInitialize)(this.genderLayoutControlItem)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.spaceBetweenEnglishAndGender)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.englishLayoutControlItem)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.saveButtonLayoutControlItem)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.saveAndCloseButtonLayoutControlItem)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.cancelButtonLayoutControlItem)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.spaceAtFormBottom)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit();
@@ -914,9 +914,9 @@ private void InitializeComponent()
private DevExpress.XtraLayout.LayoutControlItem socialNetworksLabelLayoutControlItem;
private DevExpress.XtraEditors.LabelControl generalInforLabel;
private DevExpress.XtraEditors.SimpleButton cancelButton;
- private DevExpress.XtraEditors.SimpleButton saveButton;
+ private DevExpress.XtraEditors.SimpleButton saveAndCloseButton;
private DevExpress.XtraLayout.LayoutControlItem generalInfoLabelLayoutControlItem;
- private DevExpress.XtraLayout.LayoutControlItem saveButtonLayoutControlItem;
+ private DevExpress.XtraLayout.LayoutControlItem saveAndCloseButtonLayoutControlItem;
private DevExpress.XtraLayout.LayoutControlItem cancelButtonLayoutControlItem;
private DevExpress.XtraLayout.EmptySpaceItem spaceAtFormBottom;
private DevExpress.XtraLayout.EmptySpaceItem spaceBetweenEnglishAndGender;
diff --git a/sources/CandidatesBrowser/Forms/CandidateForm.cs b/sources/CandidatesBrowser/Forms/CandidateForm.cs
index c7f14a3..727be55 100644
--- a/sources/CandidatesBrowser/Forms/CandidateForm.cs
+++ b/sources/CandidatesBrowser/Forms/CandidateForm.cs
@@ -8,6 +8,7 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
+using System.Resources;
using HumanResourcesLibrary.DataClasses; // for Candidate
using DevExpress.XtraGrid.Views.Grid;
@@ -20,6 +21,8 @@ public CandidateForm()
InitializeComponent();
englishLevelComboBox.Properties.Items.AddRange(typeof (HumanResourcesLibrary.DataClasses.EnglishLevel).GetEnumValues());
genderComboBox.Properties.Items.AddRange(typeof(HumanResourcesLibrary.DataClasses.Gender).GetEnumValues());
+
+ this.CancelButton = this.cancelButton; // pressing ESC is now equivalent to pressing Cancel
}
// TODO: you are free to change this name if you have a better one.
@@ -53,19 +56,28 @@ private void RenewPhoto()
private Candidate candidate, candidateCopy;
+ // Added to avoid double checking that candidate equals candidateCopy when Save and Close button is pressed.
+ private bool saved = false;
+
private void commentsGridView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
- var newContact = (ContactWithCandidate)((GridView)sender).GetRow(e.RowHandle);
- newContact.Date = DateTime.Now;
- newContact.Type = ContactTypes.Call;
- newContact.Comment = "";
+ if (sender != null)
+ {
+ var newContact = (ContactWithCandidate)((GridView)sender).GetRow(e.RowHandle);
+ newContact.Date = DateTime.Now;
+ newContact.Type = ContactTypes.Call;
+ newContact.Comment = "";
+ }
}
private void RowsDeletion(object sender, KeyEventArgs e)
{
- var gridView = (GridView)sender;
- if (e.KeyCode == Keys.Delete)
- gridView.DeleteSelectedRows();
+ if (sender != null)
+ {
+ var gridView = (GridView)sender;
+ if (e.KeyCode == Keys.Delete)
+ gridView.DeleteSelectedRows();
+ }
}
private void commentsGridView_KeyDown(object sender, KeyEventArgs e)
@@ -75,9 +87,12 @@ private void commentsGridView_KeyDown(object sender, KeyEventArgs e)
private void phonesGridView_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e)
{
- var newPhone = (Phone)((GridView)sender).GetRow(e.RowHandle);
- newPhone.Type = PhoneType.Mobile;
- newPhone.PhoneNumber = "";
+ if (sender != null)
+ {
+ var newPhone = (Phone)((GridView)sender).GetRow(e.RowHandle);
+ newPhone.Type = PhoneType.Mobile;
+ newPhone.PhoneNumber = "";
+ }
}
private void phonesGridView_KeyDown(object sender, KeyEventArgs e)
@@ -87,19 +102,26 @@ private void phonesGridView_KeyDown(object sender, KeyEventArgs e)
private void socialNetworksGridView_InitNewRow(object sender, InitNewRowEventArgs e)
{
- var newSocNetowrk = (SocialNetwork)((GridView)sender).GetRow(e.RowHandle);
- newSocNetowrk.Type = SocialNetworkType.Facebook;
- newSocNetowrk.Link = "";
+ if (sender != null)
+ {
+ var newSocNetowrk = (SocialNetwork)((GridView)sender).GetRow(e.RowHandle);
+ newSocNetowrk.Type = SocialNetworkType.Facebook;
+ newSocNetowrk.Link = "";
+ }
}
private void socialNetworksGridView_KeyDown(object sender, KeyEventArgs e)
{
RowsDeletion(sender, e);
}
-
- private void saveButton_Click(object sender, EventArgs e)
+
+ private void saveAndCloseButton_Click(object sender, EventArgs e)
{
- SaveCandidate();
+ if (!this.candidate.Equals(this.candidateCopy))
+ SaveCandidate();
+ saved = true;
+
+ Close();
}
private void cancelButton_Click(object sender, EventArgs e)
@@ -109,23 +131,33 @@ private void cancelButton_Click(object sender, EventArgs e)
private void CandidateForm_FormClosing(object sender, FormClosingEventArgs e)
{
- if (!this.candidate.Equals(this.candidateCopy))
+ // if Save and Close button was pressed, everything is already up to date and we don't need to check it.
+ if (saved)
{
- var result = MessageBox.Show("Record has been changed but not saved.\nDo you want to save changes?",
- "Warning", MessageBoxButtons.YesNoCancel);
-
- switch (result)
+ saved = false;
+ }
+ else if (!this.candidate.Equals(this.candidateCopy))
+ {
+ using (var resources = new ResXResourceSet("..\\..\\Properties\\Resources.resx"))
{
- case DialogResult.Yes:
- SaveCandidate();
- break;
+ var message = resources.GetString("CandidateFormClosingMessage");
+ var title = resources.GetString("CandidateFormClosingMBoxTitle");
+
+ var result = MessageBox.Show(message, title, MessageBoxButtons.YesNoCancel);
+
+ switch (result)
+ {
+ case DialogResult.Yes:
+ SaveCandidate();
+ break;
- case DialogResult.No:
- break;
+ case DialogResult.No:
+ break;
- case DialogResult.Cancel:
- e.Cancel = true;
- break;
+ case DialogResult.Cancel:
+ e.Cancel = true;
+ break;
+ }
}
}
}
diff --git a/sources/CandidatesBrowser/Forms/CandidatesBrowserMainForm.cs b/sources/CandidatesBrowser/Forms/CandidatesBrowserMainForm.cs
index df7bca0..9523a07 100644
--- a/sources/CandidatesBrowser/Forms/CandidatesBrowserMainForm.cs
+++ b/sources/CandidatesBrowser/Forms/CandidatesBrowserMainForm.cs
@@ -38,14 +38,17 @@ private void addButton_Click(object sender, EventArgs e)
private void editButton_Click(object sender, EventArgs e)
{
- if (mainGridView.SelectedRowsCount == 1)
+ if (mainGridView != null && mainGridView.SelectedRowsCount == 1)
this.mainGridView_DoubleClick(mainGridView, e);
}
private void mainGridView_DoubleClick(object sender, EventArgs e)
{
- candidateForm.FormCandidate = (Candidate)((GridView)sender).GetRow(((GridView)sender).FocusedRowHandle);
- candidateForm.ShowDialog();
+ if (sender != null)
+ {
+ candidateForm.FormCandidate = (Candidate)((GridView)sender).GetRow(((GridView)sender).FocusedRowHandle);
+ candidateForm.ShowDialog();
+ }
}
}
}
diff --git a/sources/CandidatesBrowser/Properties/Resources.Designer.cs b/sources/CandidatesBrowser/Properties/Resources.Designer.cs
index 4b0a56a..71ed2b6 100644
--- a/sources/CandidatesBrowser/Properties/Resources.Designer.cs
+++ b/sources/CandidatesBrowser/Properties/Resources.Designer.cs
@@ -1,17 +1,17 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.18063
+// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
//
//------------------------------------------------------------------------------
-namespace CandidatesBrowser.Properties
-{
-
-
+namespace CandidatesBrowser.Properties {
+ using System;
+
+
///
/// A strongly-typed resource class, for looking up localized strings, etc.
///
@@ -22,50 +22,60 @@ namespace CandidatesBrowser.Properties
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources
- {
-
+ internal class Resources {
+
private static global::System.Resources.ResourceManager resourceMan;
-
+
private static global::System.Globalization.CultureInfo resourceCulture;
-
+
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources()
- {
+ internal Resources() {
}
-
+
///
/// Returns the cached ResourceManager instance used by this class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager
- {
- get
- {
- if ((resourceMan == null))
- {
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("CandidatesBrowser.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
-
+
///
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture
- {
- get
- {
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
return resourceCulture;
}
- set
- {
+ set {
resourceCulture = value;
}
}
+
+ ///
+ /// Looks up a localized string similar to Warning.
+ ///
+ internal static string CandidateFormClosingMBoxTitle {
+ get {
+ return ResourceManager.GetString("CandidateFormClosingMBoxTitle", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Record has been changed but not saved. Do you want to save changes?.
+ ///
+ internal static string CandidateFormClosingMessage {
+ get {
+ return ResourceManager.GetString("CandidateFormClosingMessage", resourceCulture);
+ }
+ }
}
}
diff --git a/sources/CandidatesBrowser/Properties/Resources.resx b/sources/CandidatesBrowser/Properties/Resources.resx
index af7dbeb..cce0f59 100644
--- a/sources/CandidatesBrowser/Properties/Resources.resx
+++ b/sources/CandidatesBrowser/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,15 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Warning
+
+
+ Record has been changed but not saved. Do you want to save changes?
+
\ No newline at end of file