/// <summary> /// The btnConfigure_Click. /// </summary> /// <param name="sender">The sender<see cref="object"/>.</param> /// <param name="e">The e<see cref="EventArgs"/>.</param> private void btnConfigure_Click(object sender, EventArgs e) { string password = txtPassword.Text; DateTime effectivedate = new DateTime(dtEffectiveDate.Value.Year, dtEffectiveDate.Value.Month, dtEffectiveDate.Value.Day, 0, 0, 0); configurationDetails = new ConfigurationDetails { effectiveDate = effectivedate, TotalNoOfReceipts = Convert.ToInt32(nmcReceipts.Value), NoOfMonths = Convert.ToInt32(nmcMonths.Value) }; if (string.IsNullOrWhiteSpace(password)) { MessageBox.Show("Please enter valid password...", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (!string.IsNullOrWhiteSpace(password) && password != Convert.ToString(ConfigurationManager.AppSettings["Password"])) { MessageBox.Show("Please enter valid password...", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (configurationDetails.TotalNoOfReceipts < 5) { MessageBox.Show("Total No.of Receipts should be greater than 5.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (configurationDetails.NoOfMonths < 3) { MessageBox.Show("Min No.of Months for booking annadhanam should be greater than or equal to 3.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (lstConfiguration.Any(n => n.effectiveDate.Date == dtEffectiveDate.Value.Date)) { MessageBox.Show("Record already exists in out database. Please choose another date !..", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); } else { SqlHelper.AddConfiguration(configurationDetails); dtEffectiveDate.MinDate = DateTime.Now.Date; dtEffectiveDate.MaxDate = DateTime.Now.AddYears(1); dtEffectiveDate.Value = DateTime.Now.Date; nmcReceipts.Value = 5; nmcMonths.Value = 3; LoadConfigurationDetails(); } }