コード例 #1
0
        private void btnAnular_Click(object sender, EventArgs e)
        {
            try
            {
                imp_ordencompra_ext_x_ct_cbtecble_Bus BusOrdxCbt = new imp_ordencompra_ext_x_ct_cbtecble_Bus();
                Get();
                ct_Cbtecble_Bus CbteCble_B = new ct_Cbtecble_Bus();
                if (lbl_Estado.Visible)
                {
                    MessageBox.Show("No se puede anular el gasto debido a que ya se encuentra anulado.", "Mensaje Erp");
                    return;
                }
                FrmGe_MotivoAnulacion oFrm = new FrmGe_MotivoAnulacion();
                if (MessageBox.Show("¿Está seguro que desea anular el Gasto #" + txtIdRegistroGasto.Text + " ?", "Anulación de Gastos", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    oFrm.ShowDialog();
                    String MovitoAnulacion = oFrm.motivoAnulacion;
                    _Info.IdTipoCbte_Anul = tipocbte.IdTipoCbte_Anul;
                    string mensej = "";
                    if (Bus.AnularDB(_Info))
                    {
                        MessageBox.Show("Anulado con exito el Gasto # " + _Info.IdRegistroGasto);
                        lbl_Estado.Visible       = true;
                        btnOk.Enabled            = false;
                        BtnGuardarYsalir.Enabled = false;
                        decimal IdCbteCbleRev = 0;
                        string  msg2          = "";
                        if (generarDiarioTipoImp == true)
                        {
                            CbteCble_B.ReversoCbteCble(param.IdEmpresa, _SetInfo.IdCbteCble, tipocbte.IdTipoCbte, tipocbte.IdTipoCbte_Anul, ref IdCbteCbleRev, ref msg2, param.IdUsuario, MovitoAnulacion);

                            Bus.ACtualizarAnulado(_Info, IdCbteCbleRev);
                            imp_ordencompra_ext_x_ct_cbtecble_Info ordCompraxCbte_info = new imp_ordencompra_ext_x_ct_cbtecble_Info();
                            ordCompraxCbte_info.ct_IdEmpresa         = ordCompraxCbte_info.imp_IdEmpresa = param.IdEmpresa;
                            ordCompraxCbte_info.imp_IdOrdenCompraExt = Convert.ToDecimal(searchLookUpEditImportacion.EditValue);
                            var idSucursa = Importaciones.Find(var => var.IdOrdenCompraExt == ordCompraxCbte_info.imp_IdOrdenCompraExt).IdSucusal;
                            ordCompraxCbte_info.imp_IdSucusal = Convert.ToInt32(idSucursa);
                            ordCompraxCbte_info.ct_IdTipoCbte = tipocbte.IdTipoCbte_Anul;
                            ordCompraxCbte_info.ct_IdCbteCble = IdCbteCbleRev;
                            ordCompraxCbte_info.TipoReg       = "AGAST";
                            BusOrdxCbt.GuardarDB(ordCompraxCbte_info, ref msg2);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log_Error_bus.Log_Error(ex.ToString());
            }
        }