private void metroButton1_Click(object sender, EventArgs e)
{
this.edtCodMun.Focus();
if (Functions.CodigoParaUF(Convert.ToInt32(this.edtCodMun.Text.Substring(0, 2))) != this.edtUF.SelectedItem.ToString())
{
MetroFramework.MetroMessageBox.Show(this, "Código do IBGE diverge da UF", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (this.edtMunicipio.Text == "")
{
MetroFramework.MetroMessageBox.Show(this, "Nome do município deve ser informado", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
this.edtMunicipio.Focus();
return;
}
foreach (Municipio mun in Propriedade.Municipios)
if (mun.CodigoMunicipio.ToString() == this.edtCodMun.Text)
{
MetroFramework.MetroMessageBox.Show(this, "Código IBGE já definido no municipio \"" + mun.Nome + "\"", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
WebServiceNFSe.SalvarXMLMunicipios(this.edtUF.SelectedItem.ToString(),
this.edtMunicipio.Text,
Convert.ToInt32(this.edtCodMun.Text),
(this.edtPadrao.SelectedItem as PadroesDataSource).fromType,
false);
this.DialogResult = System.Windows.Forms.DialogResult.OK;
}
catch (Exception ex)
{
MetroFramework.MetroMessageBox.Show(null, ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}