コード例 #1
0
        private void _Mtd_Anular()
        {
            try
            {
                string  _Str_cndanu     = "";
                string  _Str_cidcomprob = "";
                string  _Str_Sql        = "select cidcomprobanul,ccliente from TNOTADEBICC where cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebitocc='" + _Txt_Cod.Text + "'";
                DataSet _Ds2            = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Sql);
                if (_Ds2.Tables[0].Rows.Count > 0)
                {
                    if (_Str_MyProceso == "F1")
                    {
                        _Str_Sql = "UPDATE TNOTADEBICC SET cmotivoanulacion='" + _Cmb_Motivo.SelectedValue.ToString() + "',cfechaanul='" + _My_Formato._Mtd_fecha(CLASES._Cls_Varios_Metodos._Mtd_SQLGetDate()) + "' WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebitocc='" + _Txt_Cod.Text.Trim() + "' and ccliente='" + _Txt_CodCliente.Text.Trim() + "'";
                        Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                        _Str_cndanu = _MyUtilidad._Mtd_Correlativo("SELECT MAX(cndanu) FROM TNDANUL WHERE ccompany='" + Frm_Padre._Str_Comp + "'");
                        if (!Program._MyClsCnn._mtd_conexion._Mtd_ExistenRegistros("SELECT * FROM TNDANUL WHERE ccompany='" + Frm_Padre._Str_Comp + "' AND cidnotadebito='" + _Txt_Cod.Text.Trim() + "'"))
                        {
                            _Str_Sql = "INSERT INTO TNDANUL (ccompany,cidnotadebito,cndanu,cdescripcion,cfechaanul,cactivo,cestatusfirma,cdateadd,cuseradd,cdelete) VALUES('" +
                                       Frm_Padre._Str_Comp + "','" + _Txt_Cod.Text + "','" + _Str_cndanu + "','" + _Txt_Descripcion.Text.ToUpper() + "','" + _My_Formato._Mtd_fecha(CLASES._Cls_Varios_Metodos._Mtd_SQLGetDate()) + "',0,1,'" + _My_Formato._Mtd_fecha(CLASES._Cls_Varios_Metodos._Mtd_SQLGetDateServ()) + "','" + Frm_Padre._Str_Use + "',0)";
                            Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                        }
                        MessageBox.Show("Se cargo la ND como anulada.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (_Rbt_NoAnul.Checked)
                        {
                            _Mtd_Actualizar_NoAnul();
                        }
                        else
                        {
                            _Mtd_Actualizar_Anul();
                        }
                        _Mtd_Ini();
                        _Bt_Anular.Enabled    = false;
                        _Tb_Tab.SelectedIndex = 0;
                    }
                    else if (_Str_MyProceso == "F2")
                    {
                        string _Str_Cadena = "SELECT cidnotadebito FROM TNDANUL WHERE cidnotadebito='" + _Txt_Cod.Text.Trim() + "' AND ccompany='" + Frm_Padre._Str_Comp + "'";
                        if (Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena).Tables[0].Rows.Count > 0)
                        {
                            PrintDialog _Print = new PrintDialog();
_PrintG:
                            if (_Print.ShowDialog() == DialogResult.OK)
                            {
                                string _Str_Id_Comprobante = "";
                                _Str_Cadena = "SELECT cidcomprobanul FROM TNOTADEBICC WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebitocc='" + _Txt_Cod.Text.Trim() + "' and ccliente='" + _Txt_CodCliente.Text.Trim() + "'";
                                DataSet _DsTemp = Program._MyClsCnn._mtd_conexion._Mtd_RetornarDataset(_Str_Cadena);
                                if (_DsTemp.Tables[0].Rows[0][0] == System.DBNull.Value | _DsTemp.Tables[0].Rows[0][0].ToString().Trim() == "0")
                                {
                                    if (CLASES._Cls_Varios_Metodos._Mtd_EsClienteIC(_Txt_CodCliente.Text.Trim()))
                                    {
                                        _Str_Id_Comprobante = _MyUtilidad._Mtd_Proceso_P_CXC_ND_A(_Txt_Cod.Text.Trim(), "P_CXC_ND_A_IC");
                                    }
                                    else
                                    {
                                        _Str_Id_Comprobante = _MyUtilidad._Mtd_Proceso_P_CXC_ND_A(_Txt_Cod.Text.Trim(), "P_CXC_ND_A");
                                    }
                                    _Str_Sql = "UPDATE TNOTADEBICC SET cidcomprobanul='" + _Str_Id_Comprobante + "' WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebitocc='" + _Txt_Cod.Text.Trim() + "' and ccliente='" + _Txt_CodCliente.Text.Trim() + "'";
                                    Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                                }
                                else
                                {
                                    _Str_Id_Comprobante = _DsTemp.Tables[0].Rows[0][0].ToString().Trim();
                                }
                                Cursor = Cursors.WaitCursor;
                                REPORTESS _Frm = new REPORTESS(new string[] { "vst_reportecomprobante" }, "", "T3.Report.rcomprobante", "Section1", "cabecera", "rif", "nit", "ccompany='" + Frm_Padre._Str_Comp + "' and cidcomprob='" + _Str_Id_Comprobante + "'", _Print, true);
                                Cursor         = Cursors.Default;
                                _Frm.MdiParent = this.MdiParent;
                                _Frm.Show();
                                if (MessageBox.Show("¿La impresión se ha realizado correctamente?", "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                                {
                                    _Str_Sql = "UPDATE TNOTADEBICC SET canulado='1' WHERE cgroupcomp='" + Frm_Padre._Str_GroupComp + "' and ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebitocc='" + _Txt_Cod.Text.Trim() + "' and ccliente='" + _Txt_CodCliente.Text.Trim() + "'";
                                    Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                                    _Str_Sql = "UPDATE TNDANUL SET cactivo=1,cestatusfirma=2 WHERE ccompany='" + Frm_Padre._Str_Comp + "' and cidnotadebito='" + _Txt_Cod.Text.Trim() + "'";
                                    Program._MyClsCnn._mtd_conexion._Mtd_EjecutarSentencia(_Str_Sql);
                                    MessageBox.Show("Se anuló correctamente la N.D.", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    if (_Rbt_NoAnul.Checked)
                                    {
                                        _Mtd_Actualizar_NoAnul();
                                    }
                                    else
                                    {
                                        _Mtd_Actualizar_Anul();
                                    }
                                    _Mtd_Ini();
                                    _Bt_Anular.Enabled    = false;
                                    _Tb_Tab.SelectedIndex = 0;
                                }
                                else
                                {
                                    _Frm.Close();
                                    GC.Collect();
                                    goto _PrintG;
                                }
                            }
                        }
                        else
                        {
                            MessageBox.Show("Han eliminado la anulación. Deben cargar la anulación nuevamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
            }
            catch (Exception _Ex) { MessageBox.Show(_Ex.Message); Cursor = Cursors.Default; }
        }