private void facturasCabBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            bool ok = true;

            if (gridView1.RowCount > 0 && esPrevisionCheckEdit.CheckState != CheckState.Checked)
            {
                int nIdFactura = (int)gridView1.GetFocusedRowCellValue("IdFactCab");
                facturaIncorrectaTableAdapter.Fill(datosPresupuestos.FacturaIncorrecta, VariablesGlobales.nIdEmpresaActual, (DateTime)fechaFacturaDateTimePicker.Value, (bool)facturaCheckBox.Checked, int.Parse(numFacturaTextBox.Text), nIdFactura, txtSerieFact.Text);

                if (facturaIncorrectaBindingSource.Count > 0)
                {
                    ok = false;
                    DataTable tmpFacturas = datosPresupuestos.FacturaIncorrecta.Select().CopyToDataTable();

                    FacturasIncorrectas frm = new FacturasIncorrectas();
                    frm.LoadParametros(tmpFacturas);
                    // frm.MdiParent = this.MdiParent;
                    frm.ShowDialog();



                    //   MessageBox.Show("No se puede usar ese número de factura en esa fecha. Existen facturas con fecha posterior y número menos o con fecha inferior y número mayor a la actual.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }



            if (ok == true)
            {
                try
                {
                    //try
                    //{
                    queriesPresupuestos1.PoneAFacturarPresupuesto(FacturaEliminada);

                    //}
                    //catch (Exception ex)
                    //{
                    //    if (MessageBox.Show("No se pudieron poner las cantidades de la factura en -A Facturar- en el presupuesto. ¿Desea cancelar la eliminación de la Factura?\n Mensaje de Error: " + ex.Message, this.Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    //    {
                    //        return;
                    //    }
                    //}

                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(datosPresupuestos.FacturasCab);

                    ActuallizaUltimoNumeroFactura();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Los Cambios no se Guardaron.  " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Пример #2
0
        private void facturasCabBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            DataRowView FacturaAct = (DataRowView)facturasCabBindingSource.Current;

            int nIdFactura = Convert.ToInt32(FacturaAct["IdFactCab"]);

            bool ok = true;

            if (facturaCheckBox.CheckState == CheckState.Checked && esPrevisionCheckEdit.CheckState != CheckState.Checked)
            {
                facturaIncorrectaTableAdapter.Fill(promowork_dataDataSet.FacturaIncorrecta, VariablesGlobales.nIdEmpresaActual, (DateTime)fechaFacturaDateTimePicker.Value, (bool)facturaCheckBox.Checked, int.Parse(numFacturaTextBox.Text), nIdFactura, txtSerieFact.Text);

                if (facturaIncorrectaBindingSource.Count > 0)
                {
                    ok = false;
                    DataTable tmpFacturas = promowork_dataDataSet.FacturaIncorrecta.Select().CopyToDataTable();

                    FacturasIncorrectas frm = new FacturasIncorrectas();
                    frm.LoadParametros(tmpFacturas);
                    // frm.MdiParent = this.MdiParent;
                    frm.ShowDialog();



                    //   MessageBox.Show("No se puede usar ese número de factura en esa fecha. Existen facturas con fecha posterior y número menos o con fecha inferior y número mayor a la actual.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }

            if (ok == true)
            {
                try
                {
                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);
                    if (idCuentaComboBox.Text == "" && facturasCabDataGridView.RowCount != 0)
                    {
                        facturasCabDataGridView.CurrentRow.Cells["IdCuenta"].Value = DBNull.Value;
                    }
                    if (facturasCabDataGridView.RowCount != 0 && Convert.ToBoolean(facturasCabDataGridView.CurrentRow.Cells["FacturaPresup"].Value) == true && idPresupComboBox.Text != "")
                    {
                        DataRow     PresupActual  = promowork_dataDataSet.PresupCab.FindByIdPresupCab(Convert.ToInt32(idPresupComboBox.SelectedValue));
                        DataRowView FacturaActual = (DataRowView)facturasCabBindingSource.Current;
                        FacturaActual["IdObra"] = PresupActual["IdObra"];
                    }
                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);

                    //  this.tableAdapterManager.UpdateAll(this.promowork_dataDataSet);
                    //   int posFactcab = facturasCabBindingSource.Position;
                    int poscab = presupCabBindingSource.Position;
                    int poscap = presupCapBindingSource1.Position;
                    int posdet = presupDetBindingSource1.Position;
                    int possub = presupSubBindingSource1.Position;

                    //   this.facturasCabTableAdapter.FillByEmpresa(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual);
                    this.presupCabTableAdapter.Fill(this.promowork_dataDataSet.PresupCab);
                    this.presupSubTableAdapter.FillByNumDes(this.promowork_dataDataSet.PresupSub);
                    this.presupDetTableAdapter.FillByNumDes(this.promowork_dataDataSet.PresupDet);
                    this.presupCapTableAdapter.FillByNumDes(this.promowork_dataDataSet.PresupCap);

                    // facturasCabBindingSource.Position = posFactcab;
                    presupCabBindingSource.Position  = poscab;
                    presupCapBindingSource1.Position = poscap;
                    presupDetBindingSource1.Position = posdet;
                    presupSubBindingSource1.Position = possub;
                    presupSubBindingSource1.Filter   = "Pendiente<>0";
                    presupDetBindingSource1.Filter   = "Pendiente<>0";

                    string sIdPresup = Convert.ToString(idPresupComboBox.SelectedValue == null ? "0" : Convert.ToString(idPresupComboBox.SelectedValue));

                    // MessageBox.Show(sIdPresup);
                    presupCapBindingSource1.Filter = "Pendiente<>0 and IdPresupCab=" + sIdPresup;

                    button1.Enabled = true;
                    //toolStripButton1.Enabled = true;
                    // toolStripButton12.Enabled = true;
                    facturasCabDataGridView.Enabled = true;
                    facturasCabDataGridView_CellEnter(null, null);
                }
                catch (DBConcurrencyException)
                {
                    MessageBox.Show("No se Pudo Salvar la Información. El Registro fue modificado por otro Usuario.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    if (cbxfacturas.Text == "Facturas")
                    {
                        this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                    }
                    else
                    {
                        this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                    }
                    facturasCabBindingSource.Filter = "FacturaPresup=1";
                }
                catch (SqlException ex)
                {
                    if (ErroresSQLServer.ManipulaErrorSQL(ex, this.Text))
                    {
                        if (cbxfacturas.Text == "Facturas")
                        {
                            this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                        }
                        else
                        {
                            this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                        }
                        facturasCabBindingSource.Filter = "FacturaPresup=1";
                    }
                }
            }
        }
Пример #3
0
        private void facturasCabBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            DataRowView FacturaAct = (DataRowView)facturasCabBindingSource.Current;

            int nIdFactura = Convert.ToInt32(FacturaAct["IdFactCab"]);

            bool ok = true;

            if (facturaCheckBox.CheckState == CheckState.Checked && esPrevisionCheckEdit.CheckState != CheckState.Checked)
            {
                facturaIncorrectaTableAdapter.Fill(promowork_dataDataSet.FacturaIncorrecta, VariablesGlobales.nIdEmpresaActual, (DateTime)fechaFacturaDateTimePicker.Value, (bool)facturaCheckBox.Checked, int.Parse(numFacturaTextBox.Text), nIdFactura, txtSerieFact.Text);

                if (facturaIncorrectaBindingSource.Count > 0)
                {
                    ok = false;
                    DataTable tmpFacturas = promowork_dataDataSet.FacturaIncorrecta.Select().CopyToDataTable();

                    FacturasIncorrectas frm = new FacturasIncorrectas();
                    frm.LoadParametros(tmpFacturas);
                    // frm.MdiParent = this.MdiParent;
                    frm.ShowDialog();



                    //   MessageBox.Show("No se puede usar ese número de factura en esa fecha. Existen facturas con fecha posterior y número menos o con fecha inferior y número mayor a la actual.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }

            if (ok == true)
            {
                try
                {
                    //MessageBox.Show(comboBox4.SelectedValue.ToString());

                    // DataRowView factura = (DataRowView)facturasCabBindingSource.Current;
                    //factura["IdClienteFact"] = comboBox4.SelectedValue;
                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);
                    if (idCuentaComboBox.Text == "" && facturasCabDataGridView.RowCount != 0)
                    {
                        facturasCabDataGridView.CurrentRow.Cells["IdCuenta"].Value = DBNull.Value;
                    }

                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);

                    toolStripButton1.Enabled = true;
                    // toolStripButton12.Enabled = true;
                    facturasCabDataGridView.Enabled = true;
                    facturasCabDataGridView_CellEnter(null, null);

                    ActuallizaUltimoNumeroFactura();
                }
                catch (DBConcurrencyException)
                {
                    MessageBox.Show("No se Pudo Salvar la Información. El Registro fue modificado por otro Usuario.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    if (cbxfacturas.Text == "Facturas")
                    {
                        this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, anoFacturas);
                    }
                    else
                    {
                        this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, anoFacturas);
                    }
                    facturasCabBindingSource.Filter = "FacturaPresup=0";
                }
                catch (SqlException ex)
                {
                    if (ErroresSQLServer.ManipulaErrorSQL(ex, this.Text))
                    {
                        if (cbxfacturas.Text == "Facturas")
                        {
                            this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, anoFacturas);
                        }
                        else
                        {
                            this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, anoFacturas);
                        }
                        facturasCabBindingSource.Filter = "FacturaPresup=0";
                    }
                }
            }
        }
