コード例 #1
0
        // SALVAR REGISTRO
        //------------------------------------------------------------------------------------------------------------
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                // --- Ampulheta ON
                Cursor.Current = Cursors.WaitCursor;

                //--- check data
                if (!CheckSaveData())
                {
                    return;
                }

                CartaoBLL cBLL = new CartaoBLL();

                //--- SAVE: INSERT OR UPDATE
                if (_taxa.IDCartaoTaxa == null)                 //--- save | Insert
                {
                    int ID = cBLL.InsertCartaoTaxas(_taxa);
                    //--- define newID
                    _taxa.IDCartaoTaxa = ID;
                }
                else                 //--- update
                {
                    cBLL.UpdateCartaoTaxas(_taxa);
                }

                //--- change Sit
                Sit = EnumFlagEstado.RegistroSalvo;
                //--- emit massage
                AbrirDialog("Registro Salvo com sucesso!",
                            "Registro Salvo", DialogType.OK, DialogIcon.Information);
            }
            catch (Exception ex)
            {
                if (((System.Data.SqlClient.SqlException)ex).Number == 2627)                 // operadora + bandeira duplicada
                {
                    AbrirDialog($"As taxas da operadora: {_taxa.CartaoOperadora} já foi inserida com " +
                                (_taxa.IDCartaoBandeira == null ? "bandeiras diversas." : $"a bandeira {_taxa.CartaoBandeira}."),
                                "Duplicação de Cadastro", DialogType.OK, DialogIcon.Exclamation);
                }
                else
                {
                    AbrirDialog("Uma exceção ocorreu ao Salvar Registro de Operadora..." + "\n" +
                                ex.Message, "Exceção", DialogType.OK, DialogIcon.Exclamation);
                }
            }
            finally
            {
                // --- Ampulheta OFF
                Cursor.Current = Cursors.Default;
            }
        }
コード例 #2
0
		private void AtivarDesativar_Setor_Click(object sender, EventArgs e)
		{
			//--- verifica se existe alguma cell 
			if (dgvListagem.SelectedRows.Count == 0) return;

			//--- Verifica o item
			objCartaoTaxa cartao = (objCartaoTaxa)dgvListagem.SelectedRows[0].DataBoundItem;

			//---pergunta ao usuário
			var reponse = AbrirDialog($"Deseja realmente {(cartao.Ativo ? "DESATIVAR " : "ATIVAR")} essa Taxa de Operadora?\n" +
									  cartao.CartaoOperadora.ToUpper(), (cartao.Ativo ? "DESATIVAR " : "ATIVAR"),
									  DialogType.SIM_NAO, DialogIcon.Question);
			if (reponse == DialogResult.No) return;

			//--- altera o valor
			cartao.Ativo = !cartao.Ativo;

			//--- Salvar o Registro
			try
			{
				// --- Ampulheta ON
				Cursor.Current = Cursors.WaitCursor;

				cBLL.UpdateCartaoTaxas(cartao);

				//--- altera a imagem
				FiltrarListagem(sender, e);
			}
			catch (Exception ex)
			{
				AbrirDialog("Uma exceção ocorreu ao Alterar Taxa de Operadora..." + "\n" +
							ex.Message, "Exceção", DialogType.OK, DialogIcon.Exclamation);
			}
			finally
			{
				// --- Ampulheta OFF
				Cursor.Current = Cursors.Default;
			}
		}