protected void PopolaCampiOperaio(int idOperaio, bool isControlEnabled)
        {
            EnableDisableFields(pnlInsOperai, isControlEnabled);

            //Popolo i textbox
            Operai operaio = OperaiDAO.GetSingle(idOperaio);

            txtNomeOper.Text     = operaio.NomeOp;
            txtDescrOper.Text    = operaio.DescrOp;
            txtSuffOper.Text     = operaio.Suffisso;
            txtOperaio.Text      = operaio.Operaio;
            txtCostoOperaio.Text = operaio.CostoOperaio.ToString();

            // Lascio disabilitato il campo che viene compilato in automatico
            txtOperaio.Enabled = false;
        }
        public static bool InserisciOperaio(Operai operaio)
        {
            bool          ret = false;
            StringBuilder sql = new StringBuilder();

            sql.AppendLine($"INSERT INTO TblOperaio (NomeOp,DescrOP,Suffisso,Operaio,CostoOperaio)");
            sql.AppendLine($"VALUES (@NomeOp,@DescrOp,@Suffisso,@Operaio,@CostoOperaio)");
            try
            {
                using (SqlConnection cn = GetConnection())
                {
                    ret = cn.Execute(sql.ToString(), operaio) > 0;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Errore durante l'inserimento di un nuovo operaio", ex);
            }
            return(ret);
        }
        public static bool UpdateOperaio(Operai operaio)
        {
            bool          ret = false;
            StringBuilder sql = new StringBuilder();

            sql.AppendLine("UPDATE TblOperaio");
            sql.AppendLine("SET NomeOp = @NomeOp, DescrOp = @DescrOp, Suffisso = @Suffisso, Operaio = @Operaio, CostoOperaio = @CostoOperaio");
            sql.AppendLine("WHERE IdOperaio = @IdOperaio");
            try
            {
                using (SqlConnection cn = GetConnection())
                {
                    ret = cn.Execute(sql.ToString(), operaio) > 0;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Errore durante l'update di un operaio", ex);
            }
            return(ret);
        }
        public static Operai GetSingle(int idOperaio)
        {
            Operai        ret = new Operai();
            StringBuilder sql = new StringBuilder();

            try
            {
                sql.AppendLine($"SELECT *");
                sql.AppendLine($"FROM TblOperaio");
                sql.AppendLine($"WHERE IdOperaio = @idOperaio");
                sql.AppendLine($"ORDER BY NomeOp");
                using (SqlConnection cn = GetConnection())
                {
                    ret = cn.Query <Operai>(sql.ToString(), new { idOperaio }).FirstOrDefault();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Errore durante la GetSingle in OperaiDAO", ex);
            }
            return(ret);
        }