Пример #4
0
        private void facturasCabBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            bool ok = true;

            if (gridView6.RowCount > 0)
            {
                DataRowView FacturaAct = (DataRowView)facturasCabBindingSource.Current;

                int nIdFactura = Convert.ToInt32(FacturaAct["IdFactCab"]);


                if (facturaCheckBox.CheckState == CheckState.Checked && esPrevisionCheckEdit.CheckState != CheckState.Checked)
                {
                    facturaIncorrectaTableAdapter.Fill(promowork_dataDataSet.FacturaIncorrecta, VariablesGlobales.nIdEmpresaActual, (DateTime)fechaFacturaDateTimePicker.Value, (bool)facturaCheckBox.Checked, int.Parse(numFacturaTextBox.Text), nIdFactura, txtSerieFact.Text);

                    if (facturaIncorrectaBindingSource.Count > 0)
                    {
                        ok = false;
                        DataTable tmpFacturas = promowork_dataDataSet.FacturaIncorrecta.Select().CopyToDataTable();

                        FacturasIncorrectas frm = new FacturasIncorrectas();
                        frm.LoadParametros(tmpFacturas);
                        // frm.MdiParent = this.MdiParent;
                        frm.ShowDialog();



                        //   MessageBox.Show("No se puede usar ese número de factura en esa fecha. Existen facturas con fecha posterior y número menos o con fecha inferior y número mayor a la actual.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    }
                }
            }

            if (ok == true)
            {
                try
                {
                    this.Validate();
                    this.facturasCabBindingSource.EndEdit();
                    facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);

                    decimal importe = 0;
                    try
                    {
                        importe = decimal.Parse(importeTextBox1.Text);
                    }
                    catch { }

                    decimal impBase = 0;
                    try
                    {
                        impBase = decimal.Parse(impBaseTextBox.Text);
                    }
                    catch { }

                    decimal impIVA = 0;
                    try
                    {
                        impIVA = decimal.Parse(impIVATextBox.Text);
                    }
                    catch { }

                    if (gridView6.RowCount > 0)
                    {
                        DataRowView facturaActual = (DataRowView)facturasCabBindingSource.Current;
                        //  facturaActual["Cobrada"] = importe <= impBase && impBase != 0 ? true : false;
                        facturaActual["Entregada"] = entregadaCheckBox.CheckState;



                        // this.facturasCabDataGridView.CurrentRow.Cells["Entregada"].Value = entregadaCheckBox.CheckState;

                        if (idCuentaComboBox.Text == "")
                        {
                            facturaActual["IdCuenta"] = DBNull.Value;
                        }
                        this.Validate();
                        this.facturasCabBindingSource.EndEdit();
                        facturasCabTableAdapter.Update(promowork_dataDataSet.FacturasCab);
                        //  toolStripButton1.Enabled = true;
                        // toolStripButton12.Enabled = true;
                        facturasCabGridControl.Enabled = true;

                        //DataRowView empresa = (DataRowView)empresasActualBindingSource.Current;
                        //empresa["FactEmpresa"] = Convert.ToInt32(numFacturaTextBox.Text) + 1;
                        //this.Validate();
                        //this.empresasActualBindingSource.EndEdit();
                        //empresasActualTableAdapter.Update(promowork_dataDataSet.EmpresasActual);

                        this.Validate();
                        this.cobrosBindingSource.EndEdit();

                        ActuallizaUltimoNumeroFactura();

                        if (impBase != 0)
                        {
                            if (cobrosBindingSource.Count == 0)
                            {
                                int?nidobra;
                                nidobra = (int?)idPresupComboBox.SelectedValue;
                                cobrosTableAdapter.Insert(VariablesGlobales.nIdUsuarioActual, VariablesGlobales.nIdEmpresaActual, (int)idClienteComboBox.SelectedValue,
                                                          nidobra, fechaExpDateTimePicker.Value, fechaExpDateTimePicker.Value, fechaExpDateTimePicker.Value,
                                                          fechaExpDateTimePicker.Value, (int)gridView6.GetFocusedRowCellValue("IdFactCab"), numFacturaTextBox.Text + "/" + fechaFacturaDateTimePicker.Value.Year.ToString(), (int)desFormaPagoComboBox.SelectedValue,
                                                          (int)comboBox2.SelectedValue, impBase, impIVA, null, null, fechaFacturaDateTimePicker.Value, null, false, false, null);
                            }
                        }
                        else
                        {
                            if (cobrosBindingSource.Count != 0)
                            {
                                cobrosBindingSource.RemoveCurrent();
                            }
                        }


                        this.cobrosTableAdapter.Update(promowork_dataDataSet.Cobros);
                        this.cobrosTableAdapter.FillByFactura(this.promowork_dataDataSet.Cobros, (int)gridView6.GetFocusedRowCellValue("IdFactCab"));
                    }
                }
                catch (NullReferenceException ex)
                {
                    MessageBox.Show("Debe completar los datos del Cobro.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                catch (DBConcurrencyException)
                {
                    MessageBox.Show("No se Pudo Salvar la Información. El Registro fue modificado por otro Usuario.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    if (cbxfacturas.Text == "Facturas")
                    {
                        this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                    }
                    else
                    {
                        this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                    }
                }
                catch (SqlException ex)
                {
                    if (ErroresSQLServer.ManipulaErrorSQL(ex, this.Text))
                    {
                        if (cbxfacturas.Text == "Facturas")
                        {
                            this.facturasCabTableAdapter.FillByFactHorasFacturas(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                        }
                        else
                        {
                            this.facturasCabTableAdapter.FillByFactHorasParte(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual, (int)cbxanos.SelectedValue);
                        }
                    }
                }
                //    this.facturasCabTableAdapter.FillByFactHoras(this.promowork_dataDataSet.FacturasCab, VariablesGlobales.nIdEmpresaActual);
                gridView6_FocusedRowChanged(null, null);

                if (gridView6.RowCount > 0)
                {
                    this.importeFacturaHorasTableAdapter.FillFactura(promowork_dataDataSet.ImporteFacturaHoras, (int)gridView6.GetFocusedRowCellValue("IdFactCab"));
                }
            }
        }