Ejemplo n.º 1
0
        protected void grdFatture_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                e.Row.Cells[3].Text  = "Imponibile";
                e.Row.Cells[6].Text  = "Valore Iva";
                e.Row.Cells[7].Text  = "Valore Rit. Acc.";
                e.Row.Cells[8].Text  = "Imp. Fattura";
                e.Row.Cells[9].Text  = "Reverse Charge";
                e.Row.Cells[10].Text = "Nota Credito";
            }
            else if (e.Row.RowType == DataControlRowType.DataRow)
            {
                long            rowIdFattura = Convert.ToInt64((e.Row.FindControl("hfRowIdFattura") as HiddenField).Value);
                FatturaAcquisto fattura      = FattureAcquistoDAO.GetSingle(rowIdFattura);

                double imponibile            = fattura.Imponibile;
                double valoreIva             = imponibile * fattura.Iva / 100;
                double valoreRitenutaAcconto = imponibile * fattura.RitenutaAcconto / 100;

                (e.Row.FindControl("lblValoreIva") as Label).Text             = valoreIva.ToString("N2");
                (e.Row.FindControl("lblValoreRitenutaAcconto") as Label).Text = valoreRitenutaAcconto.ToString("N2");

                double importoFattura = imponibile + valoreIva - valoreRitenutaAcconto;
                (e.Row.FindControl("lblImportoFattura") as Label).Text = importoFattura.ToString("N2");

                // Scrivo i totali generali
                totaleImporto += importoFattura;
            }
        }
Ejemplo n.º 2
0
        private void PopolaCampi(int idFatturaAcquisto, bool isModifica)
        {
            FatturaAcquisto fatt = FattureAcquistoDAO.GetSingle(idFatturaAcquisto);

            txtNumeroFattura.Text            = fatt.Numero.ToString();
            ddlScegliFornitore.SelectedValue = fatt.IdFornitore.ToString();
            txtData.Text             = fatt.Data.ToString("yyyy-MM-dd");
            txtData.TextMode         = TextBoxMode.Date;
            txtImponibile.Text       = fatt.Imponibile.ToString();
            txtRitenutaAcconto.Text  = fatt.RitenutaAcconto.ToString();
            txtIva.Text              = fatt.Iva.ToString();
            chkNotaCredito.Checked   = fatt.IsNotaDiCredito;
            chkReverseCharge.Checked = fatt.ReverseCharge;
            txtConcatenazione.Text   = $"Fat. {fatt.Numero.ToString()} del {fatt.Data.ToString("dd/MM/yyyy")}";

            // Accessibilità campi
            txtNumeroFattura.ReadOnly   = txtData.ReadOnly = !isModifica;
            txtImponibile.ReadOnly      = txtRitenutaAcconto.ReadOnly = txtIva.ReadOnly = !isModifica;
            txtFiltroFornitore.ReadOnly = !isModifica;
            chkNotaCredito.Enabled      = chkReverseCharge.Enabled = isModifica;
            ddlScegliFornitore.Enabled  = isModifica;

            // Visibilità pannelli
            pnlInsFatture.Visible     = true;
            pnlRicercaFatture.Visible = !pnlInsFatture.Visible;
        }
Ejemplo n.º 3
0
        private void PopolaGriglia(FornitoriFattureAcquisto fornitore)
        {
            _fatture = FatturaAcquisto.EstraiListaFattureAcquisto(fornitore.Codice);
            if (_fatture.Count == 0)
            {
                dgrRisultati.DataSource = null;
                dgrRisultati.Update();
                return;
            }
            dgrRisultati.AutoGenerateColumns = false;
            BindingList <FatturaAcquisto> bindingList = new BindingList <FatturaAcquisto>(_fatture);

            sourceFatture           = new BindingSource(bindingList, null);
            dgrRisultati.DataSource = sourceFatture;
            dgrRisultati.Update();
        }
Ejemplo n.º 4
0
        public static FatturaAcquisto GetSingle(long idFatturaAcquisto)
        {
            FatturaAcquisto ret = new FatturaAcquisto();
            StringBuilder   sql = new StringBuilder("SELECT * FROM TblFattureAcquisto WHERE id_fatture_acquisto = @idFatturaAcquisto ORDER BY numero");

            try
            {
                using (SqlConnection cn = GetConnection())
                {
                    ret = cn.Query <FatturaAcquisto>(sql.ToString(), new { idFatturaAcquisto }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Errore durante il recupero del singolo Fattura, id = {idFatturaAcquisto}", ex);
            }
            return(ret);
        }
Ejemplo n.º 5
0
        public static bool Update(FatturaAcquisto fa)
        {
            StringBuilder sql = new StringBuilder();

            sql.AppendLine($"UPDATE TblFattureAcquisto");
            sql.AppendLine($"SET id_fornitore = @IdFornitore, numero = @Numero, data = @Data, imponibile = @Imponibile, iva = @Iva,");
            sql.AppendLine($"ritenuta_acconto = @RitenutaAcconto, reverse_charge = @ReverseCharge, is_nota_di_credito = @IsNotaDiCredito, file_path = @FilePath");
            sql.AppendLine($"WHERE id_fatture_acquisto = @IdFattureAcquisto");
            try
            {
                using (SqlConnection cn = GetConnection())
                {
                    return(cn.Execute(sql.ToString(), fa) > 0);
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Errore durante l'aggiornamento della FatturaAcquisto {fa.Numero}", ex);
            }
        }
Ejemplo n.º 6
0
        public static long Insert(FatturaAcquisto fa)
        {
            long          ret = 0;
            StringBuilder sql = new StringBuilder();

            sql.AppendLine($"INSERT INTO TblFattureAcquisto (id_fornitore,numero,data,imponibile,iva,ritenuta_acconto,reverse_charge,is_nota_di_credito,file_path)");
            sql.AppendLine($"VALUES (@IdFornitore,@Numero,@Data,@Imponibile,@Iva,@RitenutaAcconto,@ReverseCharge,@IsNotaDiCredito,@FilePath)");
            sql.AppendLine($"SELECT CAST(scope_identity() AS bigint)");
            try
            {
                using (SqlConnection cn = GetConnection())
                {
                    ret = cn.Query <long>(sql.ToString(), fa).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Errore durante l'inserimento della FatturaAcquisto {fa.Numero}", ex);
            }
            return(ret);
        }