private void btnExcluir_Click(object sender, EventArgs e)
        {
            if (metroGrid1.RowCount > 0)
            {
                if (metroGrid1.CurrentRow.Cells[6].Value.ToString() != null)
                {
                    if (metroGrid1.CurrentRow.Cells[6].Value.ToString() == "Não")
                    {
                        if (metroGrid1.CurrentRow.Cells[0].Value.ToString() != null)
                        {
                            if (MetroFramework.MetroMessageBox.Show(this, "Tem certeza que deseja excluir a compra : " + metroGrid1.CurrentRow.Cells[0].Value.ToString(), "Excluir ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                            {
                                return;
                            }

                            try
                            {
                                wbclient.DeleteCompraGado(Convert.ToInt32(metroGrid1.CurrentRow.Cells[0].Value.ToString()));
                            }
                            catch (Exception ex)
                            {
                                MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }

                            Pesquisar();
                        }
                    }
                    else
                    {
                        MetroFramework.MetroMessageBox.Show(this, "Não é permitido excluir uma compra já impresso.", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
            }
        }
Example #2
0
        private void frmCompraGado_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (metroGrid1.RowCount < 1 && txtId.Text != "NOVO")
            {
                WebServiceMarfrigSoapClient wbClinet = null;

                try
                {
                    wbClinet = new WebServiceMarfrigSoapClient();
                    wbClinet.DeleteCompraGado(Convert.ToInt32(txtId.Text));
                }
                catch (Exception ex)
                {
                    MetroFramework.MetroMessageBox.Show(this, ex.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        public void TestDeleteCompraGado()
        {
            bool resultado = wbClinet.DeleteCompraGado(1);

            Assert.AreEqual(true, resultado);
        }